diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/gem_dependency_test.rb | 16 | ||||
-rw-r--r-- | railties/test/initializer_test.rb | 34 |
2 files changed, 26 insertions, 24 deletions
diff --git a/railties/test/gem_dependency_test.rb b/railties/test/gem_dependency_test.rb index 3ae0189327..b5946aa7b8 100644 --- a/railties/test/gem_dependency_test.rb +++ b/railties/test/gem_dependency_test.rb @@ -10,13 +10,13 @@ uses_mocha "Plugin Tests" do @gem = Rails::GemDependency.new "hpricot" @gem_with_source = Rails::GemDependency.new "hpricot", :source => "http://code.whytheluckystiff.net" @gem_with_version = Rails::GemDependency.new "hpricot", :version => "= 0.6" - @gem_with_lib = Rails::GemDependency.new "aws-s3", :lib => "aws/s3" + @gem_with_lib = Rails::GemDependency.new "aws-s3", :lib => "aws/s3" end def test_configuration_adds_gem_dependency config = Rails::Configuration.new config.gem "aws-s3", :lib => "aws/s3", :version => "0.4.0" - assert_equal [["install", "aws-s3", "--version", "= 0.4.0"]], config.gems.collect(&:install_command) + assert_equal [["install", "aws-s3", "--version", '"= 0.4.0"']], config.gems.collect(&:install_command) end def test_gem_creates_install_command @@ -28,7 +28,7 @@ uses_mocha "Plugin Tests" do end def test_gem_with_version_creates_install_command - assert_equal ["install", "hpricot", "--version", "= 0.6"], @gem_with_version.install_command + assert_equal ["install", "hpricot", "--version", '"= 0.6"'], @gem_with_version.install_command end def test_gem_creates_unpack_command @@ -36,26 +36,26 @@ uses_mocha "Plugin Tests" do end def test_gem_with_version_unpack_install_command - assert_equal ["unpack", "hpricot", "--version", "= 0.6"], @gem_with_version.unpack_command + assert_equal ["unpack", "hpricot", "--version", '"= 0.6"'], @gem_with_version.unpack_command end def test_gem_adds_load_paths @gem.expects(:gem).with(@gem.name) @gem.add_load_paths end - + def test_gem_with_version_adds_load_paths @gem_with_version.expects(:gem).with(@gem_with_version.name, @gem_with_version.requirement.to_s) @gem_with_version.add_load_paths end - + def test_gem_loading @gem.expects(:gem).with(@gem.name) @gem.expects(:require).with(@gem.name) @gem.add_load_paths @gem.load end - + def test_gem_with_lib_loading @gem_with_lib.expects(:gem).with(@gem_with_lib.name) @gem_with_lib.expects(:require).with(@gem_with_lib.lib) @@ -63,4 +63,4 @@ uses_mocha "Plugin Tests" do @gem_with_lib.load end end -end
\ No newline at end of file +end diff --git a/railties/test/initializer_test.rb b/railties/test/initializer_test.rb index 0df0164ca6..efce4f292d 100644 --- a/railties/test/initializer_test.rb +++ b/railties/test/initializer_test.rb @@ -38,27 +38,28 @@ class Initializer_after_initialize_with_blocks_environment_Test < Test::Unit::Te end config.after_initialize do $test_after_initialize_block2 = "congratulations" - end + end assert_nil $test_after_initialize_block1 - assert_nil $test_after_initialize_block2 + assert_nil $test_after_initialize_block2 + 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 + $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_second_after_initialize_block assert_equal "congratulations", $test_after_initialize_block2 end end - + class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit::TestCase def setup @@ -69,15 +70,16 @@ class Initializer_after_initialize_with_no_block_environment_Test < Test::Unit:: config.after_initialize # don't pass a block, this is what we're testing! config.after_initialize do $test_after_initialize_block2 = "congratulations" - end + 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 + $test_after_initialize_block2 = nil end def test_should_have_called_the_first_after_initialize_block @@ -95,7 +97,7 @@ uses_mocha 'framework paths' do def setup @config = Rails::Configuration.new @config.frameworks.clear - + File.stubs(:directory?).returns(true) @config.stubs(:framework_root_path).returns('') end @@ -112,7 +114,7 @@ uses_mocha 'framework paths' do def test_actioncontroller_or_actionview_add_actionpack @config.frameworks << :action_controller assert_framework_path '/actionpack/lib' - + @config.frameworks = [:action_view] assert_framework_path '/actionpack/lib' end @@ -204,22 +206,22 @@ uses_mocha "Initializer plugin loading tests" do load_plugins! end end - + def test_should_ensure_all_loaded_plugins_load_paths_are_added_to_the_load_path only_load_the_following_plugins! [:stubby, :acts_as_chunky_bacon] @initializer.add_plugin_load_paths - + assert $LOAD_PATH.include?(File.join(plugin_fixture_path('default/stubby'), 'lib')) assert $LOAD_PATH.include?(File.join(plugin_fixture_path('default/acts/acts_as_chunky_bacon'), 'lib')) end - + private - + def load_plugins! @initializer.add_plugin_load_paths @initializer.load_plugins end end - -end + +end |