From 895ae0c3045f61ae6f634b1fc898adffab49b227 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 5 Aug 2011 13:35:06 -0400 Subject: [PATCH] remove jammit and rails assets, also ensure files don't run twice --- README.md | 7 -- lib/guard/jasmine-headless-webkit.rb | 13 +--- .../lib/guard/jasmine-headless-webkit_spec.rb | 65 +++---------------- 3 files changed, 11 insertions(+), 74 deletions(-) diff --git a/README.md b/README.md index c7a9323..97f9e45 100644 --- a/README.md +++ b/README.md @@ -18,13 +18,6 @@ home folder's `.jasmine-headless-webkit` file. * `:run_before => ""` to run a command before running specs. If the command fails, the test run stops. * `:valid_extensions => %w{js coffee}` to only trigger `run_on_change` events for files with these extensions. Forces Guard to re-run all tests when any other matched file changes. -### Deprecated options - -* `:jammit => true` to run `jammit -f 2>/dev/null` before the tests for the current file change are run. - * Use [`guard-jammit`](http://github.com/guard/guard-jammit) instead. -* `:rails_assets => true` to repackage Rails assets before each run. - * Use [`guard-rails-assets`](http://github.com/dnagir/guard-rails-assets) instead. - ## Using with Rails 3.1 and the Asset Pipeline and/or Jammit Use [`guard-rails-assets`](https://github.com/dnagir/guard-rails-assets) chained in before `guard-jasmine-headless-webkit` to precompile your application diff --git a/lib/guard/jasmine-headless-webkit.rb b/lib/guard/jasmine-headless-webkit.rb index 154cb3f..2c5d891 100644 --- a/lib/guard/jasmine-headless-webkit.rb +++ b/lib/guard/jasmine-headless-webkit.rb @@ -47,7 +47,7 @@ module Guard private def filter_paths(paths) - paths.find_all { |path| File.extname(path)[valid_extensions] } + paths.find_all { |path| File.extname(path)[valid_extensions] }.uniq end def valid_extensions @@ -58,15 +58,6 @@ module Guard run_a_thing_before(:run_before, @options[:run_before]) end - def run_jammit - $stderr.puts "Jammit support is deprecated and will be removed in the future. Use guard-jammit instead." if @options[:jammit] - run_a_thing_before(:jammit, "Jammit", %{jammit -f 2>/dev/null}) - end - - def run_rails_assets - run_a_thing_before(:rails_assets, "Rails Assets", %{rake assets:precompile:for_testing}) - end - def run_a_thing_before(option, *args) if @options[option] && !@ran_before run_program(*args) @@ -76,7 +67,7 @@ module Guard end def run_all_things_before - run_before and run_rails_assets and run_jammit + run_before end def run_program(name, command = nil) diff --git a/spec/lib/guard/jasmine-headless-webkit_spec.rb b/spec/lib/guard/jasmine-headless-webkit_spec.rb index b2b2d98..e7d5380 100644 --- a/spec/lib/guard/jasmine-headless-webkit_spec.rb +++ b/spec/lib/guard/jasmine-headless-webkit_spec.rb @@ -27,6 +27,15 @@ describe Guard::JasmineHeadlessWebkit do end describe '#run_on_change' do + context 'two files' do + it "should only run one" do + Guard::JasmineHeadlessWebkitRunner.expects(:run).with(%w{test.js}).returns(1) + guard.expects(:run_all).never + + guard.run_on_change(%w{test.js test.js}) + end + end + context 'jhw call fails' do it "should not run all" do Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(1) @@ -93,60 +102,4 @@ describe Guard::JasmineHeadlessWebkit do end end end - - describe 'run jammit first' do - context 'run on run_all if called first' do - before do - guard.expects(:run_program).once.with('Jammit', regexp_matches(/jammit/)).returns(true) - Guard::JasmineHeadlessWebkitRunner.expects(:run).once - end - - let(:options) { { :jammit => true } } - - it "should run jammit first" do - guard.run_all - end - end - - context 'only run once if run_on_change is successful' do - before do - guard.expects(:run_program).once.with('Jammit', regexp_matches(/jammit/)).returns(true) - Guard::JasmineHeadlessWebkitRunner.expects(:run).once.returns(0) - end - - let(:options) { { :jammit => true } } - - it "should run jammit only once" do - guard.run_on_change(%w{path.js}) - end - end - end - - describe 'run rails_assets first' do - context 'run on run_all if called first' do - before do - guard.expects(:run_program).with('Rails Assets', regexp_matches(/assets:precompile:for_testing/)).once.returns(true) - Guard::JasmineHeadlessWebkitRunner.expects(:run).once - end - - let(:options) { { :rails_assets => true } } - - it "should run rails assets first" do - guard.run_all - end - end - - context 'only run once if run_on_change is successful' do - before do - guard.expects(:run_program).with('Rails Assets', regexp_matches(/assets:precompile:for_testing/)).once.returns(true) - Guard::JasmineHeadlessWebkitRunner.expects(:run).once.returns(0) - end - - let(:options) { { :rails_assets => true } } - - it "should run rails assets only once" do - guard.run_on_change(%w{path.js}) - end - end - end end