Class: Dommy::Rails::RSpec::Matchers::HaveTurboFrame
- Inherits:
-
Object
- Object
- Dommy::Rails::RSpec::Matchers::HaveTurboFrame
- Defined in:
- lib/dommy/rails/rspec/matchers.rb
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(actual) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(id, text:, count:) ⇒ HaveTurboFrame
constructor
A new instance of HaveTurboFrame.
- #matches?(actual, &block) ⇒ Boolean
Constructor Details
#initialize(id, text:, count:) ⇒ HaveTurboFrame
Returns a new instance of HaveTurboFrame.
360 361 362 363 364 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 360 def initialize(id, text:, count:) @id = id @text = text @count = count end |
Instance Method Details
#description ⇒ Object
377 378 379 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 377 def description "have turbo-frame#{@id ? " ##{@id}" : ""}" end |
#does_not_match?(actual) ⇒ Boolean
373 374 375 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 373 def does_not_match?(actual) !matches?(actual) end |
#failure_message ⇒ Object
381 382 383 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 381 def "expected to find turbo-frame#{@id ? " ##{@id}" : ""}, found #{@matched.size}" end |
#failure_message_when_negated ⇒ Object
385 386 387 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 385 def "expected not to find turbo-frame#{@id ? " ##{@id}" : ""}, found #{@matched.size}" end |
#matches?(actual, &block) ⇒ Boolean
366 367 368 369 370 371 |
# File 'lib/dommy/rails/rspec/matchers.rb', line 366 def matches?(actual, &block) @matched = Dommy::Rails::PageInspector.turbo_frames(MatchTarget.document(actual), @id, text: @text) ok = Dommy::Internal::DomMatching.count_matches?(@matched.size, @count) block.call(@matched.first) if ok && block && @matched.any? ok end |