Class: Merb::Test::Rspec::ViewMatchers::HaveXpath
- Defined in:
- lib/merb-core/test/matchers/view_matchers.rb
Instance Method Summary collapse
-
#failure_message ⇒ Object
Returns String:: The failure message.
-
#initialize(expected) ⇒ HaveXpath
constructor
A new instance of HaveXpath.
- #matches?(stringlike) ⇒ Boolean
-
#negative_failure_message ⇒ Object
Returns String:: The failure message to be displayed in negative matches.
Constructor Details
#initialize(expected) ⇒ HaveXpath
Returns a new instance of HaveXpath.
3 4 5 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 3 def initialize(expected) @expected = expected end |
Instance Method Details
#failure_message ⇒ Object
Returns
- String
-
The failure message.
21 22 23 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 21 def "expected following text to match xpath #{@expected}:\n#{@document}" end |
#matches?(stringlike) ⇒ Boolean
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 7 def matches?(stringlike) @document = case stringlike when LibXML::XML::Document, LibXML::XML::Node stringlike when StringIO LibXML::XML::HTMLParser.string(stringlike.string).parse else LibXML::XML::HTMLParser.string(stringlike).parse end !@document.find(@expected).empty? end |
#negative_failure_message ⇒ Object
Returns
- String
-
The failure message to be displayed in negative matches.
27 28 29 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 27 def "expected following text to not match xpath #{@expected}:\n#{@document}" end |