diff options
-rw-r--r-- | railties/Rakefile | 3 | ||||
-rw-r--r-- | railties/lib/rails_generator/commands.rb | 8 | ||||
-rw-r--r-- | railties/test/backtrace_cleaner_test.rb | 44 | ||||
-rw-r--r-- | railties/test/console_app_test.rb | 42 |
4 files changed, 54 insertions, 43 deletions
diff --git a/railties/Rakefile b/railties/Rakefile index 62dc62502f..0250cc72a5 100644 --- a/railties/Rakefile +++ b/railties/Rakefile @@ -28,7 +28,8 @@ task :default => :test ## we can see the failures task :test do Dir['test/**/*_test.rb'].all? do |file| - system("ruby -Itest #{file}") + ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME')) + system(ruby, '-Itest', file) end or raise "Failures" end diff --git a/railties/lib/rails_generator/commands.rb b/railties/lib/rails_generator/commands.rb index 299044c3d7..b684dc92be 100644 --- a/railties/lib/rails_generator/commands.rb +++ b/railties/lib/rails_generator/commands.rb @@ -182,15 +182,19 @@ HELP nesting = class_name.split('::') name = nesting.pop + # Hack to limit const_defined? to non-inherited on 1.9. + extra = [] + extra << false unless Object.method(:const_defined?).arity == 1 + # Extract the last Module in the nesting. last = nesting.inject(Object) { |last, nest| - break unless last.const_defined?(nest) + break unless last.const_defined?(nest, *extra) last.const_get(nest) } # If the last Module exists, check whether the given # class exists and raise a collision if so. - if last and last.const_defined?(name.camelize) + if last and last.const_defined?(name.camelize, *extra) raise_class_collision(class_name) end end diff --git a/railties/test/backtrace_cleaner_test.rb b/railties/test/backtrace_cleaner_test.rb index 5955fd2856..bfb9cb7639 100644 --- a/railties/test/backtrace_cleaner_test.rb +++ b/railties/test/backtrace_cleaner_test.rb @@ -3,26 +3,30 @@ require 'abstract_unit' require 'initializer' require 'rails/backtrace_cleaner' -class TestWithBacktrace - include Test::Unit::Util::BacktraceFilter - include Rails::BacktraceFilterForTestUnit -end - -class BacktraceCleanerFilterTest < ActiveSupport::TestCase - def setup - @test = TestWithBacktrace.new - @backtrace = [ './test/rails/benchmark_test.rb', './test/rails/dependencies.rb', '/opt/local/lib/ruby/kernel.rb' ] +if defined? Test::Unit::Util::BacktraceFilter + class TestWithBacktrace + include Test::Unit::Util::BacktraceFilter + include Rails::BacktraceFilterForTestUnit end - - test "test with backtrace should use the rails backtrace cleaner to clean" do - Rails.stubs(:backtrace_cleaner).returns(stub(:clean)) - Rails.backtrace_cleaner.expects(:clean).with(@backtrace, nil) - @test.filter_backtrace(@backtrace) - end - - test "filter backtrace should have the same arity as Test::Unit::Util::BacktraceFilter" do - assert_nothing_raised do - @test.filter_backtrace(@backtrace, '/opt/local/lib') + + class BacktraceCleanerFilterTest < ActiveSupport::TestCase + def setup + @test = TestWithBacktrace.new + @backtrace = [ './test/rails/benchmark_test.rb', './test/rails/dependencies.rb', '/opt/local/lib/ruby/kernel.rb' ] + end + + test "test with backtrace should use the rails backtrace cleaner to clean" do + Rails.stubs(:backtrace_cleaner).returns(stub(:clean)) + Rails.backtrace_cleaner.expects(:clean).with(@backtrace, nil) + @test.filter_backtrace(@backtrace) + end + + test "filter backtrace should have the same arity as Test::Unit::Util::BacktraceFilter" do + assert_nothing_raised do + @test.filter_backtrace(@backtrace, '/opt/local/lib') + end end end -end
\ No newline at end of file +else + $stderr.puts 'No BacktraceFilter for minitest' +end diff --git a/railties/test/console_app_test.rb b/railties/test/console_app_test.rb index 7a5de5af8f..f11de087e3 100644 --- a/railties/test/console_app_test.rb +++ b/railties/test/console_app_test.rb @@ -11,30 +11,32 @@ require 'dispatcher' require 'console_app' # console_app sets Test::Unit.run to work around the at_exit hook in test/unit, which kills IRB -Test::Unit.run = false - -class ConsoleAppTest < Test::Unit::TestCase - def test_app_method_should_return_integration_session - assert_nothing_thrown do - console_session = app - assert_not_nil console_session - assert_instance_of ActionController::Integration::Session, - console_session +if Test::Unit.respond_to?(:run=) + Test::Unit.run = false + + class ConsoleAppTest < Test::Unit::TestCase + def test_app_method_should_return_integration_session + assert_nothing_thrown do + console_session = app + assert_not_nil console_session + assert_instance_of ActionController::Integration::Session, + console_session + end end - end - def test_reload_should_fire_preparation_callbacks - a = b = c = nil + def test_reload_should_fire_preparation_callbacks + a = b = c = nil - Dispatcher.to_prepare { a = b = c = 1 } - Dispatcher.to_prepare { b = c = 2 } - Dispatcher.to_prepare { c = 3 } - ActionController::Routing::Routes.expects(:reload) + Dispatcher.to_prepare { a = b = c = 1 } + Dispatcher.to_prepare { b = c = 2 } + Dispatcher.to_prepare { c = 3 } + ActionController::Routing::Routes.expects(:reload) - reload! + reload! - assert_equal 1, a - assert_equal 2, b - assert_equal 3, c + assert_equal 1, a + assert_equal 2, b + assert_equal 3, c + end end end |