Class: WebMock::RequestSignatureSnippet
- Inherits:
-
Object
- Object
- WebMock::RequestSignatureSnippet
- Defined in:
- lib/webmock/request_signature_snippet.rb
Instance Attribute Summary collapse
-
#request_signature ⇒ Object
readonly
Returns the value of attribute request_signature.
-
#request_stub ⇒ Object
readonly
Returns the value of attribute request_stub.
Instance Method Summary collapse
-
#initialize(request_signature) ⇒ RequestSignatureSnippet
constructor
A new instance of RequestSignatureSnippet.
- #request_stubs ⇒ Object
- #stubbing_instructions ⇒ Object
Constructor Details
#initialize(request_signature) ⇒ RequestSignatureSnippet
Returns a new instance of RequestSignatureSnippet.
8 9 10 11 |
# File 'lib/webmock/request_signature_snippet.rb', line 8 def initialize(request_signature) @request_signature = request_signature @request_stub = RequestStub.from_request_signature(request_signature) end |
Instance Attribute Details
#request_signature ⇒ Object (readonly)
Returns the value of attribute request_signature.
6 7 8 |
# File 'lib/webmock/request_signature_snippet.rb', line 6 def request_signature @request_signature end |
#request_stub ⇒ Object (readonly)
Returns the value of attribute request_stub.
6 7 8 |
# File 'lib/webmock/request_signature_snippet.rb', line 6 def request_stub @request_stub end |
Instance Method Details
#request_stubs ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/webmock/request_signature_snippet.rb', line 20 def request_stubs return if WebMock::StubRegistry.instance.request_stubs.empty? text = "registered request stubs:\n".dup WebMock::StubRegistry.instance.request_stubs.each do |stub| text << "\n#{WebMock::StubRequestSnippet.new(stub).to_s(false)}" add_body_diff(stub, text) if WebMock.show_body_diff? end text end |
#stubbing_instructions ⇒ Object
13 14 15 16 17 18 |
# File 'lib/webmock/request_signature_snippet.rb', line 13 def stubbing_instructions return unless WebMock.show_stubbing_instructions? "You can stub this request with the following snippet:\n\n" + WebMock::StubRequestSnippet.new(request_stub).to_s end |