diff options
author | José Valim <jose.valim@gmail.com> | 2011-05-23 06:48:05 -0700 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-05-23 06:48:05 -0700 |
commit | a5fb1c61755f03a8c75b0a434fb2aca57502293b (patch) | |
tree | 093d94f72e157c71baaf8a3e749f4e4c20781bfd /activesupport/test | |
parent | 5c3f3f10babe01ec0b6ae04a8846b5598d107926 (diff) | |
parent | 2514d65ca2b92f57b52e8027f6ab6fc8601df92f (diff) | |
download | rails-a5fb1c61755f03a8c75b0a434fb2aca57502293b.tar.gz rails-a5fb1c61755f03a8c75b0a434fb2aca57502293b.tar.bz2 rails-a5fb1c61755f03a8c75b0a434fb2aca57502293b.zip |
Merge pull request #1231 from joshk/ruby-debugger
Ruby debugger corrections
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/kernel_test.rb | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/activesupport/test/core_ext/kernel_test.rb b/activesupport/test/core_ext/kernel_test.rb index ede9b0a6aa..995bc0751a 100644 --- a/activesupport/test/core_ext/kernel_test.rb +++ b/activesupport/test/core_ext/kernel_test.rb @@ -52,10 +52,10 @@ class KernelTest < Test::Unit::TestCase class << o; @x = 1; end assert_equal 1, o.class_eval { @x } end - + def test_capture - assert_equal 'STDERR', capture(:stderr) {$stderr.print 'STDERR'} - assert_equal 'STDOUT', capture(:stdout) {print 'STDOUT'} + assert_equal 'STDERR', capture(:stderr) { $stderr.print 'STDERR' } + assert_equal 'STDOUT', capture(:stdout) { print 'STDOUT' } end end @@ -73,3 +73,43 @@ class KernelSuppressTest < Test::Unit::TestCase suppress(LoadError, ArgumentError) { raise ArgumentError } end end + +class MockStdErr + attr_reader :output + def puts(message) + @output ||= [] + @output << message + end + + def info(message) + puts(message) + end + + def write(message) + puts(message) + end +end + +class KernelDebuggerTest < Test::Unit::TestCase + def test_debugger_not_available_message_to_stderr + old_stderr = $stderr + $stderr = MockStdErr.new + debugger + assert_match(/Debugger requested/, $stderr.output.first) + ensure + $stderr = old_stderr + end + + def test_debugger_not_available_message_to_rails_logger + rails = Class.new do + def self.logger + @logger ||= MockStdErr.new + end + end + Object.const_set("Rails", rails) + debugger + assert_match(/Debugger requested/, rails.logger.output.first) + ensure + Object.send(:remove_const, "Rails") + end +end
\ No newline at end of file |