require 'spec_helper' describe Command do context '#run_command' do klass = Class.new do include Command end it 'captures stdout' do result = klass.new.run_command( 'echo hello_world' ) expect( result.stdout.chomp ).to eq( 'hello_world' ) end it 'captures stderr' do result = klass.new.run_command( 'echo hello_world >&2' ) expect( result.stderr.chomp ).to eq( 'hello_world' ) end it 'captures exit status' do result = klass.new.run_command( 'echo hello_world >&2' ) expect( result.status.exitstatus ).to eq( 0 ) end end context '#which' do klass = Class.new do include Command end it 'returns full path for a valid command' do expect( klass.new.which( 'which' ) ).to eq( '/usr/bin/which' ) end end end