diff options
author | Joshua Peek <josh@joshpeek.com> | 2008-06-07 23:46:06 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2008-06-07 23:46:06 -0500 |
commit | 06b6f435cb7ed4b171eb600d3a9286829b8b2482 (patch) | |
tree | 8d3cba94305bd04dff6a5f868547a0f5e572c8b7 | |
parent | d5539958a892ece562ba3dcb36df12e046bd4879 (diff) | |
download | rails-06b6f435cb7ed4b171eb600d3a9286829b8b2482.tar.gz rails-06b6f435cb7ed4b171eb600d3a9286829b8b2482.tar.bz2 rails-06b6f435cb7ed4b171eb600d3a9286829b8b2482.zip |
Wrap Initializer after_initialize inside mocha block.
-rw-r--r-- | railties/test/initializer_test.rb | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb index efce4f292d..e5da491947 100644 --- a/railties/test/initializer_test.rb +++ b/railties/test/initializer_test.rb @@ -30,66 +30,66 @@ class Initializer_load_environment_Test < Test::Unit::TestCase end -class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase - def setup - config = ConfigurationMock.new("") - config.after_initialize do - $test_after_initialize_block1 = "success" - end - config.after_initialize do - $test_after_initialize_block2 = "congratulations" - end - assert_nil $test_after_initialize_block1 - assert_nil $test_after_initialize_block2 +uses_mocha 'Initializer after_initialize' do + class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::TestCase + def setup + config = ConfigurationMock.new("") + config.after_initialize do + $test_after_initialize_block1 = "success" + end + config.after_initialize do + $test_after_initialize_block2 = "congratulations" + end + assert_nil $test_after_initialize_block1 + assert_nil $test_after_initialize_block2 - Rails::Initializer.any_instance.expects(:gems_dependencies_loaded).returns(true) - Rails::Initializer.run(:after_initialize, config) - end + Rails::Initializer.any_instance.expects(:gems_dependencies_loaded).returns(true) + Rails::Initializer.run(:after_initialize, config) + end - def teardown - $test_after_initialize_block1 = nil - $test_after_initialize_block2 = nil - end + def teardown + $test_after_initialize_block1 = nil + $test_after_initialize_block2 = nil + end - def test_should_have_called_the_first_after_initialize_block - assert_equal "success", $test_after_initialize_block1 - end + def test_should_have_called_the_first_after_initialize_block + assert_equal "success", $test_after_initialize_block1 + end - def test_should_have_called_the_second_after_initialize_block - assert_equal "congratulations", $test_after_initialize_block2 + def test_should_have_called_the_second_after_initialize_block + assert_equal "congratulations", $test_after_initialize_block2 + end end -end -class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit::TestCase + class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit::TestCase + def setup + config = ConfigurationMock.new("") + config.after_initialize do + $test_after_initialize_block1 = "success" + end + config.after_initialize # don't pass a block, this is what we're testing! + config.after_initialize do + $test_after_initialize_block2 = "congratulations" + end + assert_nil $test_after_initialize_block1 - def setup - config = ConfigurationMock.new("") - config.after_initialize do - $test_after_initialize_block1 = "success" + Rails::Initializer.any_instance.expects(:gems_dependencies_loaded).returns(true) + Rails::Initializer.run(:after_initialize, config) end - config.after_initialize # don't pass a block, this is what we're testing! - config.after_initialize do - $test_after_initialize_block2 = "congratulations" - end - assert_nil $test_after_initialize_block1 - - Rails::Initializer.any_instance.expects(:gems_dependencies_loaded).returns(true) - Rails::Initializer.run(:after_initialize, config) - end - def teardown - $test_after_initialize_block1 = nil - $test_after_initialize_block2 = nil - end + def teardown + $test_after_initialize_block1 = nil + $test_after_initialize_block2 = nil + end - def test_should_have_called_the_first_after_initialize_block - assert_equal "success", $test_after_initialize_block1, "should still get set" - end + def test_should_have_called_the_first_after_initialize_block + assert_equal "success", $test_after_initialize_block1, "should still get set" + end - def test_should_have_called_the_second_after_initialize_block - assert_equal "congratulations", $test_after_initialize_block2 + def test_should_have_called_the_second_after_initialize_block + assert_equal "congratulations", $test_after_initialize_block2 + end end - end uses_mocha 'framework paths' do |