module DiscoApp::Test::FileFixtures

Public Instance Methods

json_fixture(path, dir: 'json', parse: true) click to toggle source

Return a JSON fixture as an indifferent hash.

# File lib/disco_app/support/file_fixtures.rb, line 11
def json_fixture(path, dir: 'json', parse: true)
  filename = Rails.root.join('test', 'fixtures', dir, "#{path}.json")
  return File.read(filename) unless parse

  HashWithIndifferentAccess.new(JSON.parse(File.read(filename)))
end
webhook_fixture(path, parse: true) click to toggle source

Webhook fixtures are special-case JSON fixtures.

# File lib/disco_app/support/file_fixtures.rb, line 19
def webhook_fixture(path, parse: true)
  json_fixture(path, dir: 'webhooks', parse: parse)
end
xml_fixture(path) click to toggle source

Return an XML fixture as an XML string.

# File lib/disco_app/support/file_fixtures.rb, line 5
def xml_fixture(path)
  filename = Rails.root.join('test', 'fixtures', 'xml', "#{path}.xml")
  File.read(filename)
end