Add test coverage on expected machine-readable output

This commit is contained in:
Chris Roberts 2019-06-05 13:04:47 -07:00
parent 2f818c0e23
commit fd34ea657b
1 changed files with 35 additions and 1 deletions

View File

@ -10,9 +10,11 @@ describe VagrantPlugins::CommandGlobalStatus::Command do
# We have to create a Vagrantfile so there is a root path
env = isolated_environment
env.vagrantfile("")
env.create_vagrant_env
env.create_vagrant_env(env_opts)
end
let(:env_opts) { {} }
let(:machine) { iso_env.machine(iso_env.machine_names[0], :dummy) }
let(:argv) { [] }
@ -37,6 +39,38 @@ describe VagrantPlugins::CommandGlobalStatus::Command do
end
end
describe "with --machine-readable" do
let(:env_opts) { {ui_class: Vagrant::UI::MachineReadable} }
before do
iso_env.machine_index.set(new_entry("foo"))
iso_env.machine_index.set(new_entry("bar"))
allow($stdout).to receive(:puts)
end
after { subject.execute }
it "should include the machine id" do
expect($stdout).to receive(:puts).with(/,machine-id,/).twice
end
it "should include the machine state" do
expect($stdout).to receive(:puts).with(/,state,/).twice
end
it "should include the machine count" do
expect($stdout).to receive(:puts).with(/machine-count,2/)
end
it "should include the machine home path" do
expect($stdout).to receive(:puts).with(/,machine-home,/).twice
end
it "should include the provider name" do
expect($stdout).to receive(:puts).with(/,provider-name,/).twice
end
end
describe "execute with --prune" do
let(:argv) { ["--prune"] }