Class: WebTrap::RSpec::Matchers::SendRequestWithXml Private

Inherits:
SendRequest
  • Object
show all
Defined in:
lib/webtrap/rspec/matchers/send_request_with_xml.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.

Used to specify the XML payload of the request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from SendRequest

#with_xml

Constructor Details

#initialize(expected_payload) ⇒ SendRequestWithXml

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 parameterization of the matcher with the reference payload.

Parameters:

  • expected_payload

    Reference to be compared with the payload of outgoing XML requests.



18
19
20
# File 'lib/webtrap/rspec/matchers/send_request_with_xml.rb', line 18

def initialize(expected_payload)
  @expected_payload = expected_payload
end

Instance Attribute Details

#expected_payloadObject (readonly)

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.

Reference to be compared with the payload of outgoing XML requests.



13
14
15
# File 'lib/webtrap/rspec/matchers/send_request_with_xml.rb', line 13

def expected_payload
  @expected_payload
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 the expectation fails to pass.

Returns:

  • (String)

See Also:

  • WebTrap::RSpec::Matchers::SendRequestWithXml.{RSpec{RSpec::Matchers{RSpec::Matchers::MatcherProtocol{RSpec::Matchers::MatcherProtocol#failure_message}


39
40
41
42
43
# File 'lib/webtrap/rspec/matchers/send_request_with_xml.rb', line 39

def failure_message
  return super unless request_sent?

  "expected block to send an HTTP request with XML body, but payload was not equivalent"
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.

Checks if the provided Proc sends a request with an XML payload equivalent to the expected reference.

Parameters:

  • transmission_proc (Proc)

    The proc that should send a valid request.

Returns:

  • (Boolean)

    Whether a request was sent with an equivalent XML payload.

See Also:

  • WebTrap::RSpec::Matchers::SendRequestWithXml.{RSpec{RSpec::Matchers{RSpec::Matchers::MatcherProtocol{RSpec::Matchers::MatcherProtocol#matches?}


30
31
32
33
# File 'lib/webtrap/rspec/matchers/send_request_with_xml.rb', line 30

def matches?(transmission_proc)
  perform_transmission(transmission_proc)
  request_sent? && valid_payload?
end

#supports_block_expectations?TrueClass

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:

  • (TrueClass)

See Also:

  • WebTrap::RSpec::Matchers::SendRequestWithXml.{RSpec{RSpec::Matchers{RSpec::Matchers::MatcherProtocol{RSpec::Matchers::MatcherProtocol#supports_block_expectations?}


49
50
51
# File 'lib/webtrap/rspec/matchers/send_request_with_xml.rb', line 49

def supports_block_expectations?
  true
end