Class: Webrat::Selenium::Matchers::HaveTag
- Inherits:
-
HaveSelector
- Object
- HaveSelector
- Webrat::Selenium::Matchers::HaveTag
- Defined in:
- lib/webrat/selenium/matchers/have_tag.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#failure_message ⇒ Object
Returns String:: The failure message.
-
#negative_failure_message ⇒ Object
Returns String:: The failure message to be displayed in negative matches.
- #query ⇒ Object
- #tag_inspect ⇒ Object
Methods inherited from HaveSelector
Constructor Details
This class inherits a constructor from Webrat::Selenium::Matchers::HaveSelector
Instance Method Details
#failure_message ⇒ Object
Returns
- String
-
The failure message.
8 9 10 |
# File 'lib/webrat/selenium/matchers/have_tag.rb', line 8 def "expected following output to contain a #{tag_inspect} tag:\n#{@document}" end |
#negative_failure_message ⇒ Object
Returns
- String
-
The failure message to be displayed in negative matches.
14 15 16 |
# File 'lib/webrat/selenium/matchers/have_tag.rb', line 14 def "expected following output to omit a #{tag_inspect}:\n#{@document}" end |
#query ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/webrat/selenium/matchers/have_tag.rb', line 36 def query = @expected.last.dup selector = @expected.first.to_s selector << ":contains('#{.delete(:content)}')" if [:content] .each do |key, value| selector << "[#{key}='#{value}']" end Nokogiri::CSS.parse(selector).map { |ast| ast.to_xpath } end |
#tag_inspect ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/webrat/selenium/matchers/have_tag.rb', line 18 def tag_inspect = @expected.last.dup content = .delete(:content) html = "<#{@expected.first}" .each do |k,v| html << " #{k}='#{v}'" end if content html << ">#{content}</#{@expected.first}>" else html << "/>" end html end |