Sha256: d4c49e77193a832691e471b31bf974fdb036caae3eda435860a3abc7cf9cf700
Contents?: true
Size: 1.08 KB
Versions: 3
Compression:
Stored size: 1.08 KB
Contents
require 'rubygems' require 'commander' require 'stringio' # Mock terminal IO streams so we can spec against them def mock_terminal @input = StringIO.new @output = StringIO.new $terminal = HighLine.new @input, @output end # Create test command for usage within several specs def create_test_command command :test do |c| c.syntax = "test [options] <file>" c.description = "test description" c.example "description", "command" c.example "description 2", "command 2" c.option "-t", "--trace", "trace description" c.option "--verbose", "verbose description" c.when_called do |args, options| "test %s" % args.join end end @command = command :test end # Create a new global command runner def new_command_runner *args, &block $command_runner = Commander::Runner.new args program :name, 'test' program :version, '1.2.3' program :description, 'something' create_test_command yield if block command_runner end def run *args new_command_runner *args do program :help_formatter, Commander::HelpFormatter::Base end.run! @output.string end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
visionmedia-commander-3.1.4 | spec/spec_helper.rb |
visionmedia-commander-3.1.5 | spec/spec_helper.rb |
visionmedia-commander-3.1.6 | spec/spec_helper.rb |