diff --git a/lib/jasmine/headless/options.rb b/lib/jasmine/headless/options.rb index a6a9f90..e3d324b 100644 --- a/lib/jasmine/headless/options.rb +++ b/lib/jasmine/headless/options.rb @@ -27,7 +27,8 @@ module Jasmine end def initialize(opts = {}) - @options = DEFAULT_OPTIONS.dup.merge(opts) + @options = DEFAULT_OPTIONS.dup + opts.each { |k, v| @options[k] = v if v } end def process_option(*args) diff --git a/lib/jasmine/headless/task.rb b/lib/jasmine/headless/task.rb index 97a5b6b..ed3dfdf 100644 --- a/lib/jasmine/headless/task.rb +++ b/lib/jasmine/headless/task.rb @@ -1,3 +1,5 @@ +require 'jasmine/headless/runner' + module Jasmine module Headless class Task @@ -18,7 +20,11 @@ module Jasmine desc 'Run Jasmine specs headlessly' task name do - system %{jasmine-headless-webkit #{@colors ? "-c" : "--no-colors"} #{@keep_on_error ? "--keep" : ""} #{@jasmine_config ? "-j #{@jasmine_config}" : ""}} + Jasmine::Headless::Runner.run( + :colors => colors, + :remove_html_file => !@keep_on_error, + :jasmine_config => @jasmine_config + ) end end end diff --git a/spec/lib/jasmine/headless/options_spec.rb b/spec/lib/jasmine/headless/options_spec.rb index f85b873..64f0173 100644 --- a/spec/lib/jasmine/headless/options_spec.rb +++ b/spec/lib/jasmine/headless/options_spec.rb @@ -7,9 +7,11 @@ describe Jasmine::Headless::Options do let(:opts) { {} } describe '#initialize' do + let(:default_config) { 'spec/javascripts/support/jasmine.yml' } + context 'empty' do it "should have default options" do - options[:jasmine_config].should == 'spec/javascripts/support/jasmine.yml' + options[:jasmine_config].should == default_config end end @@ -20,6 +22,14 @@ describe Jasmine::Headless::Options do options[:jasmine_config].should == 'test' end end + + context 'with nil provided' do + let(:opts) { { :jasmine_config => nil } } + + it 'should override an option' do + options[:jasmine_config].should == default_config + end + end end describe '#process_option' do diff --git a/spec/lib/jasmine/headless/runner_spec.rb b/spec/lib/jasmine/headless/runner_spec.rb index 3b248e5..bed7f8c 100644 --- a/spec/lib/jasmine/headless/runner_spec.rb +++ b/spec/lib/jasmine/headless/runner_spec.rb @@ -7,7 +7,7 @@ describe Jasmine::Headless::Runner do let(:options) { Jasmine::Headless::Options.new(opts) } describe '#initialize' do - let(:opts) { { :test => 'test' } } + let(:opts) { { :test => 'test', :jasmine_config => nil } } it 'should have default options' do runner.options[:test].should == 'test'