Object
# File lib/typhoeus/hydra_mock.rb, line 5 def initialize(url, method, options = {}) @url = url @uri = URI.parse(url) if url.kind_of?(String) @method = method @requests = [] @options = options if @options[:headers] @options[:headers] = Typhoeus::NormalizedHeaderHash.new(@options[:headers]) end @current_response_index = 0 end
# File lib/typhoeus/hydra_mock.rb, line 34 def add_request(request) @requests << request end
# File lib/typhoeus/hydra_mock.rb, line 38 def and_return(val) if val.respond_to?(:each) @responses = val else @responses = [val] end # make sure to mark them as a mock. @responses.each { |r| r.mock = true } val end
# File lib/typhoeus/hydra_mock.rb, line 18 def body @options[:body] end
# File lib/typhoeus/hydra_mock.rb, line 22 def body? @options.has_key?(:body) end
# File lib/typhoeus/hydra_mock.rb, line 26 def headers @options[:headers] end
# File lib/typhoeus/hydra_mock.rb, line 30 def headers? @options.has_key?(:headers) end
# File lib/typhoeus/hydra_mock.rb, line 61 def matches?(request) if !method_matches?(request) or !url_matches?(request) return false end if body? return false unless body_matches?(request) end if headers? return false unless headers_match?(request) end true end
Generated with the Darkfish Rdoc Generator 2.