Sha256: b76b873aff71069530af0b068f0b44e4722fcf89f322780173e69711656189c6

Contents?: true

Size: 793 Bytes

Versions: 12

Compression:

Stored size: 793 Bytes

Contents

class Fixture

  TYPES = { :gzip => "gz", :response => "xml", :wsdl => "xml" }

  class << self

    def [](type, fixture)
      fixtures(type)[fixture] ||= read_file type, fixture
    end

    def response_hash(fixture)
      @response_hash ||= {}
      @response_hash[fixture] ||= Savon::SOAP::XML.to_hash response(fixture)
    end

    TYPES.each do |type, ext|
      define_method type do |fixture|
        self[type, fixture]
      end
    end

  private

    def fixtures(type)
      @fixtures ||= {}
      @fixtures[type] ||= {}
    end

    def read_file(type, fixture)
      path = File.expand_path "../../fixtures/#{type}/#{fixture}.#{TYPES[type]}", __FILE__
      raise ArgumentError, "Unable to load: #{path}" unless File.exist? path
      
      File.read path
    end

  end
end

Version data entries

12 entries across 12 versions & 3 rubygems

Version Path
search_biomodel-1.0.0 search_biomodel/ruby/1.8/gems/savon-0.9.2/spec/support/fixture.rb
savon-0.9.2 spec/support/fixture.rb
s-savon-0.8.6 spec/support/fixture.rb
savon-0.9.1 spec/support/fixture.rb
savon-0.9.0 spec/support/fixture.rb
savon-0.8.6 spec/support/fixture.rb
savon-0.8.5 spec/support/fixture.rb
savon-0.8.4 spec/support/fixture.rb
savon-0.8.3 spec/support/fixture.rb
savon-0.8.2 spec/support/fixture.rb
savon-0.8.1 spec/support/fixture.rb
savon-0.8.0 spec/support/fixture.rb