diff --git a/README.md b/README.md index 8ca2766..2bf3cb5 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Lots of fun options! * `:start_on_start` will start the server when starting Guard (default `true`) * `:force_run` kills any process that's holding open the listen port before attempting to (re)start Rails (default `false`). * `:daemon` runs the server as a daemon, without any output to the terminal that ran `guard` (default `false`). +* `:debugger` runs the server with the debugger enabled (default `false`). Required ruby-debug gem. * `:timeout` waits this number of seconds when restarting the Rails server before reporting there's a problem (default `20`). * `:server` lets you specify the webserver engine to use (try `:server => :thin`). diff --git a/lib/guard/rails.rb b/lib/guard/rails.rb index fcdd3f4..fdcb2f2 100644 --- a/lib/guard/rails.rb +++ b/lib/guard/rails.rb @@ -13,7 +13,8 @@ module Guard :start_on_start => true, :force_run => false, :timeout => 20, - :server => nil + :server => nil, + :debugger => false } def initialize(watchers = [], options = {}) diff --git a/lib/guard/rails/runner.rb b/lib/guard/rails/runner.rb index 322005c..dff1d80 100644 --- a/lib/guard/rails/runner.rb +++ b/lib/guard/rails/runner.rb @@ -23,7 +23,7 @@ module Guard FileUtils.rm pid_file end end - + def restart stop start @@ -37,6 +37,7 @@ module Guard ] rails_options << '-d' if options[:daemon] + rails_options << '-u' if options[:debugger] rails_options << options[:server] if options[:server] %{sh -c 'cd #{Dir.pwd} && rails s #{rails_options.join(' ')} &'} diff --git a/spec/lib/guard/rails/runner_spec.rb b/spec/lib/guard/rails/runner_spec.rb index e9f1c2a..182705c 100644 --- a/spec/lib/guard/rails/runner_spec.rb +++ b/spec/lib/guard/rails/runner_spec.rb @@ -47,6 +47,14 @@ describe Guard::RailsRunner do runner.build_rails_command.should match(%r{ -d}) end end + + context 'debugger' do + let(:options) { default_options.merge(:debugger => true) } + + it "should have a debugger switch" do + runner.build_rails_command.should match(%r{ -u}) + end + end context 'custom server' do let(:options) { default_options.merge(:server => 'thin') }