Class: StimulusSpec::Capybara::Matchers::HaveStimulusController
- Inherits:
-
Object
- Object
- StimulusSpec::Capybara::Matchers::HaveStimulusController
- Defined in:
- lib/stimulus_spec/capybara/matchers/have_stimulus_controller.rb
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(page) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(*names) ⇒ HaveStimulusController
constructor
A new instance of HaveStimulusController.
- #matches?(page) ⇒ Boolean
- #within(selector) ⇒ Object
Constructor Details
#initialize(*names) ⇒ HaveStimulusController
Returns a new instance of HaveStimulusController.
7 8 9 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_controller.rb', line 7 def initialize(*names) @names = names.map(&:to_s) end |
Instance Method Details
#description ⇒ Object
33 34 35 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_controller.rb', line 33 def description "have Stimulus controller #{label}" end |
#does_not_match?(page) ⇒ Boolean
21 22 23 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_controller.rb', line 21 def does_not_match?(page) page.has_no_css?(scoped_selector, wait: 0) end |
#failure_message ⇒ Object
25 26 27 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_controller.rb', line 25 def "expected to find an element with data-controller=#{label} on the page" end |
#failure_message_when_negated ⇒ Object
29 30 31 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_controller.rb', line 29 def "expected not to find an element with data-controller=#{label} on the page" end |
#matches?(page) ⇒ Boolean
16 17 18 19 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_controller.rb', line 16 def matches?(page) @page = page page.has_css?(scoped_selector, wait: 0) end |
#within(selector) ⇒ Object
11 12 13 14 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_controller.rb', line 11 def within(selector) @scope = selector self end |