lib/spec/rails/matchers/render_template.rb in rspec-rails-1.1.12 vs lib/spec/rails/matchers/render_template.rb in rspec-rails-1.2.0
- old
+ new
@@ -7,11 +7,15 @@
def initialize(expected, controller)
@controller = controller
@expected = expected
end
- def matches?(response)
+ 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
@@ -30,14 +34,14 @@
given_controller_path, given_file = path_and_file(@actual)
expected_controller_path, expected_file = path_and_file(@expected)
given_controller_path == expected_controller_path && given_file.match(expected_file)
end
- def failure_message
+ def failure_message_for_should
"expected #{@expected.inspect}, got #{@actual.inspect}"
end
- def negative_failure_message
+ def failure_message_for_should_not
"expected not to render #{@expected.inspect}, but did"
end
def description
"render template #{@expected.inspect}"