public
Fork of dchelimsky/rspec-rails
Description: RSpec's official Ruby on Rails plugin
Homepage:
Clone URL: git://github.com/ianwhite/rspec-rails.git
Added spec for when render_partial is aliased before rspec
ianwhite (author)
Tue Apr 22 03:20:55 -0700 2008
commit  51477e207ad3ceb2fb8023b0e8ce09f0637188f5
tree    52984483e68884e5e74101824efa5c91185debda
parent  bbdc0ab62264562de27afaa3f1e22e2e5d7a26f9
...
44
45
46
47
48
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
...
44
45
46
 
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
0
@@ -44,5 +44,42 @@ describe ActionView::Base, "with RSpec extensions:", :type => :view do
0
       template.render(:partial => "name")
0
     end
0
   end
0
-
0
 end
0
+
0
+describe "When render_partial has been previously alias_method_chained" do
0
+  before(:all) do
0
+    # mess with a copy of ActionView::Base
0
+    @orig_action_view_base = ActionView::Base
0
+    ActionView.send :remove_const, :Base
0
+    ActionView::Base = @orig_action_view_base.clone
0
+    
0
+    # set up the alias_method_chain
0
+    ActionView::Base.class_eval do
0
+      def render_partial_with_chain(*args)
0
+        chain_method_called
0
+      end
0
+      alias_method_chain :render_partial, :chain
0
+    end
0
+    
0
+    # now run the rspec extension stuff (it has to be after the chain)
0
+    Kernel.eval File.read(File.join(File.dirname(__FILE__), '../../../lib/spec/rails/extensions/action_view/base.rb'))
0
+  end
0
+  
0
+  describe "#render_partial", :type => :view do
0
+    before do
0
+      @view = ActionView::Base.new
0
+      @view.stub!(:chain_method_called)
0
+    end
0
+
0
+    it "should call the chained method" do
0
+      @view.should_receive :chain_method_called
0
+      @view.render_partial('some/partial')
0
+    end
0
+  end
0
+  
0
+  after(:all) do
0
+    # set ActionView back to how it was
0
+    ActionView.send :remove_const, :Base
0
+    ActionView::Base = @orig_action_view_base
0
+  end
0
+end
0
\ No newline at end of file

Comments