# File lib/webmock/request_stub.rb, line 79 def self.from_request_signature(signature) stub = self.new(signature.method.to_sym, signature.uri.to_s) if signature.body.to_s != '' body = if signature.url_encoded? Addressable::URI.parse('?' + signature.body).query_values else signature.body end stub.with(:body => body) end if (signature.headers && !signature.headers.empty?) stub.with(:headers => signature.headers) end stub end
# File lib/webmock/request_stub.rb, line 53 def has_responses? !@responses_sequences.empty? end
# File lib/webmock/request_stub.rb, line 71 def matches?(request_signature) self.request_pattern.matches?(request_signature) end
# File lib/webmock/request_stub.rb, line 42 def response if @responses_sequences.empty? WebMock::Response.new elsif @responses_sequences.length > 1 @responses_sequences.shift if @responses_sequences.first.end? @responses_sequences.first.next_response else @responses_sequences[0].next_response end end
# File lib/webmock/request_stub.rb, line 61 def times(number) raise "times(N) accepts integers >= 1 only" if !number.is_a?(Fixnum) || number < 1 if @responses_sequences.empty? raise "Invalid WebMock stub declaration." + " times(N) can be declared only after response declaration." end @responses_sequences.last.times_to_repeat += number-1 self end
# File lib/webmock/request_stub.rb, line 26 def to_rack(app, options={}) @responses_sequences << ResponsesSequence.new([RackResponse.new(app)]) end
# File lib/webmock/request_stub.rb, line 30 def to_raise(*exceptions) @responses_sequences << ResponsesSequence.new([*exceptions].flatten.map {|e| ResponseFactory.response_for(:exception => e) }) self end
# File lib/webmock/request_stub.rb, line 17 def to_return(*response_hashes, &block) if block @responses_sequences << ResponsesSequence.new([ResponseFactory.response_for(block)]) else @responses_sequences << ResponsesSequence.new([*response_hashes].flatten.map {|r| ResponseFactory.response_for(r)}) end self end
# File lib/webmock/request_stub.rb, line 75 def to_s self.request_pattern.to_s end
Generated with the Darkfish Rdoc Generator 2.