summaryrefslogtreecommitdiff
path: root/spec/support/shared/context/client.rb
diff options
context:
space:
mode:
authorThom May <thom@chef.io>2018-02-14 12:22:41 +0000
committerThom May <thom@chef.io>2018-03-19 21:36:23 +0000
commit94222a8a0a1cda16d35c8f08c731a3f902449391 (patch)
tree712169a375dbf411ebfa4f205727840db279d404 /spec/support/shared/context/client.rb
parent7e11a4192df63ecc0166a947109878cc0070434a (diff)
downloadchef-tm/inject_log.tar.gz
Add the ability to inject log objectstm/inject_log
meaning that we can have inheritable metadata Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'spec/support/shared/context/client.rb')
-rw-r--r--spec/support/shared/context/client.rb22
1 files changed, 12 insertions, 10 deletions
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index 19ce82fa15..5acae86acf 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -20,7 +20,7 @@ shared_context "client" do
end
let(:ohai_system) do
- ohai = instance_double("Ohai::System", :all_plugins => true, :data => ohai_data)
+ ohai = instance_double("Ohai::System", :all_plugins => true, :data => ohai_data, logger: logger)
allow(ohai).to receive(:[]) do |k|
ohai_data[k]
end
@@ -37,19 +37,24 @@ shared_context "client" do
let(:json_attribs) { nil }
let(:client_opts) { {} }
+ let(:stdout) { STDOUT }
+ let(:stderr) { STDERR }
+
let(:client) do
Chef::Config[:event_loggers] = []
- Chef::Client.new(json_attribs, client_opts).tap do |c|
+ allow(Ohai::System).to receive(:new).and_return(ohai_system)
+ opts = client_opts.merge({ logger: logger })
+ Chef::Client.new(json_attribs, opts).tap do |c|
c.node = node
end
end
- before do
- Chef::Log.logger = Logger.new(StringIO.new)
+ let(:logger) { instance_double("Mixlib::Log::Child", trace: nil, debug: nil, warn: nil, info: nil, error: nil, fatal: nil) }
- # Node/Ohai data
- #Chef::Config[:node_name] = fqdn
- allow(Ohai::System).to receive(:new).and_return(ohai_system)
+ before do
+ stub_const("Chef::Client::STDOUT_FD", stdout)
+ stub_const("Chef::Client::STDERR_FD", stderr)
+ allow(client).to receive(:logger).and_return(logger)
end
end
@@ -163,9 +168,6 @@ shared_context "a client run" do
Chef::Config[:why_run] = false
Chef::Config[:audit_mode] = :enabled
- stub_const("Chef::Client::STDOUT_FD", stdout)
- stub_const("Chef::Client::STDERR_FD", stderr)
-
stub_rest_clean
stub_for_register
stub_for_data_collector_init