Class: Webrat::Matchers::HaveSelector
- Defined in:
- lib/webrat/core/matchers/have_selector.rb
Overview
:nodoc:
Instance Method Summary collapse
-
#description ⇒ Object
Returns String:: The default description for the spec when it is not provided.
-
#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 HaveXpath
#add_attributes_conditions_to, #add_content_condition_to, #add_options_conditions_to, #initialize, #matches, #matches?, #nokogiri_matches
Constructor Details
This class inherits a constructor from Webrat::Matchers::HaveXpath
Instance Method Details
#description ⇒ Object
Returns
- String
-
The default description for the spec when it is not provided.
10 11 12 13 14 15 16 |
# File 'lib/webrat/core/matchers/have_selector.rb', line 10 def description "have selector #{@expected.inspect}" + if @options && @options.any? " with #{@options.inspect}" else '' end end |
#failure_message ⇒ Object
Returns
- String
-
The failure message.
20 21 22 |
# File 'lib/webrat/core/matchers/have_selector.rb', line 20 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.
26 27 28 |
# File 'lib/webrat/core/matchers/have_selector.rb', line 26 def "expected following output to omit a #{tag_inspect}:\n#{@document}" end |
#query ⇒ Object
49 50 51 52 53 |
# File 'lib/webrat/core/matchers/have_selector.rb', line 49 def query Nokogiri::CSS.parse(@expected.to_s).map do |ast| ast.to_xpath end.first end |
#tag_inspect ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/webrat/core/matchers/have_selector.rb', line 30 def tag_inspect = @options.dup count = .delete(:count) content = .delete(:content) html = "<#{@expected}" .each do |k,v| html << " #{k}='#{v}'" end if content html << ">#{content}</#{@expected}>" else html << "/>" end html end |