Class: WebTrap::RSpec::Matchers::SendRequest Private
- Inherits:
-
Object
- Object
- WebTrap::RSpec::Matchers::SendRequest
- Defined in:
- lib/webtrap/rspec/matchers/send_request.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Provides the implementation for send_request.
Not intended to be instantiated directly.
Instance Method Summary collapse
-
#failure_message ⇒ String
private
Message to be shown if no request is intercepted for which all validators are successful.
-
#initialize ⇒ SendRequest
constructor
private
Initialize a new matcher.
-
#matches?(transmission_proc) ⇒ Boolean
private
Whether a request was intercepted that matches all validators.
-
#supports_block_expectations? ⇒ true
private
Allows the matcher to be used with block expectations.
-
#with_xml(xml) ⇒ SendRequest
Specifies the XML payload of the request.
Constructor Details
#initialize ⇒ SendRequest
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new matcher.
Unless more constraints are chained, this matcher will pass as long as any HTTP request gets intercepted.
23 24 25 |
# File 'lib/webtrap/rspec/matchers/send_request.rb', line 23 def initialize add_validator(Shared::Validators::RequestSentValidator.new) end |
Instance Method Details
#failure_message ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Message to be shown if no request is intercepted for which all validators are successful.
62 63 64 65 |
# File 'lib/webtrap/rspec/matchers/send_request.rb', line 62 def return if failed_validator.nil? failed_validator. end |
#matches?(transmission_proc) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether a request was intercepted that matches all validators.
Executes the provided proc, intercepting all transmitted HTTP requests and running them through the set of validators.
52 53 54 55 |
# File 'lib/webtrap/rspec/matchers/send_request.rb', line 52 def matches?(transmission_proc) perform_transmission(transmission_proc) .nil? end |
#supports_block_expectations? ⇒ true
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Allows the matcher to be used with block expectations.
71 72 73 |
# File 'lib/webtrap/rspec/matchers/send_request.rb', line 71 def supports_block_expectations? true end |
#with_xml(xml) ⇒ SendRequest
Specifies the XML payload of the request.
The expectation will pass only if a request is sent with a payload that is considered equivalent to the reference.
38 39 40 41 |
# File 'lib/webtrap/rspec/matchers/send_request.rb', line 38 def with_xml(xml) add_validator(Shared::Validators::EquivalentXmlContentValidator.new(xml)) self end |