spec/chake/config_manager/itamae_spec.rb in chake-0.80 vs spec/chake/config_manager/itamae_spec.rb in chake-0.81
- old
+ new
@@ -1,5 +1,6 @@
+require 'spec_helper'
require 'chake/node'
require 'chake/config_manager/itamae'
describe Chake::ConfigManager::Itamae do
let(:hostname) { 'foobar' }
@@ -10,14 +11,10 @@
end
end
let(:cfg) { Chake::ConfigManager::Itamae.new(node) }
let(:output) { StringIO.new("line1\nline2\n") }
- it 'does not require bootstrapping' do
- expect(cfg.needs_bootstrap?).to eq(false)
- end
-
it 'does not require uploading' do
expect(cfg.needs_upload?).to eq(false)
end
it 'calls itamae when converging' do
@@ -52,18 +49,39 @@
context 'for local hosts' do
let(:hostname) { 'local://localhostname' }
it 'calls itamae with local subcommand' do
expect(IO).to receive(:popen).with(
- ['itamae', 'local', /--node-json=.*/, 'foo.rb', 'bar.rb'],
+ array_including('itamae', 'local', /--node-json=.*/, 'foo.rb', 'bar.rb'),
anything,
err: anything
).and_return(output)
cfg.converge
end
end
it 'throws an error for unsupported connection' do
allow(node).to receive(:connection).and_return(Object.new)
expect(-> { cfg.converge }).to raise_error(NotImplementedError)
+ end
+
+ it 'handles silent mode' do
+ expect(IO).to receive(:popen).with(
+ array_including('--log-level=warn'),
+ anything,
+ err: anything
+ ).and_return(output)
+ cfg.converge
+ end
+
+ RSpec::Matchers.define_negated_matcher :array_excluding, :include
+
+ it 'handles non-silent mode' do
+ node.silent = false
+ expect(IO).to receive(:popen).with(
+ array_excluding('--log-level=warn'),
+ anything,
+ err: anything
+ ).and_return(output)
+ silence($stdout) { cfg.converge }
end
end