requisite pre-release code cleanup

This commit is contained in:
John Bintz 2011-05-09 15:52:11 -04:00
parent 3d51cecf03
commit f6f975a8c9
4 changed files with 34 additions and 8 deletions

View File

@ -5,4 +5,4 @@ gemspec
gem 'rspec' gem 'rspec'
gem 'autotest' gem 'autotest'
gem 'fakefs', :require => nil

View File

@ -27,8 +27,8 @@ opts = GetoptLong.new(
options = { :colors => false } options = { :colors => false }
process_options = lambda { |*args| @process_options = lambda { |*args|
opt = args.shift opt = args.flatten.shift
case opt case opt
when '--colors', '-c' when '--colors', '-c'
options[:colors] = true options[:colors] = true
@ -37,11 +37,9 @@ process_options = lambda { |*args|
end end
} }
if File.file?('.jasmine-headless-webkit') read_defaults_file if defaults_file?
File.readlines('.jasmine-headless-webkit').collect { |line| line.strip.split(' ', 2) }.flatten(1).each(&process_options)
end
opts.each(&process_options) opts.each(&@process_options)
data = YAML.load_file(ARGV.shift || 'spec/javascripts/support/jasmine.yml') data = YAML.load_file(ARGV.shift || 'spec/javascripts/support/jasmine.yml')

View File

@ -9,9 +9,19 @@ module Jasmine
'src_files' => [] 'src_files' => []
} }
DEFAULTS_FILE = '.jasmine-headless-webkit'
def process_jasmine_config(overrides = {}) def process_jasmine_config(overrides = {})
DEFAULTS.merge(overrides) DEFAULTS.merge(overrides)
end 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)
end
end end
end end

View File

@ -1,8 +1,10 @@
require 'spec_helper' require 'spec_helper'
require 'jasmine/cli' require 'jasmine/cli'
require 'fakefs/spec_helpers'
describe Jasmine::CLI do describe Jasmine::CLI do
include Jasmine::CLI include Jasmine::CLI
include FakeFS::SpecHelpers
describe '#process_jasmine_config' do describe '#process_jasmine_config' do
context 'without overrides' do context 'without overrides' do
@ -38,7 +40,23 @@ describe Jasmine::CLI do
end end
end end
describe '#get_files' do describe '#read_defaults_file' do
let(:test_data) { %w{first second} }
before do
File.open(DEFAULTS_FILE, 'w') { |fh| fh.puts test_data.join(' ') }
end
it "should read the options" do
found = false
@process_options = lambda { |*args|
found = true if args.flatten == test_data
}
read_defaults_file
found.should be_true
end
end end
end end