Class: WebMock::StubRequestSnippet
- Inherits:
-
Object
- Object
- WebMock::StubRequestSnippet
- Defined in:
- lib/webmock/stub_request_snippet.rb
Instance Method Summary collapse
- #body_pattern ⇒ Object
-
#initialize(request_stub) ⇒ StubRequestSnippet
constructor
A new instance of StubRequestSnippet.
- #to_s(with_response = true) ⇒ Object
Constructor Details
#initialize(request_stub) ⇒ StubRequestSnippet
Returns a new instance of StubRequestSnippet.
3 4 5 |
# File 'lib/webmock/stub_request_snippet.rb', line 3 def initialize(request_stub) @request_stub = request_stub end |
Instance Method Details
#body_pattern ⇒ Object
7 8 9 |
# File 'lib/webmock/stub_request_snippet.rb', line 7 def body_pattern request_pattern.body_pattern end |
#to_s(with_response = true) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/webmock/stub_request_snippet.rb', line 11 def to_s(with_response = true) request_pattern = @request_stub.request_pattern string = "stub_request(:#{request_pattern.method_pattern.to_s}," string << " \"#{request_pattern.uri_pattern.to_s}\")" with = "" if (request_pattern.body_pattern) with << ":body => #{request_pattern.body_pattern.to_s}" end if (request_pattern.headers_pattern) with << ",\n " unless with.empty? with << ":headers => #{request_pattern.headers_pattern.to_s}" end string << ".\n with(#{with})" unless with.empty? if with_response string << ".\n to_return(:status => 200, :body => \"\", :headers => {})" end string end |