things in a weird state...

This commit is contained in:
John Bintz 2011-12-29 09:32:27 -05:00
parent 9ff0dca191
commit 9dafb83892
3 changed files with 83 additions and 11 deletions

View File

@ -47,17 +47,14 @@ module Jasmine::Headless
end end
end end
if ENV['JHW_ENV']
begin begin
require 'bundler' require 'bundler'
envs = [ :default ] Bundler.require(ENV['JHW_ENV'].to_sym)
%w{JHW_ENV RAILS_ENV RACK_ENV RAILS_GROUPS}.each do |env|
envs << ENV[env].to_sym if ENV[env]
end
Bundler.require(*envs)
rescue LoadError rescue LoadError
end end
end
# ...and unregister ones we don't want/need # ...and unregister ones we don't want/need
Sprockets.instance_eval do Sprockets.instance_eval do

View File

@ -17,7 +17,10 @@ module Jasmine
:do_list => false, :do_list => false,
:full_run => true, :full_run => true,
:enable_cache => true, :enable_cache => true,
:files => [] :files => [],
:reporters => [
[ 'HeadlessConsoleReporter' ]
]
} }
DEFAULTS_FILE = File.join(Dir.pwd, '.jasmine-headless-webkit') DEFAULTS_FILE = File.join(Dir.pwd, '.jasmine-headless-webkit')
@ -64,6 +67,10 @@ module Jasmine
@options[:do_list] = true @options[:do_list] = true
when '--seed' when '--seed'
@options[:seed] = arg.to_i @options[:seed] = arg.to_i
when '--format', '-f'
add_reporter(arg)
when '--out'
@options[:reporters].last << arg
end end
end end
@ -80,18 +87,47 @@ module Jasmine
[ '--colors', '-c', GetoptLong::NO_ARGUMENT ], [ '--colors', '-c', GetoptLong::NO_ARGUMENT ],
[ '--no-colors', GetoptLong::NO_ARGUMENT ], [ '--no-colors', GetoptLong::NO_ARGUMENT ],
[ '--cache', GetoptLong::NO_ARGUMENT ], [ '--cache', GetoptLong::NO_ARGUMENT ],
[ '--no-t stcache', GetoptLong::NO_ARGUMENT ], [ '--no-cache', GetoptLong::NO_ARGUMENT ],
[ '--keep', GetoptLong::NO_ARGUMENT ], [ '--keep', GetoptLong::NO_ARGUMENT ],
[ '--runner-out', GetoptLong::REQUIRED_ARGUMENT ], [ '--runner-out', GetoptLong::REQUIRED_ARGUMENT ],
[ '--report', GetoptLong::REQUIRED_ARGUMENT ], [ '--report', GetoptLong::REQUIRED_ARGUMENT ],
[ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ], [ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ],
[ '--no-full-run', GetoptLong::NO_ARGUMENT ], [ '--no-full-run', GetoptLong::NO_ARGUMENT ],
[ '--list', '-l', GetoptLong::NO_ARGUMENT ], [ '--list', '-l', GetoptLong::NO_ARGUMENT ],
[ '--seed', GetoptLong::REQUIRED_ARGUMENT ] [ '--seed', GetoptLong::REQUIRED_ARGUMENT ],
[ '--format', '-f', GetoptLong::REQUIRED_ARGUMENT ],
[ '--out', GetoptLong::REQUIRED_ARGUMENT ]
) )
command_line_args.each { |*args| process_option(*args) } command_line_args.each { |*args| process_option(*args) }
end end
def reporters
file_index = 0
@options[:reporters].collect do |reporter, file|
output = [ reporter ]
if file
output << "report:#{file_index}"
output << file
file_index += 1
else
output << "stdout"
end
output
end
end
private
def add_reporter(name)
if !@added_reporter
@options[:reporters] = []
@added_reporter = true
end
@options[:reporters] << [ name ]
end
end end
end end
end end

View File

@ -110,6 +110,45 @@ describe Jasmine::Headless::Options do
end end
end end
let(:test_reporter) { 'TestReporter' }
let(:file) { 'file' }
context 'no reporters' do
it 'should have the default reporter' do
options[:reporters].should == [ [ 'HeadlessConsoleReporter' ] ]
end
end
context 'one reporter' do
context 'stdout' do
before do
ARGV.replace([ "--format", test_reporter ])
end
it 'should have the new reporter on stdout' do
options[:reporters].should == [ [ test_reporter ] ]
options.reporters.should == [ [ test_reporter, 'stdout' ] ]
end
end
context 'file' do
before do
ARGV.replace([ "--format", test_reporter, '--out', file ])
end
it 'should have the new reporter on stdout' do
options[:reporters].should == [ [ test_reporter, file ] ]
options.reporters.should == [ [ test_reporter, 'report:0', file ] ]
end
end
end
context 'two reporters' do
end
after do after do
ARGV.replace(@argv) ARGV.replace(@argv)
end end