Class: Merb::Test::Rspec::ViewMatchers::HasContent
- Defined in:
- lib/merb-core/test/matchers/view_matchers.rb
Instance Method Summary collapse
- #content_message ⇒ Object
-
#failure_message ⇒ Object
Returns String:: The failure message.
-
#initialize(content) ⇒ HasContent
constructor
A new instance of HasContent.
- #matches?(element) ⇒ Boolean
-
#negative_failure_message ⇒ Object
Returns String:: The failure message to be displayed in negative matches.
Constructor Details
#initialize(content) ⇒ HasContent
Returns a new instance of HasContent.
282 283 284 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 282 def initialize(content) @content = content end |
Instance Method Details
#content_message ⇒ Object
309 310 311 312 313 314 315 316 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 309 def case @content when String "include \"#{@content}\"" when Regexp "match #{@content.inspect}" end end |
#failure_message ⇒ Object
Returns
- String
-
The failure message.
299 300 301 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 299 def "expected the following element's content to #{content_message}:\n#{@element.inner_text}" end |
#matches?(element) ⇒ Boolean
286 287 288 289 290 291 292 293 294 295 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 286 def matches?(element) @element = element case @content when String @element.contains?(@content) when Regexp @element.matches?(@content) end end |
#negative_failure_message ⇒ Object
Returns
- String
-
The failure message to be displayed in negative matches.
305 306 307 |
# File 'lib/merb-core/test/matchers/view_matchers.rb', line 305 def "expected the following element's content to not #{content_message}:\n#{@element.inner_text}" end |