bin/jspec in visionmedia-jspec-2.3.1 vs bin/jspec in visionmedia-jspec-2.4.0
- old
+ new
@@ -3,16 +3,17 @@
JSPEC_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
$:.unshift JSPEC_ROOT
require 'rubygems'
require 'commander'
+require 'bind'
require 'fileutils'
RHINO = 'java org.mozilla.javascript.tools.shell.Main'
program :name, 'JSpec'
-program :version, '2.3.1'
+program :version, '2.4.0'
program :description, 'JavaScript BDD Testing Framework'
default_command :bind
command :init do |c|
c.syntax = 'jspec init [dest]'
@@ -56,56 +57,55 @@
end
command :run do |c|
c.syntax = 'jspec run [path] [options]'
c.summary = 'Run specifications'
- c.description = 'Run specifications, defaulting [path] to spec/spec.html. You will need
- supply [path] if your specs do not reside in this location. `run --bind` is
- the default sub-command of jspec so you may simply execute `jspec` in order
- to bind execution of your specs when a file is altered.
+ c.description = 'Run specifications, defaulting [path] to spec/spec.dom.html.
+ You will need to supply [path] if your specs do not reside
+ in this location. `run --bind` is the default sub-command of
+ jspec so you may simply execute `jspec` in order to bind execution
+ of your specs when a file is altered.
- JSpec supports Rhino execution when installed. The [path] is assumed to be
- spec/spec.js unless specified. See examples below for using the --rhino switch.'
+ JSpec supports Rhino execution when installed. The [path] is assumed
+ to be spec/spec.rhino.js unless specified. See examples below for
+ using the --rhino switch.
+
+ JSpec\'s server is also available via --server, which defaults
+ the [path] to spec/server.html'
c.example 'Run once in Safari', 'jspec run'
c.example 'Run once in Safari and Firefox', 'jspec run --browsers Safari,Firefox'
c.example 'Run custom spec file', 'jspec run foo.html'
c.example 'Auto-run browsers when a file is altered', 'jspec run --bind --browsers Safari,Firefox'
c.example 'Shortcut for the previous example', 'jspec --browsers Safari,Firefox'
c.example 'Auto-run rhino when a file is altered', 'jspec --rhino'
- c.example 'Run Rhino specs once', 'jspec run --rhino'
+ c.example 'Run Rhino specs once', 'jspec run specs/something.js --rhino'
c.option '-b', '--browsers BROWSERS', Array, 'Specify browsers to test, defaults to Safari'
c.option '-p', '--paths PATHS', Array, 'Specify paths when binding, defaults to javascript within ./lib and ./spec'
c.option '-B', '--bind', 'Auto-run specs when source files or specs are altered'
c.option '-R', '--rhino', 'Run specs using Rhino'
c.option '-S', '--server', 'Run specs using the JSpec server'
c.option '-s', '--server-only', 'Start JSpec server without running browsers'
c.when_called do |args, options|
- begin
- require 'bind'
- options.default :browsers => %w( Safari ), :paths => ['lib/**/*.js', 'spec/**/*.js']
-
- # Actions
- if options.rhino
- spec = args.shift || 'spec/spec.rhino.js'
- action = lambda { rhino spec }
- elsif options.server
- spec = args.shift || 'spec/spec.server.html'
- action = lambda { start_server options, spec }
- else
- spec = args.shift || 'spec/spec.dom.html'
- action = Bind::Actions::RefreshBrowsers.new spec, *options.browsers
- end
-
- # Binding
- if options.bind
- listener = Bind::Listener.new :paths => options.paths, :interval => 1, :actions => [action], :debug => $stdout
- listener.run!
- else
- action.call File.new(spec)
- end
-
- rescue LoadError
- abort "jspec run requires the visionmedia-bind gem; http://visionmedia.github.com/bind/"
+ options.default :browsers => %w( Safari ), :paths => ['lib/**/*.js', 'spec/**/*.js']
+
+ # Actions
+ if options.rhino
+ spec = args.shift || 'spec/spec.rhino.js'
+ action = lambda { rhino spec }
+ elsif options.server
+ spec = args.shift || 'spec/spec.server.html'
+ action = lambda { start_server options, spec }
+ else
+ spec = args.shift || 'spec/spec.dom.html'
+ action = Bind::Actions::RefreshBrowsers.new spec, *options.browsers
+ end
+
+ # Binding
+ if options.bind
+ listener = Bind::Listener.new :paths => options.paths, :interval => 1, :actions => [action], :debug => $stdout
+ listener.run!
+ else
+ action.call File.new(spec)
end
end
end
alias_command :bind, :run, '--bind'
\ No newline at end of file