diff --git a/lib/jasmine/headless/files_list.rb b/lib/jasmine/headless/files_list.rb index f49ac2e..f4f066b 100644 --- a/lib/jasmine/headless/files_list.rb +++ b/lib/jasmine/headless/files_list.rb @@ -47,16 +47,13 @@ module Jasmine::Headless end end - begin - require 'bundler' + if ENV['JHW_ENV'] + begin + require 'bundler' - envs = [ :default ] - %w{JHW_ENV RAILS_ENV RACK_ENV RAILS_GROUPS}.each do |env| - envs << ENV[env].to_sym if ENV[env] + Bundler.require(ENV['JHW_ENV'].to_sym) + rescue LoadError end - - Bundler.require(*envs) - rescue LoadError end # ...and unregister ones we don't want/need diff --git a/lib/jasmine/headless/options.rb b/lib/jasmine/headless/options.rb index d62da56..a228dd6 100644 --- a/lib/jasmine/headless/options.rb +++ b/lib/jasmine/headless/options.rb @@ -17,7 +17,10 @@ module Jasmine :do_list => false, :full_run => true, :enable_cache => true, - :files => [] + :files => [], + :reporters => [ + [ 'HeadlessConsoleReporter' ] + ] } DEFAULTS_FILE = File.join(Dir.pwd, '.jasmine-headless-webkit') @@ -64,6 +67,10 @@ module Jasmine @options[:do_list] = true when '--seed' @options[:seed] = arg.to_i + when '--format', '-f' + add_reporter(arg) + when '--out' + @options[:reporters].last << arg end end @@ -80,18 +87,47 @@ module Jasmine [ '--colors', '-c', GetoptLong::NO_ARGUMENT ], [ '--no-colors', GetoptLong::NO_ARGUMENT ], [ '--cache', GetoptLong::NO_ARGUMENT ], - [ '--no-t stcache', GetoptLong::NO_ARGUMENT ], + [ '--no-cache', GetoptLong::NO_ARGUMENT ], [ '--keep', GetoptLong::NO_ARGUMENT ], [ '--runner-out', GetoptLong::REQUIRED_ARGUMENT ], [ '--report', GetoptLong::REQUIRED_ARGUMENT ], [ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ], [ '--no-full-run', 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) } 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 diff --git a/spec/lib/jasmine/headless/options_spec.rb b/spec/lib/jasmine/headless/options_spec.rb index 237423d..8494681 100644 --- a/spec/lib/jasmine/headless/options_spec.rb +++ b/spec/lib/jasmine/headless/options_spec.rb @@ -110,6 +110,45 @@ describe Jasmine::Headless::Options do 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 ARGV.replace(@argv) end