bin/jspec in visionmedia-jspec-2.0.3 vs bin/jspec in visionmedia-jspec-2.1.0

- old
+ new

@@ -8,63 +8,47 @@ require 'fileutils' RHINO = 'java org.mozilla.javascript.tools.shell.Main' program :name, 'JSpec' -program :version, '2.0.3' +program :version, '2.1.0' program :description, 'JavaScript BDD Testing Framework' default_command :bind command :init do |c| c.syntax = 'jspec init [dest]' c.summary = 'Initialize a JSpec project template' c.description = 'Initialize a JSpec project template. Defaults to the current directory - when [dest] is not specified. Currently three templates are available: - - "default" : runs specs in browser(s) using the DOM formatter. - "rhino" : runs specs with Rhino using the Terminal formatter. - "server" : runs specs using a Ruby server/client solution which - starts each browser and reports back to the terminal.' + when [dest] is not specified. The template includes several files for + running via Rhino, DOM, and the JSpec Rack server.' c.example 'Create a directory foo, initialized with a jspec template', 'jspec init foo' - c.example 'Initialize a rhino based project in the current directory', 'jspec init --template rhino' - c.example 'Initialize a server based project in foo', 'jspec init foo --template server' - c.option '-T', '--template name', 'Template to use. Valid choices are default, rhino, and server.' c.when_called do |args, options| dest = args.shift || '.' - options.default :template => 'default' unless Dir[dest + '/*'].empty? abort unless agree "'#{dest}' is not empty; continue? " end - template = File.join JSPEC_ROOT, 'templates', options.template, '.' - abort "template #{options.template} does not exist" unless File.exists? template + template = File.join JSPEC_ROOT, 'templates', 'default', '.' FileUtils.mkdir_p dest FileUtils.cp_r template, dest - path = case options.template - when 'default' ; 'spec.html' - when 'rhino' ; 'spec.js' - else - end - if path - spec = File.join dest, 'spec', path - contents = File.read(spec).gsub 'JSPEC_ROOT', JSPEC_ROOT - File.open(spec, 'w') { |file| file.write contents } + %w( spec/spec.dom.html spec/spec.rhino.js ).each do |path| + path = File.join dest, path + contents = File.read(path).gsub 'JSPEC_ROOT', JSPEC_ROOT + File.open(path, 'w') { |file| file.write contents } end say "Template initialized at '#{dest}'" end end command :update do |c| c.syntax = 'jspec update [path ...]' c.summary = 'Update JSpec releases' - c.description = 'Update JSpec release in [paths], this will allow you to utilize the latest - JSpec features. If you have suites running at a path other than the regular - spec/spec.html simply pass them as arguments to this sub-command. - - This is only needed when using the default, or rhino project templates.' + c.description = 'Update JSpec release in [paths], this will allow you to utilize + the latest JSpec features. Execute from JSpec project root without [paths] to + update the default template spec files.' c.when_called do |args, options| - args = %w( spec/spec.html ) if args.empty? - args.each do |path| + paths = args.empty? ? %w( spec/spec.dom.html spec/spec.rhino.js ) : args + paths.each do |path| next unless File.exists? path contents = File.read(path).gsub /visionmedia-jspec-(\d+\.\d+\.\d+)/, "visionmedia-jspec-#{program(:version)}" File.open(path, 'r+'){ |file| file.write contents } say "Updated #{path} to JSpec #{program(:version)}" end @@ -99,16 +83,16 @@ require 'bind' options.default :browsers => %w( Safari ), :paths => ['lib/**/*.js', 'spec/**/*.js'] # Actions if options.rhino - spec = args.shift || 'spec/spec.js' + spec = args.shift || 'spec/spec.rhino.js' action = lambda { rhino spec } elsif options.server - spec = args.shift || 'spec/spec.html' + spec = args.shift || 'spec/spec.server.html' action = lambda { start_server options, spec } else - spec = args.shift || 'spec/spec.html' + spec = args.shift || 'spec/spec.dom.html' action = Bind::Actions::RefreshBrowsers.new spec, *options.browsers end # Binding if options.bind \ No newline at end of file