support for faster filtered spec running in JHW 0.3.0

This commit is contained in:
John Bintz 2011-06-10 11:33:27 -04:00
parent 5f147638be
commit b6b2f9d897
5 changed files with 10 additions and 9 deletions

View File

@ -8,3 +8,4 @@ gem 'mocha'
gem 'rake', '0.8.7' gem 'rake', '0.8.7'
gem 'growl' gem 'growl'
gem 'fakefs', :require => nil gem 'fakefs', :require => nil
gem 'jasmine-headless-webkit', :path => '../jasmine-headless-webkit'

View File

@ -1,7 +1,7 @@
# A sample Guardfile # A sample Guardfile
# More info at https://github.com/guard/guard#readme # More info at https://github.com/guard/guard#readme
guard 'rspec', :version => 2 do guard 'rspec', :cli => '-c', :version => 2 do
watch(%r{^spec/.+_spec\.rb}) watch(%r{^spec/.+_spec\.rb})
watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" } watch(%r{^lib/(.+)\.rb}) { |m| "spec/lib/#{m[1]}_spec.rb" }
watch('spec/spec_helper.rb') { "spec" } watch('spec/spec_helper.rb') { "spec" }

View File

@ -19,6 +19,6 @@ Gem::Specification.new do |s|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"] s.require_paths = ["lib"]
s.add_dependency 'guard', '>= 0.2.2' s.add_dependency 'guard', '>= 0.4.0'
s.add_dependency 'jasmine-headless-webkit', '>= 0.2.2' s.add_dependency 'jasmine-headless-webkit', '>= 0.3.0'
end end

View File

@ -30,11 +30,11 @@ module Guard
@ran_jammit = false @ran_jammit = false
if run_before and run_jammit if run_before and run_jammit
@ran_jammit = true @ran_jammit = true
do_run_all = true
if !paths.empty? if !paths.empty?
do_run_all = (JasmineHeadlessWebkitRunner.run(paths) == 0) JasmineHeadlessWebkitRunner.run(paths)
else
run_all
end end
run_all if do_run_all
end end
end end

View File

@ -36,10 +36,10 @@ describe Guard::JasmineHeadlessWebkit do
end end
end end
context 'succeed, run all' do context 'succeed, but still do not run all' do
it "should run all" do it "should run all" do
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(0) Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(0)
guard.expects(:run_all).once guard.expects(:run_all).never
guard.run_on_change(%w{test.js}) guard.run_on_change(%w{test.js})
end end
@ -109,7 +109,7 @@ describe Guard::JasmineHeadlessWebkit do
context 'only run once if run_on_change is successful' do context 'only run once if run_on_change is successful' do
before do before do
guard.expects(:run_program).once.returns(true) guard.expects(:run_program).once.returns(true)
Guard::JasmineHeadlessWebkitRunner.expects(:run).twice.returns(0) Guard::JasmineHeadlessWebkitRunner.expects(:run).once.returns(0)
end end
let(:options) { { :jammit => true } } let(:options) { { :jammit => true } }