Class: Micronaut::Rails::Matchers::Controllers::RenderTemplate

Inherits:
Object
  • Object
show all
Defined in:
lib/micronaut/rails/matchers/controllers/render_template.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(expected, controller) ⇒ RenderTemplate

Returns a new instance of RenderTemplate.



8
9
10
11
# File 'lib/micronaut/rails/matchers/controllers/render_template.rb', line 8

def initialize(expected, controller)
  @controller = controller
  @expected = expected
end

Instance Method Details

#descriptionObject



33
34
35
# File 'lib/micronaut/rails/matchers/controllers/render_template.rb', line 33

def description
  "render template #{@expected.inspect}"
end

#failure_messageObject



25
26
27
# File 'lib/micronaut/rails/matchers/controllers/render_template.rb', line 25

def failure_message
  "expected #{@expected.inspect}, got #{@actual.inspect}"
end

#matches?(response) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
20
21
22
23
# File 'lib/micronaut/rails/matchers/controllers/render_template.rb', line 13

def matches?(response)
  if response.respond_to?(:rendered_file)
    @actual = response.rendered_file
  else
    @actual = response.rendered_template.to_s
  end
  return false if @actual.blank?
  given_controller_path, given_file = path_and_file(@actual)
  expected_controller_path, expected_file = path_and_file(@expected)
  given_controller_path == expected_controller_path && given_file.match(expected_file)
end

#negative_failure_messageObject



29
30
31
# File 'lib/micronaut/rails/matchers/controllers/render_template.rb', line 29

def negative_failure_message
  "expected not to render #{@expected.inspect}, but did"
end