Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix bug where render_template would match 'newer' for 'new'

  • Loading branch information...
commit 66d710d6abc68aaed00c8a2efe1ba620200b5e3f 1 parent 7feca16
@dchelimsky authored
View
11 lib/spec/rails/matchers/render_template.rb
@@ -33,7 +33,16 @@ def matches?(response_or_controller)
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 && given_file.match(expected_file)
+ given_controller_path == expected_controller_path && match_files(given_file, expected_file)
+ end
+
+ def match_files(actual, expected)
+ actual_parts = actual.split('.')
+ expected_parts = expected.split('.')
+ expected_parts.each_with_index do |expected_part, index|
+ return false unless expected_part == actual_parts[index]
+ end
+ true
end
def failure_message_for_should
View
5 spec/spec/rails/matchers/render_template_spec.rb
@@ -16,6 +16,11 @@
should render_template('some_action')
end
+ it "does not match an action that is a truncated version of the actual action" do
+ post 'some_action'
+ should_not render_template('some_actio')
+ end
+
if ::Rails::VERSION::STRING >= '2.3'
it "matches an action with specified extenstions (implicit format)" do
post 'some_action'
Please sign in to comment.
Something went wrong with that request. Please try again.