Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8899

Show
Ignore:
Timestamp:
02/19/08 21:43:13 (2 years ago)
Author:
nzkoz
Message:

use stubbing instead of monkeypatching to stop tests from interfering with one another. Closes #11163 [RubyRedRick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/test/controller/integration_test.rb

    r8564 r8899  
    44uses_mocha 'integration' do 
    55 
    6 # Stub process for testing. 
    7 module ActionController 
    8   module Integration 
    9     class Session 
    10       def process(*args) 
    11       end 
    12  
    13       def generic_url_rewriter 
    14       end 
    15     end 
     6module IntegrationSessionStubbing 
     7  def stub_integration_session(session) 
     8    session.stubs(:process) 
     9    session.stubs(:generic_url_rewriter) 
    1610  end 
    1711end 
    1812 
    1913class SessionTest < Test::Unit::TestCase 
     14  include IntegrationSessionStubbing 
     15   
    2016  def setup 
    2117    @session = ActionController::Integration::Session.new 
    22   end 
     18    stub_integration_session(@session) 
     19  end 
     20   
    2321  def test_https_bang_works_and_sets_truth_by_default 
    2422    assert !@session.https? 
     
    211209 
    212210class IntegrationTestTest < Test::Unit::TestCase 
     211  include IntegrationSessionStubbing 
    213212 
    214213  def setup 
     
    216215    @test.class.stubs(:fixture_table_names).returns([]) 
    217216    @session = @test.open_session 
     217    stub_integration_session(@session) 
    218218  end 
    219219 
     
    234234# Integration tests have their own setup and teardown. 
    235235class IntegrationTestUsesCorrectClass < ActionController::IntegrationTest 
     236  include IntegrationSessionStubbing 
    236237 
    237238  def self.fixture_table_names 
     
    240241 
    241242  def test_integration_methods_called 
     243    reset! 
     244    stub_integration_session(@integration_session) 
    242245    %w( get post head put delete ).each do |verb| 
    243246      assert_nothing_raised("'#{verb}' should use integration test methods") { send!(verb, '/') } 
     
    247250end 
    248251 
    249 # TODO 
    250 # class MockCGITest < Test::Unit::TestCase 
    251 # end 
    252  
    253252end # uses_mocha