diff --git a/README.md b/README.md index 9b2d9c6..14043fb 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/jasmine-headless-webkit b/bin/jasmine-headless-webkit index 2e87b3f..d834287 100755 --- a/bin/jasmine-headless-webkit +++ b/bin/jasmine-headless-webkit @@ -49,7 +49,7 @@ options = { end } -read_defaults_file if defaults_file? +read_defaults_files! opts.each(&@process_options) @spec_filter = ARGV.dup diff --git a/lib/jasmine/cli.rb b/lib/jasmine/cli.rb index 21c39f8..5dedc53 100644 --- a/lib/jasmine/cli.rb +++ b/lib/jasmine/cli.rb @@ -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) - end - - def defaults_file? - File.file?(DEFAULTS_FILE) + 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 end def use_spec?(file) @@ -50,6 +51,11 @@ module Jasmine HTML end + + private + def read_config_file(file) + + end end end diff --git a/spec/lib/jasmine/cli_spec.rb b/spec/lib/jasmine/cli_spec.rb index 0898f29..15d2ff7 100644 --- a/spec/lib/jasmine/cli_spec.rb +++ b/spec/lib/jasmine/cli_spec.rb @@ -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