Class: TurboRspec::Capybara::Matchers::HaveStimulusController
- Inherits:
-
Object
- Object
- TurboRspec::Capybara::Matchers::HaveStimulusController
- Defined in:
- lib/turbo_rspec/capybara/matchers/have_stimulus_controller.rb
Overview
Capybara matcher asserting that an element with the given Stimulus controller is present on the page (+data-controller+ contains the name as a space-separated token).
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(page_or_node) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(controller_name) ⇒ HaveStimulusController
constructor
A new instance of HaveStimulusController.
- #matches?(page_or_node) ⇒ Boolean
Constructor Details
#initialize(controller_name) ⇒ HaveStimulusController
Returns a new instance of HaveStimulusController.
14 15 16 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_controller.rb', line 14 def initialize(controller_name) @controller_name = controller_name.to_s end |
Instance Method Details
#description ⇒ Object
34 35 36 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_controller.rb', line 34 def description "have Stimulus controller #{@controller_name.inspect}" end |
#does_not_match?(page_or_node) ⇒ Boolean
22 23 24 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_controller.rb', line 22 def does_not_match?(page_or_node) page_or_node.has_no_css?(selector, wait: 0) end |
#failure_message ⇒ Object
26 27 28 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_controller.rb', line 26 def "expected page to have Stimulus controller #{@controller_name.inspect}" end |
#failure_message_when_negated ⇒ Object
30 31 32 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_controller.rb', line 30 def "expected page not to have Stimulus controller #{@controller_name.inspect}" end |
#matches?(page_or_node) ⇒ Boolean
18 19 20 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_controller.rb', line 18 def matches?(page_or_node) page_or_node.has_css?(selector, wait: 0) end |