Class: TurboRspec::Matchers::HaveTurboFrame
- Inherits:
-
Object
- Object
- TurboRspec::Matchers::HaveTurboFrame
- Defined in:
- lib/turbo_rspec/matchers/have_turbo_frame.rb
Overview
RSpec matcher for asserting that a response body contains a
+
Instance Method Summary collapse
- #description ⇒ Object
- #does_not_match?(response_or_body) ⇒ Boolean
- #failure_message ⇒ String
- #failure_message_when_negated ⇒ String
-
#initialize ⇒ HaveTurboFrame
constructor
A new instance of HaveTurboFrame.
- #matches?(response_or_body) ⇒ Boolean
-
#rendering(partial) ⇒ self
Constrains the match to frames whose HTML includes the given partial path.
-
#with_content(text) ⇒ self
Constrains the match to frames whose content includes the given text.
-
#with_id(id) ⇒ self
Constrains the match to frames with the given id attribute.
Constructor Details
#initialize ⇒ HaveTurboFrame
Returns a new instance of HaveTurboFrame.
20 21 22 23 24 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 20 def initialize @id = nil @content = nil @partial = nil end |
Instance Method Details
#description ⇒ Object
74 75 76 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 74 def description "have turbo frame#{constraint_description}" end |
#does_not_match?(response_or_body) ⇒ Boolean
60 61 62 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 60 def does_not_match?(response_or_body) !matches?(response_or_body) end |
#failure_message ⇒ String
65 66 67 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 65 def "expected response to contain a turbo frame#{constraint_description}\n#{}" end |
#failure_message_when_negated ⇒ String
70 71 72 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 70 def "expected response not to contain a turbo frame#{constraint_description}" end |
#matches?(response_or_body) ⇒ Boolean
52 53 54 55 56 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 52 def matches?(response_or_body) @body = extract_body(response_or_body) @frames = parse_frames(@body) @frames.any? { |frame| frame_matches?(frame) } end |
#rendering(partial) ⇒ self
Constrains the match to frames whose HTML includes the given partial path.
45 46 47 48 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 45 def rendering(partial) @partial = partial.to_s self end |
#with_content(text) ⇒ self
Constrains the match to frames whose content includes the given text.
37 38 39 40 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 37 def with_content(text) @content = text.to_s self end |
#with_id(id) ⇒ self
Constrains the match to frames with the given id attribute.
29 30 31 32 |
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 29 def with_id(id) @id = id.to_s self end |