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.
10 11 12 13 |
# File 'lib/webmock/request_signature_snippet.rb', line 10 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.
8 9 10 |
# File 'lib/webmock/request_signature_snippet.rb', line 8 def request_signature @request_signature end |
#request_stub ⇒ Object (readonly)
Returns the value of attribute request_stub.
8 9 10 |
# File 'lib/webmock/request_signature_snippet.rb', line 8 def request_stub @request_stub end |
Instance Method Details
#request_stubs ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/webmock/request_signature_snippet.rb', line 22 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
15 16 17 18 19 20 |
# File 'lib/webmock/request_signature_snippet.rb', line 15 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 |