mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Removed the AS core_ext/kernel/debugger breakpoint method as this method is added by ruby-debug and should be left as is. Missing tests added.
This commit is contained in:
parent
eff5d9aed4
commit
2514d65ca2
2 changed files with 44 additions and 10 deletions
|
@ -5,12 +5,6 @@ module Kernel
|
|||
message = "\n***** Debugger requested, but was not available (ensure ruby-debug is listed in Gemfile/installed as gem): Start server with --debugger to enable *****\n"
|
||||
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
|
||||
end
|
||||
end
|
||||
|
||||
undef :breakpoint if respond_to?(:breakpoint)
|
||||
def breakpoint
|
||||
message = "\n***** The 'breakpoint' command has been renamed 'debugger' -- please change *****\n"
|
||||
defined?(Rails) ? Rails.logger.info(message) : $stderr.puts(message)
|
||||
debugger
|
||||
alias breakpoint debugger unless respond_to?(:breakpoint)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
Loading…
Reference in a new issue