public
Fork of NZKoz/koz-rails
Description: Koz's rails git-svn clone
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/eventualbuddha/koz-rails.git
use  stubbing instead  of  monkeypatching to  stop  tests  from 
interfering  with  one another.  Closes  #11163 [RubyRedRick]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8899 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
nzkoz (author)
Tue Feb 19 13:43:13 -0800 2008
commit  0833ae16396d6803f383643aa559d00a52903d1f
tree    e1094c8d33008aa5f05c992282581e0f51c4b15e
parent  9d35fe263ed916bfd11667f9a2ef76872096ff2e
...
3
4
5
6
7
8
9
10
11
12
13
14
15
 
 
 
 
16
17
18
19
 
 
20
21
 
22
 
23
24
25
...
210
211
212
 
213
214
215
216
217
 
218
219
220
...
233
234
235
 
236
237
238
239
240
241
 
 
242
243
244
...
246
247
248
249
250
251
252
253
...
3
4
5
 
 
 
 
 
 
 
 
 
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
208
209
210
211
212
213
214
215
216
217
218
219
220
...
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
...
249
250
251
 
 
 
 
252
0
@@ -3,23 +3,21 @@ require 'action_controller/integration'
0
 
0
 uses_mocha 'integration' do
0
 
0
-# Stub process for testing.
0
-module ActionController
0
- module Integration
0
- class Session
0
- def process(*args)
0
- end
0
-
0
- def generic_url_rewriter
0
- end
0
- end
0
+module IntegrationSessionStubbing
0
+ def stub_integration_session(session)
0
+ session.stubs(:process)
0
+ session.stubs(:generic_url_rewriter)
0
   end
0
 end
0
 
0
 class SessionTest < Test::Unit::TestCase
0
+ include IntegrationSessionStubbing
0
+
0
   def setup
0
     @session = ActionController::Integration::Session.new
0
+ stub_integration_session(@session)
0
   end
0
+
0
   def test_https_bang_works_and_sets_truth_by_default
0
     assert !@session.https?
0
     @session.https!
0
@@ -210,11 +208,13 @@ class SessionTest < Test::Unit::TestCase
0
 end
0
 
0
 class IntegrationTestTest < Test::Unit::TestCase
0
+ include IntegrationSessionStubbing
0
 
0
   def setup
0
     @test = ::ActionController::IntegrationTest.new(:default_test)
0
     @test.class.stubs(:fixture_table_names).returns([])
0
     @session = @test.open_session
0
+ stub_integration_session(@session)
0
   end
0
 
0
   def test_opens_new_session
0
@@ -233,12 +233,15 @@ end
0
 # Tests that integration tests don't call Controller test methods for processing.
0
 # Integration tests have their own setup and teardown.
0
 class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
0
+ include IntegrationSessionStubbing
0
 
0
   def self.fixture_table_names
0
     []
0
   end
0
 
0
   def test_integration_methods_called
0
+ reset!
0
+ stub_integration_session(@integration_session)
0
     %w( get post head put delete ).each do |verb|
0
       assert_nothing_raised("'#{verb}' should use integration test methods") { send!(verb, '/') }
0
     end
0
@@ -246,8 +249,4 @@ class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest
0
 
0
 end
0
 
0
-# TODO
0
-# class MockCGITest < Test::Unit::TestCase
0
-# end
0
-
0
 end # uses_mocha

Comments

    No one has commented yet.