Class: Webrat::Selenium::Matchers::HaveSelector
- Defined in:
- lib/webrat/selenium/matchers/have_selector.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#failure_message ⇒ Object
Returns String:: The failure message.
-
#initialize(expected, options = {}, &block) ⇒ HaveSelector
constructor
A new instance of HaveSelector.
- #matches?(response) ⇒ Boolean
-
#negative_failure_message ⇒ Object
Returns String:: The failure message to be displayed in negative matches.
- #selector ⇒ Object
Constructor Details
#initialize(expected, options = {}, &block) ⇒ HaveSelector
Returns a new instance of HaveSelector.
5 6 7 8 9 10 |
# File 'lib/webrat/selenium/matchers/have_selector.rb', line 5 def initialize(expected, = {}, &block) @expected = expected @options = @block = block @content = @options.delete(:content)||@options.delete(:text) end |
Instance Method Details
#failure_message ⇒ Object
Returns
- String
-
The failure message.
37 38 39 |
# File 'lib/webrat/selenium/matchers/have_selector.rb', line 37 def "expected following text to match selector #{@expected}:\n#{@document}" end |
#matches?(response) ⇒ Boolean
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/webrat/selenium/matchers/have_selector.rb', line 12 def matches?(response) response.session.wait_for do # if @content # @element=response.selenium.get_text("css=#{@expected}") # case @content # when String # @element.include?(@content) # when Regexp # @element.match(@content) # end # # else response.selenium.is_element_present(selector) # end end rescue Webrat::TimeoutError false end |
#negative_failure_message ⇒ Object
Returns
- String
-
The failure message to be displayed in negative matches.
43 44 45 |
# File 'lib/webrat/selenium/matchers/have_selector.rb', line 43 def "expected following text to not match selector #{@expected}:\n#{@document}" end |
#selector ⇒ Object
31 32 33 |
# File 'lib/webrat/selenium/matchers/have_selector.rb', line 31 def selector "css=#{@expected}" + ((@content && ":contains('#{@content}')") || '') end |