class Shoulda::Matchers::ActionController::RenderWithLayoutMatcher
:nodoc:
def description
def description description = 'render with ' if @expected_layout.nil? description << 'a layout' else description << "the #{@expected_layout.inspect} layout" end description end
def expectation
def expectation "to #{description}" end
def failure_message_for_should
def failure_message_for_should "Expected #{expectation}, but #{result}" end
def failure_message_for_should_not
def failure_message_for_should_not "Did not expect #{expectation}, but #{result}" end
def in_context(context)
Used to provide access to layouts recorded by
def in_context(context) @context = context self end
def initialize(expected_layout)
def initialize(expected_layout) unless expected_layout.nil? @expected_layout = expected_layout.to_s end end
def matches?(controller)
def matches?(controller) @controller = controller rendered_with_layout? && rendered_with_expected_layout? end
def recorded_layouts
def recorded_layouts if @context @context.instance_variable_get('@layouts') else {} end end
def rendered_layouts
def rendered_layouts recorded_layouts.keys.compact.map { |layout| layout.sub(%r{^layouts/}, '') } end
def rendered_with_expected_layout?
def rendered_with_expected_layout? if @expected_layout.nil? true else rendered_layouts.include?(@expected_layout) end end
def rendered_with_layout?
def rendered_with_layout? !rendered_layouts.empty? end
def result
def result if rendered_with_layout? 'rendered with ' + rendered_layouts.map(&:inspect).join(', ') else 'rendered without a layout' end end