remove jammit and rails assets, also ensure files don't run twice

This commit is contained in:
John Bintz 2011-08-05 13:35:06 -04:00
parent 3fb7d8ac24
commit 895ae0c304
3 changed files with 11 additions and 74 deletions

View File

@ -18,13 +18,6 @@ home folder's `.jasmine-headless-webkit` file.
* `:run_before => "<command to run>"` to run a command before running specs. If the command fails, the test run stops. * `:run_before => "<command to run>"` 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. * `: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 ## 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 Use [`guard-rails-assets`](https://github.com/dnagir/guard-rails-assets) chained in before `guard-jasmine-headless-webkit` to precompile your application

View File

@ -47,7 +47,7 @@ module Guard
private private
def filter_paths(paths) def filter_paths(paths)
paths.find_all { |path| File.extname(path)[valid_extensions] } paths.find_all { |path| File.extname(path)[valid_extensions] }.uniq
end end
def valid_extensions def valid_extensions
@ -58,15 +58,6 @@ module Guard
run_a_thing_before(:run_before, @options[:run_before]) run_a_thing_before(:run_before, @options[:run_before])
end 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) def run_a_thing_before(option, *args)
if @options[option] && !@ran_before if @options[option] && !@ran_before
run_program(*args) run_program(*args)
@ -76,7 +67,7 @@ module Guard
end end
def run_all_things_before def run_all_things_before
run_before and run_rails_assets and run_jammit run_before
end end
def run_program(name, command = nil) def run_program(name, command = nil)

View File

@ -27,6 +27,15 @@ describe Guard::JasmineHeadlessWebkit do
end end
describe '#run_on_change' do 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 context 'jhw call fails' do
it "should not run all" do it "should not run all" do
Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(1) Guard::JasmineHeadlessWebkitRunner.expects(:run).returns(1)
@ -93,60 +102,4 @@ describe Guard::JasmineHeadlessWebkit do
end end
end 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 end