Reload instead of run_all #8

Merged
tehpeh merged 1 commits from reload_instead_of_run_all into master 2011-10-18 13:29:44 +00:00
3 changed files with 12 additions and 13 deletions
Showing only changes of commit 3ac650799c - Show all commits

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
.bundle .bundle
Gemfile.lock Gemfile.lock
pkg/* pkg/*
.rvmrc

View File

@ -26,10 +26,10 @@ module Guard
def start def start
server = options[:server] ? "#{options[:server]} and " : "" server = options[:server] ? "#{options[:server]} and " : ""
UI.info "Guard::Rails will now restart your app on port #{options[:port]} using #{server}#{options[:environment]} environment." 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] reload if options[:start_on_start]
end end
def run_all def reload
UI.info "Restarting Rails..." UI.info "Restarting Rails..."
Notifier.notify("Rails restarting on port #{options[:port]} in #{options[:environment]} environment...", :title => "Restarting Rails...", :image => :pending) Notifier.notify("Rails restarting on port #{options[:port]} in #{options[:environment]} environment...", :title => "Restarting Rails...", :image => :pending)
if runner.restart if runner.restart
@ -41,15 +41,13 @@ module Guard
end end
end end
alias :reload :run_all
def stop def stop
Notifier.notify("Until next time...", :title => "Rails shutting down.", :image => :pending) Notifier.notify("Until next time...", :title => "Rails shutting down.", :image => :pending)
runner.stop runner.stop
end end
def run_on_change(paths) def run_on_change(paths)
run_all reload
end end
end end
end end

View File

@ -19,7 +19,7 @@ describe Guard::Rails do
context 'start on start' do context 'start on start' do
it "should show the right message and run startup" do it "should show the right message and run startup" do
guard.expects(:run_all).once guard.expects(:reload).once
ui_expectation ui_expectation
guard.start guard.start
end end
@ -29,14 +29,14 @@ describe Guard::Rails do
let(:options) { { :start_on_start => false } } let(:options) { { :start_on_start => false } }
it "should show the right message and not run startup" do it "should show the right message and not run startup" do
guard.expects(:run_all).never guard.expects(:reload).never
ui_expectation ui_expectation
guard.start guard.start
end end
end end
end end
describe '#run_all' do describe '#reload' do
let(:pid) { '12345' } let(:pid) { '12345' }
before do before do
@ -56,7 +56,7 @@ describe Guard::Rails do
Guard::UI.expects(:info).with(regexp_matches(/#{pid}/)) Guard::UI.expects(:info).with(regexp_matches(/#{pid}/))
Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarted/), has_entry(:image => :success)) Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarted/), has_entry(:image => :success))
guard.run_all guard.reload
end end
end end
@ -70,7 +70,7 @@ describe Guard::Rails do
Guard::UI.expects(:info).with(regexp_matches(/Rails NOT restarted/)) Guard::UI.expects(:info).with(regexp_matches(/Rails NOT restarted/))
Guard::Notifier.expects(:notify).with(regexp_matches(/Rails NOT restarted/), has_entry(:image => :failed)) Guard::Notifier.expects(:notify).with(regexp_matches(/Rails NOT restarted/), has_entry(:image => :failed))
guard.run_all guard.reload
end end
end end
end end
@ -83,8 +83,8 @@ describe Guard::Rails do
end end
describe '#run_on_change' do describe '#run_on_change' do
it "should run on change" do it "should reload on change" do
guard.expects(:run_all).once guard.expects(:reload).once
guard.run_on_change([]) guard.run_on_change([])
end end
end end