Class: RSpecXML::XMLMatchers::HaveXPath::TextMatcher
- Inherits:
-
Object
- Object
- RSpecXML::XMLMatchers::HaveXPath::TextMatcher
- Defined in:
- lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb
Instance Method Summary collapse
- #failure_message_for_should ⇒ Object
- #failure_message_for_should_not ⇒ Object
-
#initialize(options = {}) ⇒ TextMatcher
constructor
A new instance of TextMatcher.
- #matches?(xml) ⇒ Boolean
Constructor Details
#initialize(options = {}) ⇒ TextMatcher
Returns a new instance of TextMatcher.
9 10 11 12 |
# File 'lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb', line 9 def initialize(={}) self.xpath = [:xpath] self.text = [:text] end |
Instance Method Details
#failure_message_for_should ⇒ Object
18 19 20 |
# File 'lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb', line 18 def "expected #{xpath} to contain #{text}" end |
#failure_message_for_should_not ⇒ Object
22 23 24 |
# File 'lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb', line 22 def "expected #{xpath} to not exist with text: #{text}" end |
#matches?(xml) ⇒ Boolean
14 15 16 |
# File 'lib/rspec-xml/xml_matchers/have_xpath/text_matcher.rb', line 14 def matches?(xml) ::Nokogiri::XML(xml).xpath(xpath).text == text end |