mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-06-17 00:00:50 -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
30 lines
619 B
Ruby
30 lines
619 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)[:resources]
|
|
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
|