Class: TurboRspec::Capybara::Matchers::HaveTurboFrame
- Inherits:
-
Object
- Object
- TurboRspec::Capybara::Matchers::HaveTurboFrame
- Defined in:
- lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(page_or_node) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize(id) ⇒ HaveTurboFrame
constructor
A new instance of HaveTurboFrame.
- #loaded ⇒ Object
- #matches?(page_or_node) ⇒ Boolean
- #with_content(text) ⇒ Object
Constructor Details
#initialize(id) ⇒ HaveTurboFrame
Returns a new instance of HaveTurboFrame.
7 8 9 10 11 |
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb', line 7 def initialize(id) @id = id.to_s @content = nil @loaded = false end |
Instance Method Details
#description ⇒ Object
49 50 51 |
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb', line 49 def description "have turbo-frame##{@id}#{constraint_description}" end |
#does_not_match?(page_or_node) ⇒ Boolean
31 32 33 |
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb', line 31 def does_not_match?(page_or_node) !matches?(page_or_node) end |
#failure_message ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb', line 35 def if @node.nil? "expected page to have turbo-frame##{@id}#{constraint_description} but it was not found" elsif @loaded && !@node[:complete] "expected turbo-frame##{@id} to be loaded (missing [complete] attribute)" else "expected turbo-frame##{@id} to have content #{@content.inspect}" end end |
#failure_message_when_negated ⇒ Object
45 46 47 |
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb', line 45 def "expected page not to have turbo-frame##{@id}#{constraint_description}" end |
#loaded ⇒ Object
18 19 20 21 |
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb', line 18 def loaded @loaded = true self end |
#matches?(page_or_node) ⇒ Boolean
23 24 25 26 27 28 29 |
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb', line 23 def matches?(page_or_node) @node = find_frame(page_or_node) return false unless @node return false if @loaded && !@node[:complete] return false if @content && !@node.has_content?(@content, wait: 0) true end |
#with_content(text) ⇒ Object
13 14 15 16 |
# File 'lib/turbo_rspec/capybara/matchers/have_turbo_frame.rb', line 13 def with_content(text) @content = text.to_s self end |