Isolate debugger related code

上级 eb2d555f
...@@ -76,9 +76,19 @@ def set_environment! ...@@ -76,9 +76,19 @@ def set_environment!
Rails.env = environment Rails.env = environment
end end
def debugger? if RUBY_VERSION < '2.0.0'
options[:debugger] def debugger?
end if RUBY_VERSION < '2.0.0' options[:debugger]
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 def start
if RUBY_VERSION < '2.0.0' if RUBY_VERSION < '2.0.0'
...@@ -99,13 +109,5 @@ def start ...@@ -99,13 +109,5 @@ def start
end end
console.start console.start
end 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
end end
...@@ -19,14 +19,8 @@ def test_short_version_of_sandbox_option ...@@ -19,14 +19,8 @@ def test_short_version_of_sandbox_option
assert console.sandbox? assert console.sandbox?
end 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 def test_no_options
console = Rails::Console.new(app, parse_arguments([])) console = Rails::Console.new(app, parse_arguments([]))
assert !console.debugger? if RUBY_VERSION < '2.0.0'
assert !console.sandbox? assert !console.sandbox?
end end
...@@ -36,13 +30,6 @@ def test_start ...@@ -36,13 +30,6 @@ def test_start
assert_match(/Loading \w+ environment \(Rails/, output) assert_match(/Loading \w+ environment \(Rails/, output)
end 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 def test_start_with_sandbox
app.expects(:sandbox=).with(true) app.expects(:sandbox=).with(true)
FakeConsole.expects(:start) FakeConsole.expects(:start)
...@@ -52,6 +39,25 @@ def test_start_with_sandbox ...@@ -52,6 +39,25 @@ def test_start_with_sandbox
assert_match(/Loading \w+ environment in sandbox \(Rails/, output) assert_match(/Loading \w+ environment in sandbox \(Rails/, output)
end 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 def test_console_with_environment
start ["-e production"] start ["-e production"]
assert_match(/\sproduction\s/, output) assert_match(/\sproduction\s/, output)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册