class Spec::Rails::Matchers::RenderTemplate

def matches?(response_or_controller)

def matches?(response_or_controller)
  response  = response_or_controller.respond_to?(:response) ?
              response_or_controller.response :
              response_or_controller
  if response.respond_to?(:rendered_file)
    @actual = response.rendered_file
  elsif response.respond_to?(:rendered)
    case template = response.rendered[:template]
    when nil
      unless response.rendered[:partials].empty?
        @actual = path_and_file(response.rendered[:partials].keys.first).join("/_")
      end
    when ActionView::Template
      @actual = template.path
    when String
      @actual = template
    end
  else
    @actual = response.rendered_template.to_s
  end
  return false if @actual.blank?
  given_controller_path, given_file = path_and_file(@actual)
  expected_controller_path, expected_file = path_and_file(@expected)
  given_controller_path == expected_controller_path && match_files(given_file, expected_file)
end