Skip to content

Commit

Permalink
Add custom server to options (:server => 'thin').
Browse files Browse the repository at this point in the history
  • Loading branch information
tehpeh committed Jul 12, 2011
1 parent 7429b1f commit 372e2cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/guard/rails.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class Rails < ::Guard::Guard
:environment => 'development',
:start_on_start => true,
:force_run => false,
:timeout => 20
:timeout => 20,
:server => nil
}

def initialize(watchers = [], options = {})
Expand All @@ -23,7 +24,8 @@ def initialize(watchers = [], options = {})
end

def start
UI.info "Guard::Rails will now restart your app on port #{options[:port]} using #{options[:environment]} environment."
server = options[:server] ? "#{options[:server]} and " : ""
UI.info "Guard::Rails will now restart your app on port #{options[:port]} using #{server}#{options[:environment]} environment."
run_all if options[:start_on_start]
end

Expand Down
1 change: 1 addition & 0 deletions lib/guard/rails/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def build_rails_command
]

rails_options << '-d' if options[:daemon]
rails_options << options[:server] if options[:server]

%{sh -c 'cd #{Dir.pwd} && rails s #{rails_options.join(' ')} &'}
end
Expand Down
8 changes: 8 additions & 0 deletions spec/lib/guard/rails/runner_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@
runner.build_rails_command.should match(%r{ -d})
end
end

context 'custom server' do
let(:options) { default_options.merge(:server => 'thin') }

it "should have the server name" do
runner.build_rails_command.should match(%r{thin})
end
end
end

describe '#start' do
Expand Down

0 comments on commit 372e2cd

Please sign in to comment.