core: machine-readable output should include standard UI output

As a "ui" type
This commit is contained in:
Mitchell Hashimoto 2015-10-26 18:10:26 -07:00
parent efa01abb12
commit 32e981ce7c
2 changed files with 24 additions and 0 deletions

View File

@ -103,6 +103,12 @@ module Vagrant
raise Errors::UIExpectsTTY
end
[:detail, :warn, :error, :info, :output, :success].each do |method|
define_method(method) do |message, *opts|
machine("ui", method.to_s, message)
end
end
def machine(type, *data)
opts = {}
opts = data.pop if data.last.kind_of?(Hash)

View File

@ -215,6 +215,24 @@ describe Vagrant::UI::MachineReadable do
end
end
[:detail, :warn, :error, :info, :output, :success].each do |method|
describe "##{method}" do
it "outputs UI type to the machine-readable output" do
expect(subject).to receive(:safe_puts).with { |message|
parts = message.split(",")
expect(parts.length).to eq(5)
expect(parts[1]).to eq("")
expect(parts[2]).to eq("ui")
expect(parts[3]).to eq(method.to_s)
expect(parts[4]).to eq("foo")
true
}
subject.send(method, "foo")
end
end
end
describe "#machine" do
it "is formatted properly" do
expect(subject).to receive(:safe_puts).with { |message|