mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-06-02 00:00:35 -04:00
See [1] for details, but a few conventions changed around the structure of the OpenAPI repository and the data within the fixtures file. Here we put in some minor changes to compensate for them. [1] https://github.com/stripe/openapi/pull/3
44 lines
989 B
Ruby
44 lines
989 B
Ruby
require 'rake/testtask'
|
|
|
|
task :default => [:test]
|
|
|
|
Rake::TestTask.new do |t|
|
|
t.pattern = './test/**/*_test.rb'
|
|
end
|
|
|
|
desc "Update bundled certs"
|
|
task :update_certs do
|
|
require "faraday"
|
|
|
|
fetch_file "https://curl.haxx.se/ca/cacert.pem",
|
|
File.expand_path("../lib/data/ca-certificates.crt", __FILE__)
|
|
end
|
|
|
|
desc "Update OpenAPI specification"
|
|
task :update_openapi do
|
|
require "faraday"
|
|
|
|
["fixtures.json", "fixtures.yaml", "spec2.json", "spec2.yaml"].map { |file|
|
|
Thread.new do
|
|
fetch_file "https://raw.githubusercontent.com/stripe/openapi/master/openapi/#{file}",
|
|
File.expand_path("../openapi/#{file}", __FILE__)
|
|
end
|
|
}.map { |t| t.join }
|
|
end
|
|
|
|
#
|
|
# helpers
|
|
#
|
|
|
|
def fetch_file(url, dest)
|
|
File.open(dest, 'w') do |file|
|
|
resp = Faraday.get(url)
|
|
unless resp.status == 200
|
|
abort("bad response when fetching: #{url}\n" \
|
|
"Status #{resp.status}: #{resp.body}")
|
|
end
|
|
file.write(resp.body)
|
|
puts "Successfully fetched: #{url}"
|
|
end
|
|
end
|