write some tests
This commit is contained in:
parent
1bc4fb1a99
commit
6439609a8a
8
Gemfile
8
Gemfile
|
@ -3,5 +3,11 @@ source "http://rubygems.org"
|
|||
# Specify your gem's dependencies in guard-rails.gemspec
|
||||
gemspec
|
||||
gem 'rake', '0.8.7'
|
||||
gem 'growl'
|
||||
gem 'fakefs', :require => nil
|
||||
gem 'guard'
|
||||
gem 'guard-rspec'
|
||||
|
||||
# TODO: make this more OS-independent...like the rest of the gem
|
||||
gem 'growl'
|
||||
gem 'rb-fsevent'
|
||||
|
||||
|
|
|
@ -7,21 +7,23 @@ module Guard
|
|||
class Rails < ::Guard::Guard
|
||||
attr_reader :options, :runner
|
||||
|
||||
def initialize(watchers = [], options = {})
|
||||
super
|
||||
@options = {
|
||||
DEFAULT_OPTIONS = {
|
||||
:port => 3000,
|
||||
:environment => 'development',
|
||||
:start_on_start => true,
|
||||
:force_run => false,
|
||||
:timeout => 20
|
||||
}.merge(options)
|
||||
}
|
||||
|
||||
def initialize(watchers = [], options = {})
|
||||
super
|
||||
@options = DEFAULT_OPTIONS.merge(options)
|
||||
|
||||
@runner = RailsRunner.new(@options)
|
||||
end
|
||||
|
||||
def start
|
||||
UI.info "Guard::Rails restarting app on port #{options[:port]} using #{options[:environment]} environment."
|
||||
UI.info "Guard::Rails will now restart your app on port #{options[:port]} using #{options[:environment]} environment."
|
||||
run_all if options[:start_on_start]
|
||||
end
|
||||
|
||||
|
|
|
@ -14,6 +14,28 @@ describe Guard::Rails do
|
|||
end
|
||||
end
|
||||
|
||||
describe '#start' do
|
||||
let(:ui_expectation) { Guard::UI.expects(:info).with(regexp_matches(/#{Guard::Rails::DEFAULT_OPTIONS[:port]}/)) }
|
||||
|
||||
context 'start on start' do
|
||||
it "should show the right message and run startup" do
|
||||
guard.expects(:run_all).once
|
||||
ui_expectation
|
||||
guard.start
|
||||
end
|
||||
end
|
||||
|
||||
context 'no start on start' do
|
||||
let(:options) { { :start_on_start => false } }
|
||||
|
||||
it "should show the right message and not run startup" do
|
||||
guard.expects(:run_all).never
|
||||
ui_expectation
|
||||
guard.start
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#run_all' do
|
||||
let(:pid) { '12345' }
|
||||
|
||||
|
@ -52,5 +74,19 @@ describe Guard::Rails do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#stop' do
|
||||
it "should stop correctly" do
|
||||
Guard::Notifier.expects(:notify).with('Until next time...', anything)
|
||||
guard.stop
|
||||
end
|
||||
end
|
||||
|
||||
describe '#run_on_change' do
|
||||
it "should run on change" do
|
||||
guard.expects(:run_all).once
|
||||
guard.run_on_change([])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue