summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-05-07 09:20:41 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-05-07 09:20:41 -0700
commit6687bae7bede7919dd50c78379425c76fd3fca70 (patch)
treea669eff36b8877e6828a8da4e7f86d578c689c52
parent3d65e1d22f03e24cace59b2b4d389a01c1890d40 (diff)
downloadchef-6687bae7bede7919dd50c78379425c76fd3fca70.tar.gz
Allow units to for winevt to run everywhere
-rw-r--r--lib/chef/log/winevt.rb4
-rw-r--r--spec/unit/log/winevt_spec.rb10
2 files changed, 4 insertions, 10 deletions
diff --git a/lib/chef/log/winevt.rb b/lib/chef/log/winevt.rb
index 6574f50b51..e355ff8162 100644
--- a/lib/chef/log/winevt.rb
+++ b/lib/chef/log/winevt.rb
@@ -41,8 +41,8 @@ class Chef
attr_accessor :sync, :formatter, :level
- def initialize
- @eventlog = ::Win32::EventLog::open('Application')
+ def initialize(eventlog=nil)
+ @eventlog = eventlog || ::Win32::EventLog::open('Application')
end
def close
diff --git a/spec/unit/log/winevt_spec.rb b/spec/unit/log/winevt_spec.rb
index 95e805bbb5..867ef55900 100644
--- a/spec/unit/log/winevt_spec.rb
+++ b/spec/unit/log/winevt_spec.rb
@@ -19,18 +19,12 @@
require 'spec_helper'
-module Win32
- class EventLog
- end
-end
-
describe Chef::Log::WinEvt do
- let(:winevt) { Chef::Log::WinEvt.new }
- let(:app) { Chef::Application.new }
let(:evtlog) { instance_double("Win32::EventLog")}
+ let(:winevt) { Chef::Log::WinEvt.new(evtlog) }
+ let(:app) { Chef::Application.new }
before do
- allow(::Win32::EventLog).to receive(:open).and_return(evtlog)
Chef::Log.init(MonoLogger.new(winevt))
@old_log_level = Chef::Log.level