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.
|
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
|
### CoffeeScript Support
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ options = {
|
|||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
read_defaults_file if defaults_file?
|
read_defaults_files!
|
||||||
opts.each(&@process_options)
|
opts.each(&@process_options)
|
||||||
@spec_filter = ARGV.dup
|
@spec_filter = ARGV.dup
|
||||||
|
|
||||||
|
@ -11,17 +11,18 @@ module Jasmine
|
|||||||
|
|
||||||
RUNNER = 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner'
|
RUNNER = 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner'
|
||||||
DEFAULTS_FILE = '.jasmine-headless-webkit'
|
DEFAULTS_FILE = '.jasmine-headless-webkit'
|
||||||
|
GLOBAL_DEFAULTS_FILE = File.expand_path("~/#{DEFAULTS_FILE}")
|
||||||
|
|
||||||
def process_jasmine_config(overrides = {})
|
def process_jasmine_config(overrides = {})
|
||||||
DEFAULTS.merge(overrides)
|
DEFAULTS.merge(overrides)
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_defaults_file
|
def read_defaults_files!
|
||||||
File.readlines(DEFAULTS_FILE).collect { |line| line.strip.split(' ', 2) }.each(&@process_options)
|
[ 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
|
end
|
||||||
|
|
||||||
def defaults_file?
|
|
||||||
File.file?(DEFAULTS_FILE)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def use_spec?(file)
|
def use_spec?(file)
|
||||||
@ -50,6 +51,11 @@ module Jasmine
|
|||||||
</html>
|
</html>
|
||||||
HTML
|
HTML
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
def read_config_file(file)
|
||||||
|
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -41,22 +41,21 @@ describe Jasmine::CLI do
|
|||||||
end
|
end
|
||||||
|
|
||||||
describe '#read_defaults_file' do
|
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
|
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(' ') }
|
File.open(DEFAULTS_FILE, 'w') { |fh| fh.puts test_data.join(' ') }
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should read the options" do
|
it "should read the options" do
|
||||||
found = false
|
all_data = []
|
||||||
|
@process_options = lambda { |*args| all_data << args.flatten }
|
||||||
|
|
||||||
@process_options = lambda { |*args|
|
read_defaults_files!
|
||||||
found = true if args.flatten == test_data
|
|
||||||
}
|
|
||||||
|
|
||||||
read_defaults_file
|
all_data.should == [ global_test_data, test_data ]
|
||||||
|
|
||||||
found.should be_true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user