Sha256: bdb47bf47db0496d636f480952c021dc65ba84137b9e923a5025709e674a5a84

Contents?: true

Size: 719 Bytes

Versions: 65

Compression:

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

65 entries across 65 versions & 1 rubygems

Version Path
disco_app-0.16.1 lib/disco_app/support/file_fixtures.rb
disco_app-0.15.2 lib/disco_app/support/file_fixtures.rb
disco_app-0.12.7.pre.puma.pre.3 lib/disco_app/support/file_fixtures.rb
disco_app-0.14.0 lib/disco_app/support/file_fixtures.rb
disco_app-0.13.6.pre.puma.pre.3 lib/disco_app/support/file_fixtures.rb