Class: Cog::SpecHelpers::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/cog/spec_helpers/runner.rb

Overview

Points to the cog command-line app

Instance Method Summary collapse

Constructor Details

#initialize(exec_path = nil, opt = {}) ⇒ Runner

Returns a new instance of Runner.

Parameters:

  • exec_path (String) (defaults to: nil)

    path to the executable

  • opt (Hash) (defaults to: {})

    a customizable set of options

Options Hash (opt):

  • :flags (Array<String>) — default: ['--colorless']

    command line flags to pass each time the executable is invoked

  • :use_bundler (Boolean) — default: true

    Should ‘bundle exec` prefix each invocation of the executable?



12
13
14
15
16
17
18
19
20
# File 'lib/cog/spec_helpers/runner.rb', line 12

def initialize(exec_path = nil, opt={})
  @exec_path = if exec_path
    exec_path
  else
    File.expand_path File.join(File.dirname(__FILE__), '..', '..', '..', 'bin', 'cog')
  end
  @flags = opt[:flags] || ['--colorless']
  @use_bundler = opt[:use_bundler].nil? ? true : opt[:use_bundler]
end

Instance Method Details

#run(*args) ⇒ Invocation

Run cog with the given arguments

Parameters:

Returns:



25
26
27
28
# File 'lib/cog/spec_helpers/runner.rb', line 25

def run(*args)
  cmd = ([@exec_path] + @flags + args).collect &:to_s
  Invocation.new(cmd, :use_bundler => @use_bundler)
end