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.
52 53 54 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 52 def initialize(expected) @expected = expected end |
Instance Method Details
#failure_message ⇒ Object
Returns
- String
-
The failure message.
75 76 77 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 75 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.
61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 61 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.
81 82 83 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 81 def "expected following text to not match selector #{@expected}:\n#{@document}" end |