class Cog::SpecHelpers::Invocation
Represents a cog
command line invocation, which can be tested with RSpec
should
and should_not
custom {Matchers}. This is the kind of object returned by {Runner#run}.
Public Class Methods
new(cmd, opt={})
click to toggle source
@api developer @param cmd [Array<String>] @option opt [Boolean] :use_bundler (false)
# File lib/cog/spec_helpers/runner.rb, line 39 def initialize(cmd, opt={}) @cmd = cmd @use_bundler = opt[:use_bundler] end
Public Instance Methods
exec(&block)
click to toggle source
Execute the command @api developer @yield [stdin, stdout, stderr] standard pipes for the invocation @return [nil]
# File lib/cog/spec_helpers/runner.rb, line 48 def exec(&block) full_cmd = @cmd full_cmd = ['bundle', 'exec'] + full_cmd if @use_bundler ENV['HOME'] = SpecHelpers.active_home_fixture_dir Open3.popen3 *full_cmd do |i,o,e,t| block.call i,o,e end end
to_s()
click to toggle source
@api developer @return [String] loggable representation
# File lib/cog/spec_helpers/runner.rb, line 59 def to_s "`#{@cmd.compact.join ' '}`" end