summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Bellone <jbellone@bloomberg.net>2016-06-13 13:25:59 -0400
committerJohn Bellone <jbellone@bloomberg.net>2016-06-13 13:25:59 -0400
commit3528c0531621bc9a99f48e978ef7e10759aa0db6 (patch)
tree0ab9429879157eb1a403a9cda373a4df0b878c1c
parent8698719fe40161dc40e1de9b49e00efabbe3a4e2 (diff)
downloadohai-3528c0531621bc9a99f48e978ef7e10759aa0db6.tar.gz
Add unit test and fix broken plugin.
-rw-r--r--lib/ohai/plugins/timezone.rb4
-rw-r--r--spec/unit/plugins/timezone_spec.rb30
2 files changed, 32 insertions, 2 deletions
diff --git a/lib/ohai/plugins/timezone.rb b/lib/ohai/plugins/timezone.rb
index b7b3cb0e..fb35987d 100644
--- a/lib/ohai/plugins/timezone.rb
+++ b/lib/ohai/plugins/timezone.rb
@@ -17,7 +17,7 @@
Ohai.plugin(:Timezone) do
provides "timezone"
- collect_data do
- timezone = Time.now.getlocal.zone
+ collect_data(:default) do
+ timezone Time.now.getlocal.zone
end
end
diff --git a/spec/unit/plugins/timezone_spec.rb b/spec/unit/plugins/timezone_spec.rb
new file mode 100644
index 00000000..770dc838
--- /dev/null
+++ b/spec/unit/plugins/timezone_spec.rb
@@ -0,0 +1,30 @@
+#
+# Author:: John Bellone (<jbellone@bloomberg.net>)
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper.rb")
+
+describe Ohai::System, "timezone plugin" do
+ before(:each) do
+ @plugin = get_plugin("timezone")
+ allow(Time).to receive_message_chain(:now, :getlocal, :zone) { "ZZZ" }
+ end
+
+ it "should get the local timezone" do
+ @plugin.run
+ expect(@plugin["timezone"]).to eq("ZZZ")
+ end
+end