From 829d2d2187e41555005b7ba6c54a5aa3e0a733cf Mon Sep 17 00:00:00 2001 From: John Bintz Date: Tue, 3 May 2011 09:55:42 -0400 Subject: [PATCH] make autotest integration better, and provide for default options using .jasmine-headless-webkit --- README.md | 21 +++++++++++++-------- bin/jasmine-headless-webkit | 18 +++++++++++++----- lib/autotest/discover.rb | 2 +- lib/autotest/jasmine_mixin.rb | 2 +- 4 files changed, 28 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 2a74efb..39a980c 100644 --- a/README.md +++ b/README.md @@ -19,14 +19,6 @@ serialize. `gem install jasmine-headless-webkit` or use Bundler. -## Usage - - jasmine-headless-webkit [options] [path to jasmine.yml, defaults to spec/javascripts/support/jasmine.yml] - -Current supported options: - -* `-c` enables color output - Installation requires Qt 4.7. See [senchalabs/examples](https://github.com/senchalabs/examples) and [my fork of examples](https://github.com/johnbintz/examples) for more information on the QtWebKit runner. @@ -35,12 +27,25 @@ Tested in the following environments: * Mac OS X 10.6, with MacPorts Qt and Nokia Qt.mpkg * Kubuntu 10.10 +## Usage + + jasmine-headless-webkit [options] [path to jasmine.yml, defaults to spec/javascripts/support/jasmine.yml] + +Current supported options: + +* `-c` enables color output + +These options can also be placed into a `.jasmine-headless-webkit` file in your project root. + ### Autotest Integration `jasmine-headless-webkit` can integrate with Autotest. Your `jasmine.yml` file needs to be in the default path, and you have to be ready to use a very alpha implementation of the feature. If used with RSpec 2, Jasmine tests run after RSpec tests. +You need to create a `.jasmine-headless-webkit` file in your project root for this integration +to work. + ### Server Interaction `jasmine-headless-webkit` works the same as if you create an HTML file, manually load the Jasmine library and diff --git a/bin/jasmine-headless-webkit b/bin/jasmine-headless-webkit index 421da7b..1e4266b 100755 --- a/bin/jasmine-headless-webkit +++ b/bin/jasmine-headless-webkit @@ -8,14 +8,22 @@ opts = GetoptLong.new( [ '--colors', '-c', GetoptLong::NO_ARGUMENT ] ) -colors = false -opts.each do |opt, arg| +options = { :colors => false } + +process_options = lambda { |*args| + opt = args.shift case opt - when '--colors' - colors = true + when '--colors', '-c' + options[:colors] = true end +} + +if File.file?('.jasmine-headless-webkit') + File.readlines('.jasmine-headless-webkit').collect { |line| line.strip.split(' ', 2) }.flatten(1).each(&process_options) end +opts.each(&process_options) + data = YAML.load_file(ARGV.shift || 'spec/javascripts/support/jasmine.yml') gem_dir = File.expand_path('../..', __FILE__) @@ -78,7 +86,7 @@ window.console = { log: function(data) { debug.log(JSON.stringify(data)); } }; HTML File.open(target = "specrunner.#{$$}.html", 'w') { |fh| fh.print output } -system %{#{File.join(gem_dir, 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner')} #{colors ? '-c' : ''} #{target}} +system %{#{File.join(gem_dir, 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner')} #{options[:colors] ? '-c' : ''} #{target}} status = $?.exitstatus FileUtils.rm_f target diff --git a/lib/autotest/discover.rb b/lib/autotest/discover.rb index c609b68..13f70bc 100644 --- a/lib/autotest/discover.rb +++ b/lib/autotest/discover.rb @@ -1 +1 @@ -Autotest.add_discovery { 'jasmine' if File.file?('./spec/javascripts/support/jasmine.yml') } +Autotest.add_discovery { 'jasmine' if File.file?('./.jasmine-headless-webkit') } diff --git a/lib/autotest/jasmine_mixin.rb b/lib/autotest/jasmine_mixin.rb index f85b119..c4edea8 100644 --- a/lib/autotest/jasmine_mixin.rb +++ b/lib/autotest/jasmine_mixin.rb @@ -73,7 +73,7 @@ module JasmineMixin end def make_jasmine_cmd - "#{JASMINE_PROGRAM} -c" + "#{JASMINE_PROGRAM}" end def setup_jasmine_project_mappings