class Shoulda::ActionController::Matchers::RenderWithLayout

:nodoc:

def description

def description
  description = "render with "
  if @layout.nil?
    description << "a layout"
  else
    description << "the #{@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 initialize(layout)

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

def layout

def layout
  layout = @controller.response.layout
  if layout.nil?
    nil
  else
    layout.split('/').last
  end
end

def matches?(controller)

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

def negative_failure_message

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

def rendered_with_expected_layout?

def rendered_with_expected_layout?
  return true if @layout.nil?
  layout == @layout
end

def rendered_with_layout?

def rendered_with_layout?
  !layout.blank?
end

def result

def result
  if rendered_with_layout?
    "rendered with the #{layout.inspect} layout"
  else
    "rendered without a layout"
  end
end