class Shoulda::Matchers::ActionController::RenderWithLayoutMatcher

@private

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

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

def failure_message_when_negated

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

def in_context(context)

ActionController::TemplateAssertions in Rails 3
Used to provide access to layouts recorded by
def in_context(context)
  @context = context
  self
end

def initialize(expected_layout)

def initialize(expected_layout)
  if expected_layout
    @expected_layout = expected_layout.to_s
  else
    @expected_layout = nil
  end
  @controller = nil
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