better errors and flatten jasmine.yml keys, allowing for merged yaml sequences in config
This commit is contained in:
parent
88d1b7f1d2
commit
dc5b8c026d
@ -123,7 +123,7 @@ module Jasmine
|
||||
data = @options[:config].dup
|
||||
[ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].each do |searches, root|
|
||||
if data[searches]
|
||||
data[searches].collect do |search|
|
||||
data[searches].flatten.collect do |search|
|
||||
path = search
|
||||
path = File.join(data[root], path) if data[root]
|
||||
found_files = Dir[path] - @files
|
||||
|
@ -8,6 +8,8 @@ module Jasmine
|
||||
|
||||
class TestFailure < StandardError; end
|
||||
class ConsoleLogUsage < StandardError ; end
|
||||
|
||||
class JasmineConfigNotFound < Errno::ENOENT ; end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -46,6 +46,8 @@ module Jasmine
|
||||
end
|
||||
|
||||
def jasmine_config
|
||||
raise JasmineConfigNotFound.new("Jasmine config not found. I tried #{@options[:jasmine_config]}.") if !File.file?(@options[:jasmine_config])
|
||||
|
||||
@jasmine_config ||= JASMINE_DEFAULTS.dup.merge(YAML.load_file(@options[:jasmine_config]))
|
||||
end
|
||||
|
||||
|
@ -38,6 +38,19 @@ describe Jasmine::FilesList do
|
||||
end
|
||||
end
|
||||
|
||||
shared_examples_for :reading_data do
|
||||
it 'should read the data from the jasmine.yml file and add the files' do
|
||||
files_list.files.should == Jasmine::FilesList::DEFAULT_FILES + [
|
||||
File.expand_path(first_file),
|
||||
File.expand_path(src_file),
|
||||
File.expand_path(stylesheet_file),
|
||||
File.expand_path(helper_file),
|
||||
File.expand_path(spec_file)
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
context 'with normal list' do
|
||||
let(:config) { {
|
||||
'src_dir' => src_dir,
|
||||
'spec_dir' => spec_dir,
|
||||
@ -47,14 +60,20 @@ describe Jasmine::FilesList do
|
||||
'stylesheets' => [ 'stylesheet/*.css' ]
|
||||
} }
|
||||
|
||||
it 'should read the data from the jasmine.yml file and add the files' do
|
||||
files_list.files.should == Jasmine::FilesList::DEFAULT_FILES + [
|
||||
File.expand_path(first_file),
|
||||
File.expand_path(src_file),
|
||||
File.expand_path(stylesheet_file),
|
||||
File.expand_path(helper_file),
|
||||
File.expand_path(spec_file)
|
||||
]
|
||||
it_should_behave_like :reading_data
|
||||
end
|
||||
|
||||
context 'with multidimensional list' do
|
||||
let(:config) { {
|
||||
'src_dir' => src_dir,
|
||||
'spec_dir' => spec_dir,
|
||||
'src_files' => [ [ 'js/first_file.js', 'js/*.js' ] ],
|
||||
'spec_files' => [ '*_spec.js' ],
|
||||
'helpers' => [ 'helper/*.js' ],
|
||||
'stylesheets' => [ 'stylesheet/*.css' ]
|
||||
} }
|
||||
|
||||
it_should_behave_like :reading_data
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -18,11 +18,17 @@ describe Jasmine::Headless::Runner do
|
||||
describe '#load_config' do
|
||||
include FakeFS::SpecHelpers
|
||||
|
||||
let(:opts) { { :jasmine_config => 'test.yml' } }
|
||||
before do
|
||||
File.open('ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner', 'w')
|
||||
end
|
||||
|
||||
let(:config_filename) { 'test.yml' }
|
||||
let(:opts) { { :jasmine_config => config_filename } }
|
||||
|
||||
context 'file exists' do
|
||||
before do
|
||||
File.open(Jasmine::Headless::Runner::RUNNER, 'w')
|
||||
File.open('test.yml', 'w') { |fh| fh.print YAML.dump('test' => 'hello') }
|
||||
File.open(config_filename, 'w') { |fh| fh.print YAML.dump('test' => 'hello') }
|
||||
end
|
||||
|
||||
it 'should load the jasmine config' do
|
||||
@ -31,6 +37,13 @@ describe Jasmine::Headless::Runner do
|
||||
end
|
||||
end
|
||||
|
||||
context 'file does not exist' do
|
||||
it 'should raise an exception' do
|
||||
expect { runner.jasmine_config }.to raise_error(Jasmine::Headless::JasmineConfigNotFound, /#{config_filename}/)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#jasmine_command' do
|
||||
let(:opts) { {
|
||||
:colors => true,
|
||||
|
Loading…
Reference in New Issue
Block a user