Fixed notifications at start to say "Rails starting..." and "Rails started!" instead of "restarting". I enjoy accurate messages
This commit is contained in:
parent
70d76d166d
commit
14b8402e1c
@ -27,18 +27,19 @@ module Guard
|
||||
def start
|
||||
server = options[:server] ? "#{options[:server]} and " : ""
|
||||
UI.info "Guard::Rails will now restart your app on port #{options[:port]} using #{server}#{options[:environment]} environment."
|
||||
reload if options[:start_on_start]
|
||||
reload("start") if options[:start_on_start]
|
||||
end
|
||||
|
||||
def reload
|
||||
UI.info "Restarting Rails..."
|
||||
Notifier.notify("Rails restarting on port #{options[:port]} in #{options[:environment]} environment...", :title => "Restarting Rails...", :image => :pending)
|
||||
def reload(action = "restart")
|
||||
action_cap = action.capitalize
|
||||
UI.info "#{action_cap}ing Rails..."
|
||||
Notifier.notify("Rails #{action}ing on port #{options[:port]} in #{options[:environment]} environment...", :title => "#{action_cap}ing Rails...", :image => :pending)
|
||||
if runner.restart
|
||||
UI.info "Rails restarted, pid #{runner.pid}"
|
||||
Notifier.notify("Rails restarted on port #{options[:port]}.", :title => "Rails restarted!", :image => :success)
|
||||
UI.info "Rails #{action}ed, pid #{runner.pid}"
|
||||
Notifier.notify("Rails #{action}ed on port #{options[:port]}.", :title => "Rails #{action}ed!", :image => :success)
|
||||
else
|
||||
UI.info "Rails NOT restarted, check your log files."
|
||||
Notifier.notify("Rails NOT restarted, check your log files.", :title => "Rails NOT restarted!", :image => :failed)
|
||||
UI.info "Rails NOT #{action}ed, check your log files."
|
||||
Notifier.notify("Rails NOT #{action}ed, check your log files.", :title => "Rails NOT #{action}ed!", :image => :failed)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -40,13 +40,33 @@ describe Guard::Rails do
|
||||
let(:pid) { '12345' }
|
||||
|
||||
before do
|
||||
Guard::UI.expects(:info).with('Restarting Rails...')
|
||||
Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarting/), has_entry(:image => :pending))
|
||||
Guard::RailsRunner.any_instance.stubs(:pid).returns(pid)
|
||||
end
|
||||
|
||||
let(:runner_stub) { Guard::RailsRunner.any_instance.stubs(:restart) }
|
||||
|
||||
context 'at start' do
|
||||
before do
|
||||
Guard::UI.expects(:info).with('Starting Rails...')
|
||||
Guard::Notifier.expects(:notify).with(regexp_matches(/Rails starting/), has_entry(:image => :pending))
|
||||
runner_stub.returns(true)
|
||||
end
|
||||
|
||||
it "should start and show the pid file" do
|
||||
Guard::UI.expects(:info).with(regexp_matches(/#{pid}/))
|
||||
Guard::Notifier.expects(:notify).with(regexp_matches(/Rails started/), has_entry(:image => :success))
|
||||
|
||||
guard.reload("start")
|
||||
end
|
||||
end
|
||||
|
||||
context 'after start' do
|
||||
before do
|
||||
Guard::RailsRunner.any_instance.stubs(:pid).returns(pid)
|
||||
Guard::UI.expects(:info).with('Restarting Rails...')
|
||||
Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarting/), has_entry(:image => :pending))
|
||||
end
|
||||
|
||||
context 'with pid file' do
|
||||
before do
|
||||
runner_stub.returns(true)
|
||||
@ -74,6 +94,7 @@ describe Guard::Rails do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#stop' do
|
||||
it "should stop correctly" do
|
||||
|
Loading…
Reference in New Issue
Block a user