Skip to content

Loading…

Reload instead of run_all #8

Merged
merged 1 commit into from

2 participants

@tehpeh

Hi John,

This is what I meant regarding issue 6.

I've replaced run_all with reload so when a user hits return, nothing happens, but when they hit r+return the rails server restarts. This means you can use return to just run all tests, and r+return to restart rails, spork etc...

Any watched files will restart rails when touched, the same way it happens now.

What do you think? Does that work for you?

Tim Preston Swapped run_all for reload.
This means hitting return will not reload rails server,
instead 'r' or 'reload' must be issued.
3ac6507
@johnbintz johnbintz merged commit 63c648c into johnbintz:master
@johnbintz
Owner

So I guess you're stacking your Rails runner and tests in one group/guard, then. I'll take a cue from guard-spork and support the same reload behavior, then. Consider your patch merged. :) Thanks for contributing!

@tehpeh

Ok now I see. I was using different groups for a while, but now just run everything together. I run rails in daemon mode and tail the logs when I need to see what's going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 17, 2011
  1. Swapped run_all for reload.

    Tim Preston committed
    This means hitting return will not reload rails server,
    instead 'r' or 'reload' must be issued.
Showing with 12 additions and 13 deletions.
  1. +1 −0 .gitignore
  2. +3 −5 lib/guard/rails.rb
  3. +8 −8 spec/lib/guard/rails_spec.rb
View
1 .gitignore
@@ -2,3 +2,4 @@
.bundle
Gemfile.lock
pkg/*
+.rvmrc
View
8 lib/guard/rails.rb
@@ -26,10 +26,10 @@ def initialize(watchers = [], options = {})
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."
- run_all if options[:start_on_start]
+ reload if options[:start_on_start]
end
- def run_all
+ def reload
UI.info "Restarting Rails..."
Notifier.notify("Rails restarting on port #{options[:port]} in #{options[:environment]} environment...", :title => "Restarting Rails...", :image => :pending)
if runner.restart
@@ -41,15 +41,13 @@ def run_all
end
end
- alias :reload :run_all
-
def stop
Notifier.notify("Until next time...", :title => "Rails shutting down.", :image => :pending)
runner.stop
end
def run_on_change(paths)
- run_all
+ reload
end
end
end
View
16 spec/lib/guard/rails_spec.rb
@@ -19,7 +19,7 @@
context 'start on start' do
it "should show the right message and run startup" do
- guard.expects(:run_all).once
+ guard.expects(:reload).once
ui_expectation
guard.start
end
@@ -29,14 +29,14 @@
let(:options) { { :start_on_start => false } }
it "should show the right message and not run startup" do
- guard.expects(:run_all).never
+ guard.expects(:reload).never
ui_expectation
guard.start
end
end
end
- describe '#run_all' do
+ describe '#reload' do
let(:pid) { '12345' }
before do
@@ -56,7 +56,7 @@
Guard::UI.expects(:info).with(regexp_matches(/#{pid}/))
Guard::Notifier.expects(:notify).with(regexp_matches(/Rails restarted/), has_entry(:image => :success))
- guard.run_all
+ guard.reload
end
end
@@ -70,11 +70,11 @@
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.run_all
+ guard.reload
end
end
end
-
+
describe '#stop' do
it "should stop correctly" do
Guard::Notifier.expects(:notify).with('Until next time...', anything)
@@ -83,8 +83,8 @@
end
describe '#run_on_change' do
- it "should run on change" do
- guard.expects(:run_all).once
+ it "should reload on change" do
+ guard.expects(:reload).once
guard.run_on_change([])
end
end
Something went wrong with that request. Please try again.