mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Isolate debugger related code
This commit is contained in:
parent
eb2d555f5c
commit
6fae9ac581
2 changed files with 32 additions and 24 deletions
|
@ -76,9 +76,19 @@ module Rails
|
|||
Rails.env = environment
|
||||
end
|
||||
|
||||
if RUBY_VERSION < '2.0.0'
|
||||
def debugger?
|
||||
options[:debugger]
|
||||
end if RUBY_VERSION < '2.0.0'
|
||||
end
|
||||
|
||||
def require_debugger
|
||||
require 'debugger'
|
||||
puts "=> Debugger enabled"
|
||||
rescue LoadError
|
||||
puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle it and try again."
|
||||
exit(1)
|
||||
end
|
||||
end
|
||||
|
||||
def start
|
||||
if RUBY_VERSION < '2.0.0'
|
||||
|
@ -99,13 +109,5 @@ module Rails
|
|||
end
|
||||
console.start
|
||||
end
|
||||
|
||||
def require_debugger
|
||||
require 'debugger'
|
||||
puts "=> Debugger enabled"
|
||||
rescue LoadError
|
||||
puts "You're missing the 'debugger' gem. Add it to your Gemfile, bundle it and try again."
|
||||
exit(1)
|
||||
end if RUBY_VERSION < '2.0.0'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,14 +19,8 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
|
|||
assert console.sandbox?
|
||||
end
|
||||
|
||||
def test_debugger_option
|
||||
console = Rails::Console.new(app, parse_arguments(["--debugger"]))
|
||||
assert console.debugger?
|
||||
end if RUBY_VERSION < '2.0.0'
|
||||
|
||||
def test_no_options
|
||||
console = Rails::Console.new(app, parse_arguments([]))
|
||||
assert !console.debugger? if RUBY_VERSION < '2.0.0'
|
||||
assert !console.sandbox?
|
||||
end
|
||||
|
||||
|
@ -36,13 +30,6 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
|
|||
assert_match(/Loading \w+ environment \(Rails/, output)
|
||||
end
|
||||
|
||||
def test_start_with_debugger
|
||||
rails_console = Rails::Console.new(app, parse_arguments(["--debugger"]))
|
||||
rails_console.expects(:require_debugger).returns(nil)
|
||||
|
||||
silence_stream(STDOUT) { rails_console.start }
|
||||
end if RUBY_VERSION < '2.0.0'
|
||||
|
||||
def test_start_with_sandbox
|
||||
app.expects(:sandbox=).with(true)
|
||||
FakeConsole.expects(:start)
|
||||
|
@ -52,6 +39,25 @@ class Rails::ConsoleTest < ActiveSupport::TestCase
|
|||
assert_match(/Loading \w+ environment in sandbox \(Rails/, output)
|
||||
end
|
||||
|
||||
if RUBY_VERSION < '2.0.0'
|
||||
def test_debugger_option
|
||||
console = Rails::Console.new(app, parse_arguments(["--debugger"]))
|
||||
assert console.debugger?
|
||||
end
|
||||
|
||||
def test_no_options_does_not_set_debugger_flag
|
||||
console = Rails::Console.new(app, parse_arguments([]))
|
||||
assert !console.debugger?
|
||||
end
|
||||
|
||||
def test_start_with_debugger
|
||||
rails_console = Rails::Console.new(app, parse_arguments(["--debugger"]))
|
||||
rails_console.expects(:require_debugger).returns(nil)
|
||||
|
||||
silence_stream(STDOUT) { rails_console.start }
|
||||
end
|
||||
end
|
||||
|
||||
def test_console_with_environment
|
||||
start ["-e production"]
|
||||
assert_match(/\sproduction\s/, output)
|
||||
|
|
Loading…
Reference in a new issue