have jasmine config set by argument

This commit is contained in:
John Bintz 2011-05-11 10:17:27 -04:00
parent 1c1691f40f
commit cf5cd24d1b
3 changed files with 17 additions and 8 deletions

View File

@ -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.

View File

@ -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."

View File

@ -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