spec/unit/config_spec.rb in ohai-8.6.0.alpha.1 vs spec/unit/config_spec.rb in ohai-8.6.0

- old
+ new

@@ -88,9 +88,37 @@ let(:value) { "8.2.0" } end end end + describe "config_context :ohai" do + describe "option :plugin" do + it "gets configured with a value" do + Ohai::Config.ohai[:plugin][:foo] = true + expect(Ohai::Config.ohai[:plugin]).to have_key(:foo) + expect(Ohai::Config.ohai[:plugin][:foo]).to be true + end + + it "gets configured with a Hash" do + value = { :bar => true, :baz => true } + Ohai::Config.ohai[:plugin][:foo] = value + expect(Ohai::Config.ohai[:plugin]).to have_key(:foo) + expect(Ohai::Config.ohai[:plugin][:foo]).to eq(value) + end + + it "raises an error if the plugin name is not a symbol" do + expect { Ohai::Config.ohai[:plugin]["foo"] = false }. + to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/) + end + + it "raises an error if the value Hash has non-Symbol key" do + value = { :bar => true, "baz" => true } + expect { Ohai::Config.ohai[:plugin][:foo] = value }. + to raise_error(Ohai::Exceptions::PluginConfigError, /Expected Symbol/) + end + end + end + describe "::merge_deprecated_config" do before(:each) do allow(Ohai::Log).to receive(:warn) configure_ohai end