Sha256: d2b0534de12d2f9532e1dac98f0baa1b155571d0558becdb431e9bfa502a7d38

Contents?: true

Size: 972 Bytes

Versions: 21

Compression:

Stored size: 972 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(ActiveSupport::JSON.decode(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")
      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

21 entries across 21 versions & 1 rubygems

Version Path
disco_app-0.6.0 test/support/test_file_fixtures.rb
disco_app-0.6.1 test/support/test_file_fixtures.rb
disco_app-0.6.2 test/support/test_file_fixtures.rb
disco_app-0.6.3 test/support/test_file_fixtures.rb
disco_app-0.6.4 test/support/test_file_fixtures.rb
disco_app-0.6.5 test/support/test_file_fixtures.rb
disco_app-0.6.6 test/support/test_file_fixtures.rb
disco_app-0.6.7 test/support/test_file_fixtures.rb
disco_app-0.6.8 test/support/test_file_fixtures.rb
disco_app-0.6.9 test/support/test_file_fixtures.rb
disco_app-0.7.0 test/support/test_file_fixtures.rb
disco_app-0.7.1 test/support/test_file_fixtures.rb
disco_app-0.7.2 test/support/test_file_fixtures.rb
disco_app-0.8.0 test/support/test_file_fixtures.rb
disco_app-0.8.1 test/support/test_file_fixtures.rb
disco_app-0.8.2 test/support/test_file_fixtures.rb
disco_app-0.8.3 test/support/test_file_fixtures.rb
disco_app-0.8.4 test/support/test_file_fixtures.rb
disco_app-0.8.5 test/support/test_file_fixtures.rb
disco_app-0.8.6 test/support/test_file_fixtures.rb