class Shoulda::Matchers::ActionController::RenderWithLayoutMatcher
@private
Public Class Methods
Source
# 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
Public Instance Methods
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 96 def description description = 'render with ' description << if @expected_layout.nil? 'a layout' else "the #{@expected_layout.inspect} layout" end description end
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 88 def failure_message "Expected #{expectation}, but #{result}" end
Source
# 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
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 78 def in_context(context) @context = context self end
Used to provide access to layouts recorded by ActionController::TemplateAssertions in Rails 3
Source
# 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
Private Instance Methods
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 135 def expectation "to #{description}" end
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 127 def recorded_layouts if @context @context.instance_variable_get('@_layouts') else {} end end
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 121 def rendered_layouts recorded_layouts.keys.compact.map { |layout| layout.sub(%r{^layouts/}, '') } end
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 113 def rendered_with_expected_layout? if @expected_layout.nil? true else rendered_layouts.include?(@expected_layout) end end
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 109 def rendered_with_layout? !rendered_layouts.empty? end
Source
# File lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb, line 139 def result if rendered_with_layout? "rendered with #{rendered_layouts.map(&:inspect).join(', ')}" else 'rendered without a layout' end end