mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-06-03 00:01:47 -04:00
Naming a directory `spec` in a Ruby project is terribly ambiguous. This clarifies the purpose of this directory and makes it easier to find if you know that you're looking for OpenAPI.
30 lines
607 B
Ruby
30 lines
607 B
Ruby
# APIFixtures loads fixture data generated by the core Stripe API so that we
|
|
# can have slightly more accurate and up-to-date resource information in our
|
|
# tests.
|
|
class APIFixtures
|
|
def initialize
|
|
@fixtures = ::JSON.parse(File.read("#{PROJECT_ROOT}/openapi/fixtures.json"),
|
|
symbolize_names: true)
|
|
freeze_recursively(@fixtures)
|
|
end
|
|
|
|
def [](name)
|
|
@fixtures[name]
|
|
end
|
|
|
|
def fetch(*args)
|
|
@fixtures.fetch(*args)
|
|
end
|
|
|
|
private
|
|
|
|
def freeze_recursively(data)
|
|
data.each do |k, v|
|
|
if v.is_a?(Hash)
|
|
freeze_recursively(v)
|
|
end
|
|
end
|
|
data.freeze
|
|
end
|
|
end
|