Class: TurboRspec::Capybara::Matchers::HaveTurboStreamTag

Inherits:
Object
  • Object
show all
Defined in:
lib/turbo_rspec/capybara/matchers/have_turbo_stream_tag.rb

Instance Method Summary collapse

Constructor Details

#initialize(signed_stream_name: nil) ⇒ HaveTurboStreamTag

Returns a new instance of HaveTurboStreamTag.



7
8
9
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_stream_tag.rb', line 7

def initialize(signed_stream_name: nil)
  @signed_stream_name = signed_stream_name
end

Instance Method Details

#descriptionObject



29
30
31
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_stream_tag.rb', line 29

def description
  "have turbo-stream-source#{stream_description}"
end

#does_not_match?(page_or_node) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_stream_tag.rb', line 16

def does_not_match?(page_or_node)
  selector = build_selector
  page_or_node.has_no_css?(selector, wait: 0)
end

#failure_messageObject



21
22
23
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_stream_tag.rb', line 21

def failure_message
  "expected page to have a turbo-stream-source element#{stream_description}"
end

#failure_message_when_negatedObject



25
26
27
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_stream_tag.rb', line 25

def failure_message_when_negated
  "expected page not to have a turbo-stream-source element#{stream_description}"
end

#matches?(page_or_node) ⇒ Boolean

Returns:

  • (Boolean)


11
12
13
14
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_stream_tag.rb', line 11

def matches?(page_or_node)
  selector = build_selector
  page_or_node.has_css?(selector, wait: 0)
end