Class: StimulusSpec::Capybara::Matchers::HaveStimulusTarget
- Inherits:
-
Object
- Object
- StimulusSpec::Capybara::Matchers::HaveStimulusTarget
- Defined in:
- lib/stimulus_spec/capybara/matchers/have_stimulus_target.rb
Overview
Capybara matcher for +data-controller-target+ attributes.
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(page) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(controller, target) ⇒ HaveStimulusTarget
constructor
A new instance of HaveStimulusTarget.
- #matches?(page) ⇒ Boolean
- #within(selector) ⇒ self
Constructor Details
#initialize(controller, target) ⇒ HaveStimulusTarget
Returns a new instance of HaveStimulusTarget.
13 14 15 16 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_target.rb', line 13 def initialize(controller, target) @controller = controller.to_s @target = target.to_s end |
Instance Method Details
#description ⇒ Object
44 45 46 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_target.rb', line 44 def description "have Stimulus target \"#{@target}\" for controller \"#{@controller}\"" end |
#does_not_match?(page) ⇒ Boolean
32 33 34 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_target.rb', line 32 def does_not_match?(page) page.has_no_css?(scoped_selector, wait: 0) end |
#failure_message ⇒ Object
36 37 38 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_target.rb', line 36 def "expected to find an element with data-#{@controller}-target=\"#{@target}\" on the page" end |
#failure_message_when_negated ⇒ Object
40 41 42 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_target.rb', line 40 def "expected not to find an element with data-#{@controller}-target=\"#{@target}\" on the page" end |
#matches?(page) ⇒ Boolean
27 28 29 30 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_target.rb', line 27 def matches?(page) @page = page page.has_css?(scoped_selector, wait: 0) end |
#within(selector) ⇒ self
20 21 22 23 |
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_target.rb', line 20 def within(selector) @scope = selector self end |