From cf5cd24d1b2244e3cc7cdaa3f58a67cf89515442 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Wed, 11 May 2011 10:17:27 -0400 Subject: [PATCH] have jasmine config set by argument --- README.md | 3 ++- bin/jasmine-headless-webkit | 16 ++++++++++++---- spec/bin/jasmine-headless-webkit_spec.rb | 6 +++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 3026cdd..abbe71c 100644 --- a/README.md +++ b/README.md @@ -33,13 +33,14 @@ Let me know via a message or in the Issues section if it works on your setup and ## Usage - jasmine-headless-webkit [options] [path to jasmine.yml, defaults to spec/javascripts/support/jasmine.yml] + jasmine-headless-webkit [options] Current supported options: * `-c`/`--colors` enables color output * `--no-colors` disables color output * `--keep` preserves the temporary HTML document if an error occurs in testing +* `-j`/`--jasmine-config` sets the `jasmine.yml` file to load *(defaults to `spec/javascripts/support/jasmine.yml`)* These options can also be placed into a `.jasmine-headless-webkit` file in your project root. diff --git a/bin/jasmine-headless-webkit b/bin/jasmine-headless-webkit index 4a72229..9e7bf80 100755 --- a/bin/jasmine-headless-webkit +++ b/bin/jasmine-headless-webkit @@ -23,13 +23,19 @@ include Jasmine::CLI opts = GetoptLong.new( [ '--colors', '-c', GetoptLong::NO_ARGUMENT ], [ '--no-colors', GetoptLong::NO_ARGUMENT ], - [ '--keep', GetoptLong::NO_ARGUMENT ] + [ '--keep', GetoptLong::NO_ARGUMENT ], + [ '--jasmine-config', '-j', GetoptLong::REQUIRED_ARGUMENT ] ) -options = { :colors => false, :remove_html_file => true } +options = { + :colors => false, + :remove_html_file => true, + :jasmine_config => 'spec/javascripts/support/jasmine.yml' +} @process_options = lambda { |*args| - opt = args.flatten.shift + opt, arg = args.flatten[0..1] + case opt when '--colors', '-c' options[:colors] = true @@ -37,13 +43,15 @@ options = { :colors => false, :remove_html_file => true } options[:colors] = false when '--keep', '-k' options[:remove_html_file] = false + when '--jasmine-config', '-j' + options[:jasmine_config] = arg end } read_defaults_file if defaults_file? opts.each(&@process_options) -data = YAML.load_file(ARGV.shift || 'spec/javascripts/support/jasmine.yml') +data = YAML.load_file(options[:jasmine_config]) if !File.file?(File.join(gem_dir, RUNNER)) puts "The Qt WebKit widget is not compiled! Try re-installing this gem." diff --git a/spec/bin/jasmine-headless-webkit_spec.rb b/spec/bin/jasmine-headless-webkit_spec.rb index 26f4fd8..4d85601 100644 --- a/spec/bin/jasmine-headless-webkit_spec.rb +++ b/spec/bin/jasmine-headless-webkit_spec.rb @@ -3,21 +3,21 @@ require 'spec_helper' describe "jasmine-headless-webkit" do describe 'success' do it "should succeed with error code 0" do - %x{bin/jasmine-headless-webkit spec/jasmine/success/success.yml} + %x{bin/jasmine-headless-webkit -j spec/jasmine/success/success.yml} $?.exitstatus.should == 0 end end describe 'failure' do it "should fail with an error code of 1" do - %x{bin/jasmine-headless-webkit spec/jasmine/failure/failure.yml} + %x{bin/jasmine-headless-webkit -j spec/jasmine/failure/failure.yml} $?.exitstatus.should == 1 end end describe 'with console.log' do it "should succeed, but has a console.log so an error code of 2" do - %x{bin/jasmine-headless-webkit spec/jasmine/console_log/console_log.yml} + %x{bin/jasmine-headless-webkit -j spec/jasmine/console_log/console_log.yml} $?.exitstatus.should == 2 end end