fix other half of #19, better error reporting and exceptions

This commit is contained in:
John Bintz 2011-06-19 15:08:18 -04:00
parent 3b71a0355b
commit d4b886099c
6 changed files with 24 additions and 23 deletions

View File

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

View File

@ -1,4 +1,13 @@
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

View File

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

View File

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

View File

@ -1,4 +1,5 @@
require 'forwardable'
require 'getoptlong'
module Jasmine
module Headless

View File

@ -1 +0,0 @@