Class: TurboRspec::Matchers::HaveTurboFrame

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

Instance Method Summary collapse

Constructor Details

#initializeHaveTurboFrame

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

#descriptionObject



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

Returns:

  • (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_messageObject



39
40
41
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 39

def failure_message
  "expected response to contain a turbo frame#{constraint_description}\n#{found_frames_message}"
end

#failure_message_when_negatedObject



43
44
45
# File 'lib/turbo_rspec/matchers/have_turbo_frame.rb', line 43

def failure_message_when_negated
  "expected response not to contain a turbo frame#{constraint_description}"
end

#matches?(response_or_body) ⇒ Boolean

Returns:

  • (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