Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 66d710d6abc68aaed00c8a2efe1ba620200b5e3f 1 parent 7feca16
David Chelimsky authored June 21, 2009
11  lib/spec/rails/matchers/render_template.rb
@@ -33,7 +33,16 @@ def matches?(response_or_controller)
33 33
           return false if @actual.blank?
34 34
           given_controller_path, given_file = path_and_file(@actual)
35 35
           expected_controller_path, expected_file = path_and_file(@expected)
36  
-          given_controller_path == expected_controller_path && given_file.match(expected_file)
  36
+          given_controller_path == expected_controller_path && match_files(given_file, expected_file)
  37
+        end
  38
+        
  39
+        def match_files(actual, expected)
  40
+          actual_parts = actual.split('.')
  41
+          expected_parts = expected.split('.')
  42
+          expected_parts.each_with_index do |expected_part, index|
  43
+            return false unless expected_part == actual_parts[index]
  44
+          end
  45
+          true
37 46
         end
38 47
         
39 48
         def failure_message_for_should
5  spec/spec/rails/matchers/render_template_spec.rb
@@ -16,6 +16,11 @@
16 16
         should render_template('some_action')
17 17
       end
18 18
 
  19
+      it "does not match an action that is a truncated version of the actual action" do
  20
+        post 'some_action'
  21
+        should_not render_template('some_actio')
  22
+      end
  23
+
19 24
       if ::Rails::VERSION::STRING >= '2.3'
20 25
         it "matches an action with specified extenstions (implicit format)" do
21 26
           post 'some_action'

0 notes on commit 66d710d

Please sign in to comment.
Something went wrong with that request. Please try again.