Sha256: f0c37beae9fc729bf8517afab8dea8878f18cd46fffc1090a024ea45f6e3ad51

Contents?: true

Size: 704 Bytes

Versions: 7

Compression:

Stored size: 704 Bytes

Contents

module DiscoApp::Test
  module FileFixtures

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

    # Return a JSON fixture as an indifferent hash.
    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 fixtures are special-case JSON fixtures.
    def webhook_fixture(path, parse: true)
      json_fixture(path, dir: 'webhooks', parse: parse)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
disco_app-0.17.0 lib/disco_app/support/file_fixtures.rb
disco_app-0.18.0 lib/disco_app/support/file_fixtures.rb
disco_app-0.18.2 lib/disco_app/support/file_fixtures.rb
disco_app-0.18.3 lib/disco_app/support/file_fixtures.rb
disco_app-0.18.6 lib/disco_app/support/file_fixtures.rb
disco_app-0.18.4 lib/disco_app/support/file_fixtures.rb
disco_app-0.18.1 lib/disco_app/support/file_fixtures.rb