Class: TurboRspec::Capybara::Matchers::HaveStimulusAction
- Inherits:
-
Object
- Object
- TurboRspec::Capybara::Matchers::HaveStimulusAction
- Defined in:
- lib/turbo_rspec/capybara/matchers/have_stimulus_action.rb
Overview
Capybara matcher asserting that an element with the given Stimulus action descriptor is present on the page (+data-action+ contains the descriptor as a space-separated token).
Accepts either a full descriptor (+click->hello#greet+) or a shorthand without an event (+hello#greet+), which matches any event prefix.
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(page_or_node) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(action_descriptor) ⇒ HaveStimulusAction
constructor
A new instance of HaveStimulusAction.
- #matches?(page_or_node) ⇒ Boolean
Constructor Details
#initialize(action_descriptor) ⇒ HaveStimulusAction
Returns a new instance of HaveStimulusAction.
19 20 21 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_action.rb', line 19 def initialize(action_descriptor) @action_descriptor = action_descriptor.to_s end |
Instance Method Details
#description ⇒ Object
39 40 41 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_action.rb', line 39 def description "have Stimulus action #{@action_descriptor.inspect}" end |
#does_not_match?(page_or_node) ⇒ Boolean
27 28 29 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_action.rb', line 27 def does_not_match?(page_or_node) page_or_node.has_no_css?(selector, wait: 0) end |
#failure_message ⇒ Object
31 32 33 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_action.rb', line 31 def "expected page to have Stimulus action #{@action_descriptor.inspect}" end |
#failure_message_when_negated ⇒ Object
35 36 37 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_action.rb', line 35 def "expected page not to have Stimulus action #{@action_descriptor.inspect}" end |
#matches?(page_or_node) ⇒ Boolean
23 24 25 |
# File 'lib/turbo_rspec/capybara/matchers/have_stimulus_action.rb', line 23 def matches?(page_or_node) page_or_node.has_css?(selector, wait: 0) end |