Class: Webrat::Selenium::Matchers::HasContent
- Defined in:
- lib/webrat/selenium/matchers/have_content.rb
Overview
:nodoc:
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?(response) ⇒ 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.
5 6 7 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 5 def initialize(content) @content = content end |
Instance Method Details
#content_message ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 35 def case @content when String "include \"#{@content}\"" when Regexp "match #{@content.inspect}" end end |
#failure_message ⇒ Object
Returns
- String
-
The failure message.
25 26 27 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 25 def "expected the following element's content to #{}:\n#{@element}" end |
#matches?(response) ⇒ Boolean
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 9 def matches?(response) if @content.is_a?(Regexp) text_finder = "regexp:#{@content.source}" else text_finder = @content end response.session.wait_for do response.selenium.is_text_present(text_finder) end rescue Webrat::TimeoutError false end |
#negative_failure_message ⇒ Object
Returns
- String
-
The failure message to be displayed in negative matches.
31 32 33 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 31 def "expected the following element's content to not #{}:\n#{@element}" end |