Class: Rails::Dom::Testing::Assertions::SelectorAssertions::HTMLSelector
- Inherits:
-
Object
- Object
- Rails::Dom::Testing::Assertions::SelectorAssertions::HTMLSelector
- Includes:
- Minitest::Assertions
- Defined in:
- lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#css_selector ⇒ Object
readonly
Returns the value of attribute css_selector.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#tests ⇒ Object
readonly
Returns the value of attribute tests.
Instance Method Summary collapse
-
#initialize(values, previous_selection = nil, refute: false, &root_fallback) ⇒ HTMLSelector
constructor
A new instance of HTMLSelector.
- #select ⇒ Object
-
#selecting_no_body? ⇒ Boolean
:nodoc:.
Constructor Details
#initialize(values, previous_selection = nil, refute: false, &root_fallback) ⇒ HTMLSelector
Returns a new instance of HTMLSelector.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb', line 17 def initialize(values, previous_selection = nil, refute: false, &root_fallback) @values = values @root = extract_root(previous_selection, root_fallback) extract_selectors @tests = extract_equality_tests(refute) @message = @values.shift if @message.is_a?(Hash) raise ArgumentError, "Last argument was a Hash, which would be used for the assertion message. You probably want this to be a String, or you have the wrong type of arguments." end if @values.shift raise ArgumentError, "Not expecting that last argument, you either have too many arguments, or they're the wrong type" end end |
Instance Attribute Details
#css_selector ⇒ Object (readonly)
Returns the value of attribute css_selector.
13 14 15 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb', line 13 def css_selector @css_selector end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
13 14 15 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb', line 13 def @message end |
#tests ⇒ Object (readonly)
Returns the value of attribute tests.
13 14 15 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb', line 13 def tests @tests end |
Instance Method Details
#select ⇒ Object
39 40 41 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb', line 39 def select filter @root.css(@selector, context) end |
#selecting_no_body? ⇒ Boolean
:nodoc:
33 34 35 36 37 |
# File 'lib/rails/dom/testing/assertions/selector_assertions/html_selector.rb', line 33 def selecting_no_body? # :nodoc: # Nokogiri gives the document a body element. Which means we can't # run an assertion expecting there to not be a body. @selector == "body" && @tests[:count] == 0 end |