Class: StimulusSpec::Matchers::HaveStimulusController
- Inherits:
-
Object
- Object
- StimulusSpec::Matchers::HaveStimulusController
- Defined in:
- lib/stimulus_spec/matchers/have_stimulus_controller.rb
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(subject) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(name) ⇒ HaveStimulusController
constructor
A new instance of HaveStimulusController.
- #matches?(subject) ⇒ Boolean
Constructor Details
#initialize(name) ⇒ HaveStimulusController
Returns a new instance of HaveStimulusController.
6 7 8 |
# File 'lib/stimulus_spec/matchers/have_stimulus_controller.rb', line 6 def initialize(name) @name = name.to_s end |
Instance Method Details
#description ⇒ Object
27 28 29 |
# File 'lib/stimulus_spec/matchers/have_stimulus_controller.rb', line 27 def description "have Stimulus controller \"#{@name}\"" end |
#does_not_match?(subject) ⇒ Boolean
15 16 17 |
# File 'lib/stimulus_spec/matchers/have_stimulus_controller.rb', line 15 def does_not_match?(subject) !matches?(subject) end |
#failure_message ⇒ Object
19 20 21 |
# File 'lib/stimulus_spec/matchers/have_stimulus_controller.rb', line 19 def "expected to find an element with data-controller=\"#{@name}\" but found none in:\n#{@body}" end |
#failure_message_when_negated ⇒ Object
23 24 25 |
# File 'lib/stimulus_spec/matchers/have_stimulus_controller.rb', line 23 def "expected not to find an element with data-controller=\"#{@name}\" but found one" end |
#matches?(subject) ⇒ Boolean
10 11 12 13 |
# File 'lib/stimulus_spec/matchers/have_stimulus_controller.rb', line 10 def matches?(subject) @body = extract_body(subject) !document.at_css("[data-controller~='#{@name}']").nil? end |