Parent

Files

WebMock::RequestStub

Attributes

request_pattern[RW]

Public Class Methods

new(method, uri) click to toggle source
    # File lib/webmock/request_stub.rb, line 6
 6:     def initialize(method, uri)
 7:       @request_pattern = RequestPattern.new(method, uri)
 8:       @responses_sequences = []
 9:       self
10:     end

Public Instance Methods

response() click to toggle source
    # File lib/webmock/request_stub.rb, line 38
38:     def response
39:       if @responses_sequences.empty?
40:         WebMock::Response.new
41:       elsif @responses_sequences.length > 1
42:         @responses_sequences.shift if @responses_sequences.first.end?
43:         @responses_sequences.first.next_response
44:       else
45:         @responses_sequences[0].next_response
46:       end
47:     end
then() click to toggle source
    # File lib/webmock/request_stub.rb, line 49
49:     def then
50:       self
51:     end
times(number) click to toggle source
    # File lib/webmock/request_stub.rb, line 53
53:     def times(number)
54:       raise "times(N) accepts integers >= 1 only" if !number.is_a?(Fixnum) || number < 1
55:       if @responses_sequences.empty?
56:         raise "Invalid WebMock stub declaration." +
57:           " times(N) can be declared only after response declaration."
58:       end
59:       @responses_sequences.last.times_to_repeat += number-1
60:       self
61:     end
to_raise(*exceptions) click to toggle source
    # File lib/webmock/request_stub.rb, line 26
26:     def to_raise(*exceptions)
27:       @responses_sequences << ResponsesSequence.new([*exceptions].flatten.map {|e| 
28:         ResponseFactory.response_for(:exception => e)
29:       })
30:       self
31:     end
to_return(*response_hashes, &block) click to toggle source
    # File lib/webmock/request_stub.rb, line 17
17:     def to_return(*response_hashes, &block)
18:       if block
19:         @responses_sequences << ResponsesSequence.new([ResponseFactory.response_for(block)])
20:       else
21:         @responses_sequences << ResponsesSequence.new([*response_hashes].flatten.map {|r| ResponseFactory.response_for(r)})
22:       end
23:       self
24:     end
to_timeout() click to toggle source
    # File lib/webmock/request_stub.rb, line 33
33:     def to_timeout
34:       @responses_sequences << ResponsesSequence.new([ResponseFactory.response_for(:should_timeout => true)])
35:       self
36:     end
with(params = {}, &block) click to toggle source
    # File lib/webmock/request_stub.rb, line 12
12:     def with(params = {}, &block)
13:       @request_pattern.with(params, &block)
14:       self
15:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.