Class: Cog::SpecHelpers::Invocation
- Inherits:
-
Object
- Object
- Cog::SpecHelpers::Invocation
- Defined in:
- lib/cog/spec_helpers/runner.rb
Overview
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.
Instance Method Summary collapse
-
#exec {|stdin, stdout, stderr| ... } ⇒ nil
Execute the command.
-
#initialize(cmd, opt = {}) ⇒ Invocation
constructor
A new instance of Invocation.
-
#to_s ⇒ String
Loggable representation.
Constructor Details
#initialize(cmd, opt = {}) ⇒ Invocation
Returns a new instance of Invocation.
39 40 41 42 |
# File 'lib/cog/spec_helpers/runner.rb', line 39 def initialize(cmd, opt={}) @cmd = cmd @use_bundler = opt[:use_bundler] end |
Instance Method Details
#exec {|stdin, stdout, stderr| ... } ⇒ nil
Execute the command
48 49 50 51 52 53 54 55 |
# 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 ⇒ String
Returns loggable representation.
59 60 61 |
# File 'lib/cog/spec_helpers/runner.rb', line 59 def to_s "`#{@cmd.compact.join ' '}`" end |