diff --git a/bin/jasmine-headless-webkit b/bin/jasmine-headless-webkit index 121a969..4a72229 100755 --- a/bin/jasmine-headless-webkit +++ b/bin/jasmine-headless-webkit @@ -1,5 +1,7 @@ #!/usr/bin/env ruby +require 'rubygems' + gem_dir = File.expand_path('../..', __FILE__) $:.unshift(File.join(gem_dir, 'lib')) @@ -7,11 +9,9 @@ require 'yaml' require 'fileutils' require 'getoptlong' -require 'rubygems' - -gem 'rainbow' gem 'jasmine' gem 'coffee-script' +gem 'rainbow' require 'jasmine' require 'coffee-script' @@ -41,22 +41,18 @@ options = { :colors => false, :remove_html_file => true } } read_defaults_file if defaults_file? - opts.each(&@process_options) data = YAML.load_file(ARGV.shift || 'spec/javascripts/support/jasmine.yml') -if !File.file?(File.join(gem_dir, 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner')) +if !File.file?(File.join(gem_dir, RUNNER)) puts "The Qt WebKit widget is not compiled! Try re-installing this gem." exit 1 end puts "Running Jasmine specs..." -files = [ - 'file://' + File.join(Jasmine.root, 'lib/jasmine.js'), - 'file://' + File.join(Jasmine.root, 'lib/jasmine-html.js') -] +files = %w{jasmine jasmine-html}.collect { |name| File.join(Jasmine.root, "lib/#{name}.js") } files += [ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].collect do |searches, root| data[searches] ||= DEFAULTS[searches] @@ -89,30 +85,10 @@ files = files.flatten.compact.collect { |file| end } -output = <<-HTML - - - - Jasmine Test Runner - - #{files.join("\n")} - - - - - - - -HTML +output = jasmine_html_template(files) File.open(target = "specrunner.#{$$}.html", 'w') { |fh| fh.print output } -system %{#{File.join(gem_dir, 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner')} #{options[:colors] ? '-c' : ''} #{target}} +system %{#{File.join(gem_dir, RUNNER)} #{options[:colors] ? '-c' : ''} #{target}} status = $?.exitstatus FileUtils.rm_f target if options[:remove_html_file] || (status == 0) diff --git a/lib/jasmine/cli.rb b/lib/jasmine/cli.rb index 809d156..4f4e3c6 100644 --- a/lib/jasmine/cli.rb +++ b/lib/jasmine/cli.rb @@ -9,6 +9,7 @@ module Jasmine 'src_files' => [] } + RUNNER = 'ext/jasmine-webkit-specrunner/jasmine-webkit-specrunner' DEFAULTS_FILE = '.jasmine-headless-webkit' def process_jasmine_config(overrides = {}) @@ -22,6 +23,29 @@ module Jasmine def defaults_file? File.file?(DEFAULTS_FILE) end + + def jasmine_html_template(files) + <<-HTML + + + + Jasmine Test Runner + + #{files.join("\n")} + + + + + + + + HTML + end end end