Class: WebTrap::RSpec::Matchers::SendRequest Private

Inherits:
Object
  • Object
show all
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

Constructor Details

#initializeSendRequest

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_messageString

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.

Returns:

  • (String)


62
63
64
65
# File 'lib/webtrap/rspec/matchers/send_request.rb', line 62

def failure_message
  return if failed_validator.nil?
  failed_validator.failure_message
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.

Parameters:

  • transmission_proc (Proc)

    The proc that is expected to send the requests.

Returns:

  • (Boolean)


52
53
54
55
# File 'lib/webtrap/rspec/matchers/send_request.rb', line 52

def matches?(transmission_proc)
  perform_transmission(transmission_proc)
  failure_message.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.

Returns:

  • (true)


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.

Parameters:

  • xml (String)

    The reference XML payload.

Returns:

  • (SendRequest)

    This matcher instance, to allow further chaining.

See Also:



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