spec/command_spec.rb in vagrant-shell-commander-0.1.0 vs spec/command_spec.rb in vagrant-shell-commander-0.1.1
- old
+ new
@@ -1,11 +1,11 @@
require 'spec_helper'
describe VagrantShellCommander::Command do
let(:subject) {described_class.new('2', 'command')}
let(:argv) {double}
- let(:opts) {{parser: 'parser', values: 'values'}}
+ let(:opts) {{parser: 'parser', values: {cmd: 'cmd'}}}
before(:each) do
VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
and_return(opts)
@@ -65,10 +65,11 @@
end
end
context 'running machine' do
let(:cmd) {'command'}
+ let(:cwd) {'cwd'}
let(:communicate) {double(execute: true)}
before(:each) do
VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
and_return(parser: 'parser', values: {cmd: cmd})
@@ -88,17 +89,30 @@
ui.should_receive(:info).with("#{machine_name}:: #{data}")
end
it 'executes the command in the given cwd' do
- cwd = 'cwd'
-
VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
and_return(parser: 'parser', values: {cmd: cmd, cwd: cwd})
communicate.should_receive(:execute).with("cd #{cwd} && #{cmd}")
end
+ describe 'does nothing' do
+ after(:each) do
+ subject.should_not_receive(:with_target_vms)
+ end
+
+ it 'an empty command' do
+ VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
+ and_return(parser: 'parser', values: {cmd: '', cwd: cwd})
+ end
+
+ it 'non present command' do
+ VagrantShellCommander::OptionManager.stub_chain(:new, :execute).
+ and_return(parser: 'parser', values: {cwd: cwd})
+ end
+ end
end
end
end
end