stripe-ruby/test/api_fixtures.rb
Brandur 96e03a8443 Update some OpenAPI repository conventions
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
2017-03-23 16:28:36 -07:00

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