spec/action_spec.rb in vagrant-shell-commander-0.3.1 vs spec/action_spec.rb in vagrant-shell-commander-0.3.2
- old
+ new
@@ -1,16 +1,16 @@
require 'spec_helper'
describe VagrantPlugins::ShellCommander::Action do
let(:app) {double(call: true)}
- let(:machine) {double(action: true)}
- let(:env) {double(:[] => machine)}
+ let(:state) {double(id: :poweron)}
let(:cmd) {'cmd'}
let(:sh) {double(after_share_folders: cmd)}
let(:config) {double(sh: sh)}
- let(:machine_env) {double(config: config)}
+ let(:machine_env) {double(config: config, state: state, action: true)}
let(:action_env) {{machine: machine_env}}
+ let(:env) {double(:[] => machine_env)}
let(:subject) {described_class.new(app, env)}
describe "#call" do
it "should call the next middleware" do
expect(app).to receive(:call).with(action_env)
@@ -18,25 +18,32 @@
subject.call(action_env)
end
describe "SSHRun call" do
it "should call SSHRun action of the current machine with the after_boot option as command" do
- allow(env).to receive(:[]).with(:machine).and_return(machine)
-
- expect(machine).to receive(:action).with(:ssh_run, ssh_run_command: cmd, ssh_opts: {:extra_args=>[]})
+ expect(machine_env).to receive(:action).with(:ssh_run, ssh_run_command: cmd, ssh_opts: {extra_args: []})
subject.call(action_env)
end
- it "should not call SSHRun action if after_boot option is nil" do
- sh = double(after_share_folders: nil)
- config = double(sh: sh)
- machine_env = double(config: config)
+ it "should not call SSHRun action if after_share_folder option is nil" do
+ machine_env = double(config: config, state: state)
action_env = {machine: machine_env}
- expect(machine).not_to receive(:action)
+ expect(machine_env).not_to receive(:action)
subject.call(action_env)
end
+
+ it "should not call SSHRun action if machine is not powered on" do
+ state = double(id: :poweroff)
+ machine_env = double(config: config, state: state, action: true)
+ action_env = {machine: machine_env}
+
+ expect(machine_env).not_to receive(:action)
+
+ subject.call(action_env)
+ end
+
end
end
end