Class: ValidatesXmlOf::Matchers::ValidateXmlOf
- Inherits:
-
Object
- Object
- ValidatesXmlOf::Matchers::ValidateXmlOf
- Defined in:
- lib/validates_xml_of/matchers/validate_xml_of.rb
Instance Method Summary collapse
- #description ⇒ Object
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(attribute) ⇒ ValidateXmlOf
constructor
A new instance of ValidateXmlOf.
- #matches?(given_record) ⇒ Boolean
- #with_message(expected_message) ⇒ Object
- #with_schema(schema) ⇒ Object
Constructor Details
#initialize(attribute) ⇒ ValidateXmlOf
Returns a new instance of ValidateXmlOf.
6 7 8 |
# File 'lib/validates_xml_of/matchers/validate_xml_of.rb', line 6 def initialize(attribute) @attribute = attribute end |
Instance Method Details
#description ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/validates_xml_of/matchers/validate_xml_of.rb', line 25 def description description = "#{@attribute} contains a valid xml" if @schema description << " based on '#{@schema}'" end description end |
#failure_message ⇒ Object
41 42 43 |
# File 'lib/validates_xml_of/matchers/validate_xml_of.rb', line 41 def "Expected #{@attribute} to contains a valid xml, but it is #{attribute_output.inspect}" end |
#failure_message_when_negated ⇒ Object
45 46 47 |
# File 'lib/validates_xml_of/matchers/validate_xml_of.rb', line 45 def "Expected #{@attribute} to not contains a valid xml, but it is #{attribute_output.inspect}" end |
#matches?(given_record) ⇒ Boolean
10 11 12 13 14 15 16 |
# File 'lib/validates_xml_of/matchers/validate_xml_of.rb', line 10 def matches?(given_record) @given_record = given_record @expected_message ||= ValidatesXmlOf. valid_xml? && valid_xml_based_on_schema? end |
#with_message(expected_message) ⇒ Object
35 36 37 38 39 |
# File 'lib/validates_xml_of/matchers/validate_xml_of.rb', line 35 def () @expected_message = self end |
#with_schema(schema) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/validates_xml_of/matchers/validate_xml_of.rb', line 18 def with_schema(schema) @schema = schema @expected_message ||= ValidatesXmlOf. self end |