Sha256: cd306410248d27bdf879be34b3c6055d39147a1719218f2bf2e5d4a58902a6df

Contents?: true

Size: 807 Bytes

Versions: 6

Compression:

Stored size: 807 Bytes

Contents

module TyphoeusMocks

  # Mocks a Typhoeus::Response
  # @param [Hash] options
  # @option [Integer] code - http response code. default: 200
  # @option [String] body - response body
  # @option [String] url - requested url
  # @return [Typhoeus::Response]
  def mock_response(options={})
    mock_response = Typhoeus::Response.new(
         :code => options[:code] || 200,
         :headers => "whatever",
         :time => 0.1,
         :body => options[:body])
    mock_response.stub!(:request).and_return(mock(:url => options[:url] || "mocked-url"))
    mock_response
  end

  # Mocks Typhoeus POST Request and returns a mocked_response
  # @param [Hash] options, see mock_response options.
  def mock_post_with(options={})
    Typhoeus::Request.stub!(:post).and_return(mock_response(options))
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logical_model-0.2.10 test/typhoeus_mocks.rb
logical_model-0.2.9 test/typhoeus_mocks.rb
logical_model-0.2.8 test/typhoeus_mocks.rb
logical_model-0.2.7 test/typhoeus_mocks.rb
logical_model-0.2.6 test/typhoeus_mocks.rb
logical_model-0.2.5 test/typhoeus_mocks.rb