Class: StimulusSpec::Capybara::Matchers::HaveStimulusAction

Inherits:
Object
  • Object
show all
Defined in:
lib/stimulus_spec/capybara/matchers/have_stimulus_action.rb

Instance Method Summary collapse

Constructor Details

#initialize(descriptor) ⇒ HaveStimulusAction

Returns a new instance of HaveStimulusAction.



7
8
9
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_action.rb', line 7

def initialize(descriptor)
  @descriptor = descriptor.to_s
end

Instance Method Details

#descriptionObject



33
34
35
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_action.rb', line 33

def description
  "have Stimulus action \"#{@descriptor}\""
end

#does_not_match?(page) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_action.rb', line 21

def does_not_match?(page)
  page.has_no_css?(scoped_selector, wait: 0)
end

#failure_messageObject



25
26
27
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_action.rb', line 25

def failure_message
  "expected to find an element with data-action=\"#{@descriptor}\" on the page"
end

#failure_message_when_negatedObject



29
30
31
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_action.rb', line 29

def failure_message_when_negated
  "expected not to find an element with data-action=\"#{@descriptor}\" on the page"
end

#matches?(page) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/stimulus_spec/capybara/matchers/have_stimulus_action.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_action.rb', line 11

def within(selector)
  @scope = selector
  self
end