Sha256: 227ee218262599328485ae8db3a5d7b0cee9cf75870e6176e1888f07fccd3e1f

Contents?: true

Size: 999 Bytes

Versions: 7

Compression:

Stored size: 999 Bytes

Contents

module DiscoApp::Test
  module FileFixtures

    # Return an XML fixture as an XML string.
    def xml_fixture(path)
      filename = File.join(File.dirname(File.dirname(__FILE__)), 'fixtures', 'xml', "#{path}.xml")
      File.read(filename)
    end

    # Return a JSON fixture as an indifferent hash.
    def json_fixture(path)
      filename = File.join(File.dirname(File.dirname(__FILE__)), 'fixtures', 'json', "#{path}.json")
      HashWithIndifferentAccess.new(JSON.parse(File.read(filename)))
    end

    # API fixtures are special-case JSON fixtures.
    def api_fixture(path)
      filename = File.join(File.dirname(File.dirname(__FILE__)), 'fixtures', 'api', "#{path}.json")
      HashWithIndifferentAccess.new(JSON.parse(File.read(filename)))
    end

    # Webhook fixtures are special-case JSON fixtures.
    def webhook_fixture(path)
      filename = File.join(File.dirname(File.dirname(__FILE__)), 'fixtures', 'webhooks', "#{path}.json")
      File.read(filename)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.17.0 test/support/test_file_fixtures.rb
disco_app-0.18.0 test/support/test_file_fixtures.rb
disco_app-0.18.2 test/support/test_file_fixtures.rb
disco_app-0.18.3 test/support/test_file_fixtures.rb
disco_app-0.18.6 test/support/test_file_fixtures.rb
disco_app-0.18.4 test/support/test_file_fixtures.rb
disco_app-0.18.1 test/support/test_file_fixtures.rb