Fix SafeExec tests
This commit is contained in:
parent
214a79e057
commit
0c7696f11e
|
@ -93,47 +93,9 @@ describe VagrantPlugins::LocalExecPush::Push do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#execute!" do
|
describe "#execute!" do
|
||||||
let(:exit_code) { 0 }
|
it "safe execs" do
|
||||||
let(:stdout) { "This is the output" }
|
expect(Vagrant::Util::SafeExec).to receive(:exec)
|
||||||
let(:stderr) { "This is the errput" }
|
|
||||||
|
|
||||||
let(:process) do
|
|
||||||
double("process",
|
|
||||||
exit_code: exit_code,
|
|
||||||
stdout: stdout,
|
|
||||||
stderr: stderr,
|
|
||||||
)
|
|
||||||
end
|
|
||||||
|
|
||||||
before do
|
|
||||||
allow(Vagrant::Util::Subprocess).to receive(:execute)
|
|
||||||
.and_return(process)
|
|
||||||
end
|
|
||||||
|
|
||||||
it "creates a subprocess" do
|
|
||||||
expect(Vagrant::Util::Subprocess).to receive(:execute)
|
|
||||||
expect { subject.execute! }.to_not raise_error
|
expect { subject.execute! }.to_not raise_error
|
||||||
end
|
end
|
||||||
|
|
||||||
it "returns the resulting process" do
|
|
||||||
expect(subject.execute!).to be(process)
|
|
||||||
end
|
|
||||||
|
|
||||||
context "when the exit code is non-zero" do
|
|
||||||
let(:exit_code) { 1 }
|
|
||||||
|
|
||||||
it "raises an exception" do
|
|
||||||
klass = VagrantPlugins::LocalExecPush::Errors::CommandFailed
|
|
||||||
cmd = ["foo", "bar"]
|
|
||||||
|
|
||||||
expect { subject.execute!(*cmd) }.to raise_error(klass) { |error|
|
|
||||||
expect(error.message).to eq(I18n.t("local_exec_push.errors.command_failed",
|
|
||||||
cmd: cmd.join(" "),
|
|
||||||
stdout: stdout,
|
|
||||||
stderr: stderr,
|
|
||||||
))
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue