add global options
This commit is contained in:
parent
9715eb3a2e
commit
aa11f442bc
@ -44,7 +44,8 @@ Current supported options:
|
||||
|
||||
If provided, only the requested spec files will be executed. Otherwise, all matching specs will be run.
|
||||
|
||||
These options can also be placed into a `.jasmine-headless-webkit` file in your project root.
|
||||
These options can also be placed into a `.jasmine-headless-webkit` file in your project root, or into a
|
||||
`.jasmine-headless-webkit` file in your home directory. Project level options override global options.
|
||||
|
||||
### CoffeeScript Support
|
||||
|
||||
|
@ -49,7 +49,7 @@ options = {
|
||||
end
|
||||
}
|
||||
|
||||
read_defaults_file if defaults_file?
|
||||
read_defaults_files!
|
||||
opts.each(&@process_options)
|
||||
@spec_filter = ARGV.dup
|
||||
|
||||
|
@ -11,17 +11,18 @@ module Jasmine
|
||||
|
||||
RUNNER = 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner'
|
||||
DEFAULTS_FILE = '.jasmine-headless-webkit'
|
||||
GLOBAL_DEFAULTS_FILE = File.expand_path("~/#{DEFAULTS_FILE}")
|
||||
|
||||
def process_jasmine_config(overrides = {})
|
||||
DEFAULTS.merge(overrides)
|
||||
end
|
||||
|
||||
def read_defaults_file
|
||||
File.readlines(DEFAULTS_FILE).collect { |line| line.strip.split(' ', 2) }.each(&@process_options)
|
||||
def read_defaults_files!
|
||||
[ GLOBAL_DEFAULTS_FILE, DEFAULTS_FILE ].each do |file|
|
||||
if File.file?(file)
|
||||
File.readlines(file).collect { |line| line.strip.split(' ', 2) }.each(&@process_options)
|
||||
end
|
||||
end
|
||||
|
||||
def defaults_file?
|
||||
File.file?(DEFAULTS_FILE)
|
||||
end
|
||||
|
||||
def use_spec?(file)
|
||||
@ -50,6 +51,11 @@ module Jasmine
|
||||
</html>
|
||||
HTML
|
||||
end
|
||||
|
||||
private
|
||||
def read_config_file(file)
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -41,22 +41,21 @@ describe Jasmine::CLI do
|
||||
end
|
||||
|
||||
describe '#read_defaults_file' do
|
||||
let(:test_data) { %w{first second} }
|
||||
let(:global_test_data) { %w{first second} }
|
||||
let(:test_data) { %w{third fourth} }
|
||||
|
||||
before do
|
||||
File.open(GLOBAL_DEFAULTS_FILE, 'w') { |fh| fh.puts global_test_data.join(' ') }
|
||||
File.open(DEFAULTS_FILE, 'w') { |fh| fh.puts test_data.join(' ') }
|
||||
end
|
||||
|
||||
it "should read the options" do
|
||||
found = false
|
||||
all_data = []
|
||||
@process_options = lambda { |*args| all_data << args.flatten }
|
||||
|
||||
@process_options = lambda { |*args|
|
||||
found = true if args.flatten == test_data
|
||||
}
|
||||
read_defaults_files!
|
||||
|
||||
read_defaults_file
|
||||
|
||||
found.should be_true
|
||||
all_data.should == [ global_test_data, test_data ]
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user