Class: Shoulda::ActionController::Matchers::RenderWithLayout

Inherits:
Object
  • Object
show all
Defined in:
lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(expected_layout) ⇒ RenderWithLayout

Returns a new instance of RenderWithLayout.


18
19
20
# File 'lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb', line 18

def initialize(expected_layout)
  @expected_layout = expected_layout.to_s unless expected_layout.nil?
end

Instance Method Details

#descriptionObject


42
43
44
45
46
47
48
49
50
# File 'lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb', line 42

def description
  description = "render with "
  if @expected_layout.nil?
    description << "a layout"
  else
    description << "the #{@expected_layout.inspect} layout"
  end
  description
end

#failure_messageObject


34
35
36
# File 'lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb', line 34

def failure_message
  "Expected #{expectation}, but #{result}"
end

#in_context(context) ⇒ Object

Used to provide access to layouts recorded by ActionController::TemplateAssertions in Rails 3


24
25
26
27
# File 'lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb', line 24

def in_context(context)
  @context = context
  self
end

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)

29
30
31
32
# File 'lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb', line 29

def matches?(controller)
  @controller = controller
  rendered_with_layout? && rendered_with_expected_layout?
end

#negative_failure_messageObject


38
39
40
# File 'lib/shoulda/action_controller/matchers/render_with_layout_matcher.rb', line 38

def negative_failure_message
  "Did not expect #{expectation}, but #{result}"
end