Merge pull request #6556 from mitchellh/sethvargo/chef_formatter

Only force the formatter if we are on Chef 11 or higher
This commit is contained in:
Seth Vargo 2015-11-19 11:56:01 -08:00
commit a7f9abe740
2 changed files with 36 additions and 1 deletions

View File

@ -48,8 +48,12 @@ module VagrantPlugins
args << " --json-attributes #{provisioning_path("dna.json")}"
args << " --local-mode" if options[:local_mode]
args << " --log_level #{config.log_level}" if config.log_level
args << " --force-formatter"
args << " --no-color" if !options[:colored]
if config.install && config.version >= "11.0"
args << " --force-formatter"
end
args << " #{config.arguments.strip}" if config.arguments
args.strip

View File

@ -8,6 +8,8 @@ describe VagrantPlugins::Chef::CommandBuilder do
let(:chef_config) { double("chef_config") }
before(:each) do
allow(chef_config).to receive(:install).and_return(true)
allow(chef_config).to receive(:version).and_return("12.0.0")
allow(chef_config).to receive(:provisioning_path).and_return("/tmp/vagrant-chef-1")
allow(chef_config).to receive(:arguments).and_return(nil)
allow(chef_config).to receive(:binary_env).and_return(nil)
@ -71,6 +73,23 @@ describe VagrantPlugins::Chef::CommandBuilder do
expect(subject.command).to include(
" --no-color")
end
it "includes --force-formatter if Chef > 10" do
expect(subject.command).to include(
" --force-formatter")
end
it "does not include --force-formatter if Chef < 11" do
allow(chef_config).to receive(:version).and_return("10.0")
expect(subject.command).to_not include(
" --force-formatter")
end
it "does not include --force-formatter if we did not install Chef" do
allow(chef_config).to receive(:install).and_return(false)
expect(subject.command).to_not include(
" --force-formatter")
end
end
describe "linux" do
@ -113,6 +132,18 @@ describe VagrantPlugins::Chef::CommandBuilder do
allow(chef_config).to receive(:binary_env).and_return("ENVVAR=VAL")
expect(subject.command).to match(/^ENVVAR=VAL /)
end
it "does not include --force-formatter if Chef < 11" do
allow(chef_config).to receive(:version).and_return("10.0")
expect(subject.command).to_not include(
" --force-formatter")
end
it "does not include --force-formatter if we did not install Chef" do
allow(chef_config).to receive(:install).and_return(false)
expect(subject.command).to_not include(
" --force-formatter")
end
end
end
end