From 894b979674f9d0ea9ad38a6f84cc9b91063ba905 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Mon, 24 Oct 2011 11:48:41 -0400 Subject: [PATCH] merge jasmine.yml keys the same way as the gem --- lib/jasmine/headless/runner.rb | 15 +++++++++++++-- spec/lib/jasmine/headless/runner_spec.rb | 12 ++++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/jasmine/headless/runner.rb b/lib/jasmine/headless/runner.rb index e2667d1..c82a30d 100644 --- a/lib/jasmine/headless/runner.rb +++ b/lib/jasmine/headless/runner.rb @@ -45,9 +45,13 @@ module Jasmine end def jasmine_config - raise JasmineConfigNotFound.new("Jasmine config not found. I tried #{@options[:jasmine_config]}.") if !File.file?(@options[:jasmine_config]) + return @jasmine_config if @jasmine_config - @jasmine_config ||= JASMINE_DEFAULTS.dup.merge(YAML.load_file(@options[:jasmine_config])) + @jasmine_config = JASMINE_DEFAULTS.dup + jasmine_config_data.each do |key, value| + @jasmine_config[key] = value if value + end + @jasmine_config end def jasmine_command(*targets) @@ -88,6 +92,13 @@ module Jasmine end end end + + private + def jasmine_config_data + raise JasmineConfigNotFound.new("Jasmine config not found. I tried #{@options[:jasmine_config]}.") if !File.file?(@options[:jasmine_config]) + + YAML.load_file(@options[:jasmine_config]) + end end end end diff --git a/spec/lib/jasmine/headless/runner_spec.rb b/spec/lib/jasmine/headless/runner_spec.rb index a07fa26..6c2787c 100644 --- a/spec/lib/jasmine/headless/runner_spec.rb +++ b/spec/lib/jasmine/headless/runner_spec.rb @@ -155,4 +155,16 @@ describe Jasmine::Headless::Runner do end end end + + describe '#jasmine_config' do + let(:opts) { {} } + + before do + runner.stubs(:jasmine_config_data).returns('spec_files' => nil) + end + + it 'should not merge in things with nil values' do + runner.jasmine_config['spec_files'].should == described_class::JASMINE_DEFAULTS['spec_files'] + end + end end