Class: Merb::Test::Rspec::ViewMatchers::HaveSelector
- Defined in:
- lib/merb-core/test/matchers/view_matchers.rb
Instance Method Summary collapse
-
#failure_message ⇒ Object
Returns String:: The failure message.
-
#initialize(expected) ⇒ HaveSelector
constructor
Parameters expected<String>:: The string to look for.
-
#matches?(stringlike) ⇒ Boolean
Parameters stringlike<Hpricot::Elem, StringIO, String>:: The thing to search in.
-
#negative_failure_message ⇒ Object
Returns String:: The failure message to be displayed in negative matches.
Constructor Details
#initialize(expected) ⇒ HaveSelector
Parameters
- expected<String>
-
The string to look for.
6 7 8 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 6 def initialize(expected) @expected = expected end |
Instance Method Details
#failure_message ⇒ Object
Returns
- String
-
The failure message.
29 30 31 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 29 def "expected following text to match selector #{@expected}:\n#{@document}" end |
#matches?(stringlike) ⇒ Boolean
Parameters
- stringlike<Hpricot::Elem, StringIO, String>
-
The thing to search in.
Returns
- Boolean
-
True if there was at least one match.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 15 def matches?(stringlike) @document = case stringlike when Hpricot::Elem stringlike when StringIO Hpricot.parse(stringlike.string) else Hpricot.parse(stringlike) end !@document.search(@expected).empty? end |
#negative_failure_message ⇒ Object
Returns
- String
-
The failure message to be displayed in negative matches.
35 36 37 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 35 def "expected following text to not match selector #{@expected}:\n#{@document}" end |