Module: DiscoApp::Test::FileFixtures
- Included in:
- ActiveSupport::TestCase
- Defined in:
- lib/disco_app/support/file_fixtures.rb
Instance Method Summary collapse
-
#json_fixture(path, dir: 'json', parse: true) ⇒ Object
Return a JSON fixture as an indifferent hash.
-
#webhook_fixture(path, parse: true) ⇒ Object
Webhook fixtures are special-case JSON fixtures.
-
#xml_fixture(path) ⇒ Object
Return an XML fixture as an XML string.
Instance Method Details
#json_fixture(path, dir: 'json', parse: true) ⇒ Object
Return a JSON fixture as an indifferent hash.
11 12 13 14 15 16 |
# 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) ⇒ Object
Webhook fixtures are special-case JSON fixtures.
19 20 21 |
# 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) ⇒ Object
Return an XML fixture as an XML string.
5 6 7 8 |
# 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 |