Sha256: a06508e3d66de0363d2cb1eac95aac4d6a0716ce2775d160245bc0972a2d8ef4

Contents?: true

Size: 594 Bytes

Versions: 2

Compression:

Stored size: 594 Bytes

Contents

# encoding: UTF-8

def mock_request_for(response)
  url = Regexp.new("http://websro.correios.com.br/sro_bin/sroii_xml.eventos")
  WebMock::API.stub_request(:post, url).to_return(:status => 200, :body => body_for(response))
end

def body_for(response)
  case response
  when :success_response_one_object,
       :success_response_many_objects,
       :success_response_many_objects_international,
       :failure_response_not_found
    read_file_for(response)
  else
    response
  end
end

def read_file_for(filename)
  File.open("#{File.dirname(__FILE__)}/responses/#{filename}.xml").read
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
correios-sro-xml-0.1.1 spec/support/mock_request.rb
correios-sro-xml-0.1.0 spec/support/mock_request.rb