summaryrefslogtreecommitdiff
path: root/spec/unit/system_spec.rb
diff options
context:
space:
mode:
authorsersut <serdar@opscode.com>2014-01-15 15:30:05 -0800
committersersut <serdar@opscode.com>2014-01-15 15:30:05 -0800
commitef7be56ba815223699cd2bc60e91e86dd65c2531 (patch)
treee21a9c3e327f566b2a237ccff2ea1f19c7267bdb /spec/unit/system_spec.rb
parentec77e7d31f27cc0463f5186558f596bdb900a691 (diff)
downloadohai-ef7be56ba815223699cd2bc60e91e86dd65c2531.tar.gz
Regression test for OHAI-546
Diffstat (limited to 'spec/unit/system_spec.rb')
-rw-r--r--spec/unit/system_spec.rb69
1 files changed, 69 insertions, 0 deletions
diff --git a/spec/unit/system_spec.rb b/spec/unit/system_spec.rb
index ff5dcbbf..0ab66ab4 100644
--- a/spec/unit/system_spec.rb
+++ b/spec/unit/system_spec.rb
@@ -619,4 +619,73 @@ EOF
end
end
+
+ describe "when running ohai for specific attributes" do
+ when_plugins_directory "contains v7 plugins" do
+ with_plugin("languages.rb", <<-E)
+ Ohai.plugin(:Languages) do
+ provides 'languages'
+
+ collect_data do
+ languages Mash.new
+ end
+ end
+ E
+
+ with_plugin("english.rb", <<-E)
+ Ohai.plugin(:English) do
+ provides 'languages/english'
+
+ depends 'languages'
+
+ collect_data do
+ languages[:english] = Mash.new
+ languages[:english][:version] = 2014
+ end
+ end
+ E
+
+ with_plugin("french.rb", <<-E)
+ Ohai.plugin(:French) do
+ provides 'languages/french'
+
+ depends 'languages'
+
+ collect_data do
+ languages[:french] = Mash.new
+ languages[:french][:version] = 2012
+ end
+ end
+ E
+
+ before do
+ @original_config = Ohai::Config[:plugin_path]
+ Ohai::Config[:plugin_path] = [ path_to(".") ]
+ end
+
+ after do
+ Ohai::Config[:plugin_path] = @original_config
+ end
+
+ it "should run all the plugins when a top level attribute is specified" do
+ ohai.all_plugins("languages")
+ ohai.data[:languages][:english][:version].should == 2014
+ ohai.data[:languages][:french][:version].should == 2012
+ end
+
+ it "should run the first parent when a non-existent child is specified" do
+ ohai.all_plugins("languages/english/version")
+ ohai.data[:languages][:english][:version].should == 2014
+ ohai.data[:languages][:french].should be_nil
+ end
+
+ it "should be able to run multiple plugins" do
+ ohai.all_plugins(["languages/english", "languages/french"])
+ ohai.data[:languages][:english][:version].should == 2014
+ ohai.data[:languages][:french][:version].should == 2012
+ end
+
+ end
+ end
+
end