Class: WebTrap::Shared::Validators::EquivalentXmlContentValidator Private

Inherits:
Object
  • Object
show all
Defined in:
lib/webtrap/shared/validators/equivalent_xml_content_validator.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.

Validator for asserting a request was sent with an equivalent XML payload.

See Also:

Instance Method Summary collapse

Constructor Details

#initialize(xml) ⇒ EquivalentXmlContentValidator

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.

Instantiate a new validator with the provided payload.

Parameters:

  • xml (String)

    The XML payload requests will be compared against.



15
16
17
18
# File 'lib/webtrap/shared/validators/equivalent_xml_content_validator.rb', line 15

def initialize(xml)
  @failed = true
  @xml = xml
end

Instance Method Details

#failed?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 no request with an equivalent payload was validated.

Returns:

  • (Boolean)


23
24
25
# File 'lib/webtrap/shared/validators/equivalent_xml_content_validator.rb', line 23

def failed?
  @failed
end

#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.

The message to be used if no request is validated with an equivalent payload.

Returns:

  • (String)


31
32
33
# File 'lib/webtrap/shared/validators/equivalent_xml_content_validator.rb', line 31

def failure_message
  "expected block to send an HTTP request with XML body, but payload was not equivalent"
end

#validate(request) ⇒ EquivalentXmlContentValidator

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.

Validate if the request has an equivalent XML payload.

Parameters:

  • request (Hash)

    Request environment passed by RackApp#call.

Returns:



41
42
43
44
# File 'lib/webtrap/shared/validators/equivalent_xml_content_validator.rb', line 41

def validate(request)
  @failed = EquivalentXml.equivalent?(xml, request["rack.input"].string)
  self
end