diff --git a/bin/jasmine-headless-webkit b/bin/jasmine-headless-webkit index 1b9b28a..98c1998 100755 --- a/bin/jasmine-headless-webkit +++ b/bin/jasmine-headless-webkit @@ -1,19 +1,25 @@ #!/usr/bin/env ruby require 'rubygems' +require 'rainbow' def gem_dir File.expand_path('../..', __FILE__) end $:.unshift(File.join(gem_dir, 'lib')) +require 'jasmine/headless/errors' +require 'jasmine/headless/runner' +require 'jasmine/headless/options' -puts "Running Jasmine specs..." - -require 'jasmine/headless/cli' begin - exit Jasmine::Headless::CLI.run + puts "Running Jasmine specs...".color(:white) + exit Jasmine::Headless::Runner.run(Jasmine::Headless::Options.from_command_line) +rescue CoffeeScript::CompilationError + exit 1 rescue StandardError => e + $stderr.puts "[%s] %s (%s)" % [ "jasmine-headless-webkit".color(:red), e.message.color(:white), e.class.name.color(:yellow) ] + $stderr.puts e.backtrace.collect { |line| " #{line}" }.join("\n") exit 1 end diff --git a/lib/jasmine/files_list.rb b/lib/jasmine/files_list.rb index 11cc53b..ce97cef 100644 --- a/lib/jasmine/files_list.rb +++ b/lib/jasmine/files_list.rb @@ -1,4 +1,13 @@ -require 'jasmine' +begin + require 'jasmine' +rescue NameError => e + if e.message['ActiveSupport::Concern'] + $stderr.puts "[%s] %s (%s)" % [ "jasmine-gem".color(:red), e.message.color(:white), e.class.name.color(:yellow) ] + $stderr.puts "#{'Jasmine'.color(:red)} believes Rails 3 is available. Try using #{'Bundler'.color(:green)} and running via #{'bundle exec'.color(:green)}." + else + raise e + end +end module Jasmine class FilesList diff --git a/lib/jasmine/headless/cli.rb b/lib/jasmine/headless/cli.rb deleted file mode 100644 index 252b323..0000000 --- a/lib/jasmine/headless/cli.rb +++ /dev/null @@ -1,17 +0,0 @@ -require 'jasmine/headless/runner' -require 'jasmine/headless/options' -require 'getoptlong' - -module Jasmine - module Headless - class CLI - def self.run - Runner.run(Options.from_command_line) - rescue NoRunnerError - puts "The Qt WebKit widget is not compiled! Try re-installing this gem." - 1 - end - end - end -end - diff --git a/lib/jasmine/headless/errors.rb b/lib/jasmine/headless/errors.rb index 8f6edb7..fa7e603 100644 --- a/lib/jasmine/headless/errors.rb +++ b/lib/jasmine/headless/errors.rb @@ -1,6 +1,9 @@ module Jasmine module Headless class NoRunnerError < StandardError + def message + "The jasmine-headless-webkit specrunner (jasmine-webkit-specrunner) could not be found! Try reinstalling the gem." + end end end end diff --git a/lib/jasmine/headless/options.rb b/lib/jasmine/headless/options.rb index e3d324b..51cf5cd 100644 --- a/lib/jasmine/headless/options.rb +++ b/lib/jasmine/headless/options.rb @@ -1,4 +1,5 @@ require 'forwardable' +require 'getoptlong' module Jasmine module Headless diff --git a/spec/lib/jasmine/headless/cli_spec.rb b/spec/lib/jasmine/headless/cli_spec.rb deleted file mode 100644 index 8b13789..0000000 --- a/spec/lib/jasmine/headless/cli_spec.rb +++ /dev/null @@ -1 +0,0 @@ -