class Object

Public Instance Methods

command_runner() click to toggle source

Comply with how specs were previously written

# File spec/spec_helper.rb, line 59
def command_runner
  SimpleCommander::Runner.instance
end
create_test_command() click to toggle source

Create test command for usage within several specs

# File spec/spec_helper.rb, line 31
def create_test_command
  command :test do
    syntax = 'test [options] <file>'
    description = 'test description'
    example 'description', 'command'
    example 'description 2', 'command 2'
    option '-v', '--verbose', 'verbose description'
    when_called do |args, _options|
      format('test %s', args.join)
    end
  end
  @command = command :test
end
get_binding() click to toggle source

Return the current binding.

# File lib/simple_commander/core_ext/object.rb, line 5
def get_binding
  binding
end
glob(path) click to toggle source
# File dir_glob.rb, line 6
def glob(path)
  return if !File.directory?(path) && path != '**'
  path = "#{path}/*"
  Dir.glob(path) do |file|
    File.open('Manifest', 'a') { |f| f.write("#{file}\n") }
    glob(file)
  end
end
mock_terminal() click to toggle source

Mock terminal IO streams so we can spec against them

# File spec/spec_helper.rb, line 23
def mock_terminal
  @input = StringIO.new
  @output = StringIO.new
  $terminal = HighLine.new @input, @output
end
new_command_runner(*args) { || ... } click to toggle source

Create a new command runner

# File spec/spec_helper.rb, line 47
def new_command_runner(*args, &block)
  SimpleCommander::Runner.instance_variable_set :"@singleton", SimpleCommander::Runner.new(args)
  program :name, 'test'
  program :version, '1.2.3'
  program :description, 'something'
  create_test_command
  yield if block
  SimpleCommander::Runner.instance
end
run(*args) click to toggle source
# File spec/spec_helper.rb, line 63
def run(*args)
  new_command_runner(*args) do
    program :help_formatter, SimpleCommander::HelpFormatter::Base
  end.run!
  @output.string
end