Class: TurboRspec::Matchers::HaveTurboFrame
- Inherits:
-
Object
- Object
- TurboRspec::Matchers::HaveTurboFrame
- Defined in:
- lib/turbo_rspec/matchers/have_turbo_frame.rb
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(response_or_body) ⇒ Boolean
- #failure_message ⇒ Object
- #failure_message_when_negated ⇒ Object
-
#initialize ⇒ HaveTurboFrame
constructor
A new instance of HaveTurboFrame.
- #matches?(response_or_body) ⇒ Boolean
- #rendering(partial) ⇒ Object
- #with_content(text) ⇒ Object
- #with_id(id) ⇒ Object
Constructor Details
#initialize ⇒ HaveTurboFrame
Returns a new instance of HaveTurboFrame.
8 9 10 11 12 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 8 def initialize @id = nil @content = nil @partial = nil end |
Instance Method Details
#description ⇒ Object
47 48 49 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 47 def description "have turbo frame#{constraint_description}" end |
#does_not_match?(response_or_body) ⇒ Boolean
35 36 37 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 35 def does_not_match?(response_or_body) !matches?(response_or_body) end |
#failure_message ⇒ Object
39 40 41 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 39 def "expected response to contain a turbo frame#{constraint_description}\n#{}" end |
#failure_message_when_negated ⇒ Object
43 44 45 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 43 def "expected response not to contain a turbo frame#{constraint_description}" end |
#matches?(response_or_body) ⇒ Boolean
29 30 31 32 33 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 29 def matches?(response_or_body) @body = extract_body(response_or_body) @frames = parse_frames(@body) @frames.any? { |frame| frame_matches?(frame) } end |
#rendering(partial) ⇒ Object
24 25 26 27 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 24 def rendering(partial) @partial = partial.to_s self end |
#with_content(text) ⇒ Object
19 20 21 22 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 19 def with_content(text) @content = text.to_s self end |
#with_id(id) ⇒ Object
14 15 16 17 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 14 def with_id(id) @id = id.to_s self end |