Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
fix bug where render_template would match 'newer' for 'new'
Browse files Browse the repository at this point in the history
  • Loading branch information
dchelimsky committed Jun 22, 2009
1 parent 7feca16 commit 66d710d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/spec/rails/matchers/render_template.rb
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions spec/spec/rails/matchers/render_template_spec.rb
Expand Up @@ -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'
Expand Down

0 comments on commit 66d710d

Please sign in to comment.