spec/command_spec.rb in vagrant-shell-commander-0.2.0 vs spec/command_spec.rb in vagrant-shell-commander-0.3.0

- old
+ new

@@ -1,14 +1,14 @@ require 'spec_helper' -describe VagrantShellCommander::Command do +describe VagrantPlugins::ShellCommander::Command do let(:subject) {described_class.new('2', 'command')} let(:argv) {double} let(:opts) {{parser: 'parser', values: {cmd: 'cmd'}}} before(:each) do - VagrantShellCommander::OptionManager.stub_chain(:new, :execute). + VagrantPlugins::ShellCommander::OptionManager.stub_chain(:new, :execute). and_return(opts) subject.stub(:with_target_vms) subject.stub(:parse_options).and_return(argv) end @@ -70,48 +70,51 @@ let(:dir) {'dir'} let(:user) {'user'} let(:communicate) {double(execute: true)} before(:each) do - VagrantShellCommander::OptionManager.stub_chain(:new, :execute). + VagrantPlugins::ShellCommander::OptionManager.stub_chain(:new, :execute). and_return(parser: 'parser', values: {cmd: cmd}) machine.stub_chain(:state, :id).and_return(:running) allow(ui).to receive(:success) allow(machine).to receive(:action) end it 'executes the given command' do - expect(machine).to receive(:action).with(:ssh_run, ssh_run_command: cmd) + expect(machine).to receive(:action).with(:ssh_run, ssh_run_command: cmd, ssh_opts: {:extra_args=>[]}) end it 'shows the machine name' do expect(ui).to receive(:success).with("#{machine_name}::") end it 'executes the command in the given dir' do - VagrantShellCommander::OptionManager.stub_chain(:new, :execute). + VagrantPlugins::ShellCommander::OptionManager.stub_chain(:new, :execute). and_return(parser: 'parser', values: {cmd: cmd, dir: dir}) expect(machine).to receive(:action).with(:ssh_run, - ssh_run_command: "cd #{dir} && #{cmd}") + ssh_run_command: "cd #{dir} && #{cmd}", + ssh_opts: {:extra_args=>[]}) end it 'executes the command for the given user' do - VagrantShellCommander::OptionManager.stub_chain(:new, :execute). + VagrantPlugins::ShellCommander::OptionManager.stub_chain(:new, :execute). and_return(parser: 'parser', values: {cmd: cmd, user: user}) expect(machine).to receive(:action).with(:ssh_run, - ssh_run_command: "sudo su - #{user} -c \"#{cmd}\"") + ssh_run_command: "sudo su - #{user} -c \"#{cmd}\"", + ssh_opts: {:extra_args=>[]}) end it 'executes the command for the given user and the given dir' do - VagrantShellCommander::OptionManager.stub_chain(:new, :execute). + VagrantPlugins::ShellCommander::OptionManager.stub_chain(:new, :execute). and_return(parser: 'parser', values: {cmd: cmd, user: user, dir: dir}) expect(machine).to receive(:action).with(:ssh_run, - ssh_run_command: "sudo su - #{user} -c \"cd #{dir} && #{cmd}\"") + ssh_run_command: "sudo su - #{user} -c \"cd #{dir} && #{cmd}\"", + ssh_opts: {:extra_args=>[]}) end describe 'shows help' do let(:parser) {'parser'} @@ -119,15 +122,15 @@ expect(subject).not_to receive(:with_target_vms) expect(ui).to receive(:info).with(parser) end it 'an empty command' do - VagrantShellCommander::OptionManager.stub_chain(:new, :execute). + VagrantPlugins::ShellCommander::OptionManager.stub_chain(:new, :execute). and_return(parser: parser, values: {cmd: '', dir: dir}) end it 'non present command' do - VagrantShellCommander::OptionManager.stub_chain(:new, :execute). + VagrantPlugins::ShellCommander::OptionManager.stub_chain(:new, :execute). and_return(parser: parser, values: {user: user}) end end end end