pass other options into jhw
This commit is contained in:
parent
c2a3635083
commit
9b6cb02d06
|
@ -12,13 +12,18 @@ module Guard
|
|||
|
||||
attr_reader :files_to_rerun
|
||||
|
||||
DEFAULT_OPTIONS = {
|
||||
:all_on_start => true,
|
||||
:run_before => false,
|
||||
:valid_extensions => DEFAULT_EXTENSIONS
|
||||
}
|
||||
|
||||
def initialize(watchers = [], options = {})
|
||||
super
|
||||
@options = {
|
||||
:all_on_start => true,
|
||||
:run_before => false,
|
||||
:valid_extensions => DEFAULT_EXTENSIONS
|
||||
}.merge(options)
|
||||
|
||||
@options = DEFAULT_OPTIONS.merge(options)
|
||||
@filtered_options = options
|
||||
DEFAULT_OPTIONS.keys.each { |key| @filtered_options.delete(key) }
|
||||
|
||||
UI.deprecation ":run_before is deprecated. Use guard-shell to do something beforehand. This will be removed in a future release." if @options[:run_before]
|
||||
|
||||
|
@ -68,7 +73,7 @@ module Guard
|
|||
UI.info(SOME_SPECS_MESSAGE % paths.join(' '))
|
||||
end
|
||||
|
||||
if failed_files = JasmineHeadlessWebkitRunner.run(paths)
|
||||
if failed_files = JasmineHeadlessWebkitRunner.run(paths, @filtered_options)
|
||||
@files_to_rerun = failed_files
|
||||
end
|
||||
|
||||
|
|
|
@ -4,11 +4,13 @@ require 'jasmine-headless-webkit'
|
|||
module Guard
|
||||
class JasmineHeadlessWebkitRunner
|
||||
class << self
|
||||
def run(paths = [])
|
||||
def run(paths = [], options = {})
|
||||
file = Tempfile.new('guard-jasmine-headless-webkit')
|
||||
file.close
|
||||
|
||||
Jasmine::Headless::Runner.run(:report => file.path, :colors => true, :files => paths)
|
||||
options.merge!(:report => file.path, :colors => true, :files => paths)
|
||||
|
||||
Jasmine::Headless::Runner.run(options)
|
||||
|
||||
notify(file.path)
|
||||
end
|
||||
|
|
|
@ -3,6 +3,14 @@ require 'guard/jasmine-headless-webkit/runner'
|
|||
require 'fakefs/spec_helpers'
|
||||
|
||||
describe Guard::JasmineHeadlessWebkitRunner do
|
||||
describe '.run' do
|
||||
it 'should pass along options' do
|
||||
Jasmine::Headless::Runner.expects(:run).with(has_key(:full_run))
|
||||
|
||||
Guard::JasmineHeadlessWebkitRunner.run([], :full_run => false)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.notify' do
|
||||
include FakeFS::SpecHelpers
|
||||
|
||||
|
|
|
@ -57,6 +57,16 @@ describe Guard::JasmineHeadlessWebkit do
|
|||
guard.files_to_rerun.should == []
|
||||
end
|
||||
end
|
||||
|
||||
context 'pass along jhw options' do
|
||||
let(:options) { { :all_on_start => false, :full_run => false } }
|
||||
|
||||
it 'should only pass along jhw options' do
|
||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with([], :full_run => false)
|
||||
|
||||
guard.run_all
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#run_on_change' do
|
||||
|
@ -64,7 +74,7 @@ describe Guard::JasmineHeadlessWebkit do
|
|||
|
||||
context 'two files' do
|
||||
it "should only run one" do
|
||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file).returns(one_file)
|
||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file, {}).returns(one_file)
|
||||
|
||||
guard.run_on_change(%w{test.js test.js}).should be_false
|
||||
guard.files_to_rerun.should == one_file
|
||||
|
@ -83,7 +93,7 @@ describe Guard::JasmineHeadlessWebkit do
|
|||
context 'one file one prior' do
|
||||
it "should not run all" do
|
||||
guard.instance_variable_set(:@files_to_rerun, [ "two.js" ])
|
||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file + [ "two.js" ]).returns(one_file)
|
||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file + [ "two.js" ], {}).returns(one_file)
|
||||
|
||||
guard.run_on_change(one_file).should be_false
|
||||
guard.files_to_rerun.should == one_file
|
||||
|
@ -93,7 +103,7 @@ describe Guard::JasmineHeadlessWebkit do
|
|||
context 'failed hard' do
|
||||
it "should not run all" do
|
||||
guard.instance_variable_set(:@files_to_rerun, one_file)
|
||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file).returns(nil)
|
||||
Guard::JasmineHeadlessWebkitRunner.expects(:run).with(one_file, {}).returns(nil)
|
||||
|
||||
guard.run_on_change(one_file).should be_false
|
||||
guard.files_to_rerun.should == one_file
|
||||
|
|
Loading…
Reference in New Issue