Sha256: c2e3e86836c3d15de4c2037c4587f76519261db689d461c832f69a3fff5ca5df

Contents?: true

Size: 1.04 KB

Versions: 11

Compression:

Stored size: 1.04 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 '-v', "--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

11 entries across 11 versions & 1 rubygems

Version Path
visionmedia-commander-3.1.7 spec/spec_helper.rb
visionmedia-commander-3.1.8 spec/spec_helper.rb
visionmedia-commander-3.2.0 spec/spec_helper.rb
visionmedia-commander-3.2.2 spec/spec_helper.rb
visionmedia-commander-3.2.3 spec/spec_helper.rb
visionmedia-commander-3.2.4 spec/spec_helper.rb
visionmedia-commander-3.2.5 spec/spec_helper.rb
visionmedia-commander-3.2.6 spec/spec_helper.rb
visionmedia-commander-3.2.7 spec/spec_helper.rb
visionmedia-commander-3.2.8 spec/spec_helper.rb
visionmedia-commander-3.2.9 spec/spec_helper.rb