Class: Shoulda::Matchers::ActionController::RenderWithLayoutMatcher

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

Instance Method Summary collapse

Constructor Details

#initialize(expected_layout) ⇒ RenderWithLayoutMatcher

Returns a new instance of RenderWithLayoutMatcher.



66
67
68
69
70
71
72
73
74
# File 'lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb', line 66

def initialize(expected_layout)
  @expected_layout =
    if expected_layout
      expected_layout.to_s
    else
      nil
    end
  @controller = nil
end

Instance Method Details

#descriptionObject



96
97
98
99
100
101
102
103
104
105
# File 'lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb', line 96

def description
  String.new('render with ').tap do |string|
    string <<
      if @expected_layout.nil?
        'a layout'
      else
        "the #{@expected_layout.inspect} layout"
      end
  end
end

#failure_messageObject



88
89
90
# File 'lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb', line 88

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

#failure_message_when_negatedObject



92
93
94
# File 'lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb', line 92

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

#in_context(context) ⇒ Object

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



78
79
80
81
# File 'lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb', line 78

def in_context(context)
  @context = context
  self
end

#matches?(controller) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
86
# File 'lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb', line 83

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