Sha256: 556f37770f28e03d21a300ca75e5bc646a044850aa719e701199a19837df94cc

Contents?: true

Size: 1.01 KB

Versions: 48

Compression:

Stored size: 1.01 KB

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")
      HashWithIndifferentAccess.new(ActiveSupport::JSON.decode(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

48 entries across 48 versions & 1 rubygems

Version Path
disco_app-0.16.0 test/support/test_file_fixtures.rb
disco_app-0.14.4 test/support/test_file_fixtures.rb
disco_app-0.14.3 test/support/test_file_fixtures.rb
disco_app-0.16.1 test/support/test_file_fixtures.rb
disco_app-0.15.2 test/support/test_file_fixtures.rb
disco_app-0.12.7.pre.puma.pre.3 test/support/test_file_fixtures.rb
disco_app-0.14.0 test/support/test_file_fixtures.rb
disco_app-0.13.6.pre.puma.pre.3 test/support/test_file_fixtures.rb