public
Fork of dchelimsky/rspec-rails
Description: RSpec's official Ruby on Rails plugin
Homepage:
Clone URL: git://github.com/ianwhite/rspec-rails.git
Spec and fix for ticket 469 - hide spec public actions on controllers
ianwhite (author)
Tue Jul 15 11:54:14 -0700 2008
commit  cee75ed25fa5f84cc70f8012b4ba277d630dd67e
tree    ce3a7a4daeeaefc4b42184ce4efda2160462204f
parent  9a1e10e7b71f7e8e4fb910a9695ee69abec63816
...
9
10
11
12
 
 
13
14
15
...
78
79
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
82
83
...
9
10
11
 
12
13
14
15
16
...
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
0
@@ -9,7 +9,8 @@ module Spec
0
         before(:each) do
0
           @controller_class = Object.path2class @controller_class_name
0
           raise "Can't determine controller class for #{@controller_class_name}" if @controller_class.nil?
0
-
0
+          
0
+          hide_spec_public_instance_methods_on_controller_class
0
           @controller = @controller_class.new
0
           @request = ActionController::TestRequest.new
0
           @response = ActionController::TestResponse.new
0
@@ -78,6 +79,21 @@ module Spec
0
             _assigns_hash_proxy[key]
0
           end
0
         end
0
+        
0
+      private
0
+        # any spec modules that have been included must have their public_instance_methods
0
+        # hidden, otehrwise they will show up as actions on the controller
0
+        #
0
+        # We also need to hide up the pretty print methods, if they exist,
0
+        # including :pretty_inspect added to Kernel
0
+        def hide_spec_public_instance_methods_on_controller_class
0
+          Spec::Mocks::Methods.public_instance_methods.each{|m| @controller_class.hide_action(m)}
0
+          
0
+          if defined?(PP::ObjectMixin)
0
+            PP::ObjectMixin.public_instance_methods.each{|m| @controller_class.hide_action(m)}
0
+            @controller_class.hide_action 'pretty_inspect' # this has been added to Kernel
0
+          end
0
+        end
0
       end
0
     end
0
   end

Comments