jasmine-headless-webkit/spec/lib/jasmine/cli_spec.rb

62 lines
1.6 KiB
Ruby
Raw Normal View History

2011-05-06 18:05:15 +00:00
require 'spec_helper'
require 'jasmine/cli'
2011-05-09 19:52:11 +00:00
require 'fakefs/spec_helpers'
2011-05-06 18:05:15 +00:00
describe Jasmine::CLI do
include Jasmine::CLI
2011-05-09 19:52:11 +00:00
include FakeFS::SpecHelpers
2011-05-06 18:05:15 +00:00
describe '#process_jasmine_config' do
context 'without overrides' do
let(:config) { {} }
it "should just return the defaults" do
process_jasmine_config(config).should == {
'src_files' => [],
'stylesheets' => [],
'helpers' => [ 'helpers/**/*.js' ],
'spec_files' => [ '**/*[sS]pec.js' ],
'src_dir' => nil,
2011-05-06 18:05:15 +00:00
'spec_dir' => 'spec/javascripts'
}
end
end
context 'with overrides' do
let(:config) {
{
'src_files' => [ 'one', 'two' ],
'src_dir' => 'this-dir',
'stylesheets' => [ 'three', 'four' ],
'helpers' => [ 'five', 'six' ],
'spec_files' => [ 'seven', 'eight' ],
'spec_dir' => 'that-dir'
}
}
it "should return the merged data" do
process_jasmine_config(config).should == config
end
end
end
2011-05-09 19:52:11 +00:00
describe '#read_defaults_file' do
2011-05-16 21:19:44 +00:00
let(:global_test_data) { %w{first second} }
let(:test_data) { %w{third fourth} }
2011-05-06 18:05:15 +00:00
2011-05-09 19:52:11 +00:00
before do
2011-06-07 19:04:11 +00:00
File.open(Jasmine::CLI::GLOBAL_DEFAULTS_FILE, 'w') { |fh| fh.puts global_test_data.join(' ') }
File.open(Jasmine::CLI::DEFAULTS_FILE, 'w') { |fh| fh.puts test_data.join(' ') }
2011-05-09 19:52:11 +00:00
end
it "should read the options" do
2011-05-16 21:19:44 +00:00
all_data = []
@process_options = lambda { |*args| all_data << args.flatten }
2011-05-09 19:52:11 +00:00
2011-05-16 21:19:44 +00:00
read_defaults_files!
2011-05-09 19:52:11 +00:00
2011-05-16 21:19:44 +00:00
all_data.should == [ global_test_data, test_data ]
2011-05-09 19:52:11 +00:00
end
2011-05-06 18:05:15 +00:00
end
end