Class: Webrat::Selenium::Matchers::HasContent
- Defined in:
- lib/webrat/selenium/matchers/have_content.rb
Overview
:nodoc:
Instance Method Summary collapse
- #content_message ⇒ Object
- #does_not_match?(response) ⇒ Boolean
-
#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.
- #text_finder ⇒ Object
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
39 40 41 42 43 44 45 46 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 39 def case @content when String "include \"#{@content}\"" when Regexp "match #{@content.inspect}" end end |
#does_not_match?(response) ⇒ Boolean
18 19 20 21 22 23 24 25 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 18 def does_not_match?(response) response.session.wait_for do !response.selenium.is_text_present(text_finder) end rescue Webrat::TimeoutError => e @error_message = e. false end |
#failure_message ⇒ Object
Returns
- String
-
The failure message.
29 30 31 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 29 def "expected the response to #{}:\n#{@error_message}" end |
#matches?(response) ⇒ Boolean
9 10 11 12 13 14 15 16 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 9 def matches?(response) response.session.wait_for do response.selenium.is_text_present(text_finder) end rescue Webrat::TimeoutError => e @error_message = e. false end |
#negative_failure_message ⇒ Object
Returns
- String
-
The failure message to be displayed in negative matches.
35 36 37 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 35 def "expected the response to not #{}" end |
#text_finder ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/webrat/selenium/matchers/have_content.rb', line 48 def text_finder if @content.is_a?(Regexp) "regexp:#{@content.source}" else @content end end |