diff options
Diffstat (limited to 'spec/unit/util/dsc')
-rw-r--r-- | spec/unit/util/dsc/configuration_generator_spec.rb | 36 | ||||
-rw-r--r-- | spec/unit/util/dsc/lcm_output_parser_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/util/dsc/local_configuration_manager_spec.rb | 9 | ||||
-rw-r--r-- | spec/unit/util/dsc/resource_store.rb | 4 |
4 files changed, 28 insertions, 29 deletions
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb index 7b39404c4d..d59423e1e5 100644 --- a/spec/unit/util/dsc/configuration_generator_spec.rb +++ b/spec/unit/util/dsc/configuration_generator_spec.rb @@ -50,7 +50,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do describe "#get_merged_configuration_flags" do context "when strings are used as switches" do it "should merge the hash if there are no restricted switches" do - merged = conf_man.send(:get_merged_configuration_flags!, {"flag" => "a"}, "hello") + merged = conf_man.send(:get_merged_configuration_flags!, { "flag" => "a" }, "hello") expect(merged).to include(:flag) expect(merged[:flag]).to eql("a") expect(merged).to include(:outputpath) @@ -58,25 +58,25 @@ describe Chef::Util::DSC::ConfigurationGenerator do it "should raise an ArgumentError if you try to override outputpath" do expect { - conf_man.send(:get_merged_configuration_flags!, {"outputpath" => "a"}, "hello") + conf_man.send(:get_merged_configuration_flags!, { "outputpath" => "a" }, "hello") }.to raise_error(ArgumentError) end it "should be case insensitive for switches that are not allowed" do expect { - conf_man.send(:get_merged_configuration_flags!, {"OutputPath" => "a"}, "hello") + conf_man.send(:get_merged_configuration_flags!, { "OutputPath" => "a" }, "hello") }.to raise_error(ArgumentError) end it "should be case insensitive to switches that are allowed" do - merged = conf_man.send(:get_merged_configuration_flags!, {"FLAG" => "a"}, "hello") + merged = conf_man.send(:get_merged_configuration_flags!, { "FLAG" => "a" }, "hello") expect(merged).to include(:flag) end end context "when symbols are used as switches" do it "should merge the hash if there are no restricted switches" do - merged = conf_man.send(:get_merged_configuration_flags!, {:flag => "a"}, "hello") + merged = conf_man.send(:get_merged_configuration_flags!, { :flag => "a" }, "hello") expect(merged).to include(:flag) expect(merged[:flag]).to eql("a") expect(merged).to include(:outputpath) @@ -84,18 +84,18 @@ describe Chef::Util::DSC::ConfigurationGenerator do it "should raise an ArgumentError if you try to override outputpath" do expect { - conf_man.send(:get_merged_configuration_flags!, {:outputpath => "a"}, "hello") + conf_man.send(:get_merged_configuration_flags!, { :outputpath => "a" }, "hello") }.to raise_error(ArgumentError) end it "should be case insensitive for switches that are not allowed" do expect { - conf_man.send(:get_merged_configuration_flags!, {:OutputPath => "a"}, "hello") + conf_man.send(:get_merged_configuration_flags!, { :OutputPath => "a" }, "hello") }.to raise_error(ArgumentError) end it "should be case insensitive to switches that are allowed" do - merged = conf_man.send(:get_merged_configuration_flags!, {:FLAG => "a"}, "hello") + merged = conf_man.send(:get_merged_configuration_flags!, { :FLAG => "a" }, "hello") expect(merged).to include(:flag) end end @@ -127,7 +127,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do it "should write the input to a file" do allow(File).to receive(:open).and_yield(file_like_object) allow(File).to receive(:join) do |a, b| - [a,b].join("++") + [a, b].join("++") end allow(file_like_object).to receive(:write) conf_man.send(:write_document_generation_script, "file", "hello", {}) @@ -140,18 +140,18 @@ describe Chef::Util::DSC::ConfigurationGenerator do # These tests seem way too implementation specific. Unfortunately, File and Dir # need to be mocked because they are OS specific allow(File).to receive(:join) do |a, b| - [a,b].join("++") + [a, b].join("++") end - allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "hello.mof", "f3"]} + allow(Dir).to receive(:entries).with("tmp++hello") { ["f1", "f2", "hello.mof", "f3"] } expect(conf_man.send(:find_configuration_document, "hello")).to eql("tmp++hello++hello.mof") end it "should return nil if the mof file is not found" do allow(File).to receive(:join) do |a, b| - [a,b].join("++") + [a, b].join("++") end - allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "f3"]} + allow(Dir).to receive(:entries).with("tmp++hello") { ["f1", "f2", "f3"] } expect(conf_man.send(:find_configuration_document, "hello")).to be_nil end end @@ -169,25 +169,25 @@ describe Chef::Util::DSC::ConfigurationGenerator do end context "with imports" do it "should import all resources when a module has an empty list" do - dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => []}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => [] }) expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/) end it "should import all resources when a module has a list with *" do - dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "*", "BarResource"]}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => ["FooResource", "*", "BarResource"] }) expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/) end it "should import specific resources when a module has list without * that is not empty" do - dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "BarResource"]}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => ["FooResource", "BarResource"] }) expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/) end it "should import multiple modules with multiple import statements" do - dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "BarResource"], "BazModule" => []}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", { "FooModule" => ["FooResource", "BarResource"], "BazModule" => [] }) expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/) expect(dsc).to match(/Import-DscResource -ModuleName BazModule\s*\n/) - end + end end end end diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb index 06f2a9288a..69eb8724ea 100644 --- a/spec/unit/util/dsc/lcm_output_parser_spec.rb +++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb @@ -22,13 +22,13 @@ describe Chef::Util::DSC::LocalConfigurationManager::Parser do context "empty input parameter" do it "raises an exception when there are no valid lines" do str = <<-EOF - + EOF - expect {Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)}.to raise_error(Chef::Exceptions::LCMParser) + expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) }.to raise_error(Chef::Exceptions::LCMParser) end it "raises an exception for a nil input" do - expect {Chef::Util::DSC::LocalConfigurationManager::Parser::parse(nil)}.to raise_error(Chef::Exceptions::LCMParser) + expect { Chef::Util::DSC::LocalConfigurationManager::Parser::parse(nil) }.to raise_error(Chef::Exceptions::LCMParser) end end @@ -69,7 +69,7 @@ logtype: [machinename]: LCM: [ End Resource ] [name] logtype: [machinename]: LCM: [ End Set ] EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) - expect(resources[0].change_log).to match_array(["[name]","[message]","[name]"]) + expect(resources[0].change_log).to match_array(["[name]", "[message]", "[name]"]) end it "should return false for changes_state?" do diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb index 0ea544d839..15cf38394e 100644 --- a/spec/unit/util/dsc/local_configuration_manager_spec.rb +++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb @@ -85,7 +85,7 @@ EOH expect(Chef::Log).to receive(:warn).at_least(:once) expect(lcm).to receive(:whatif_not_supported?).and_call_original test_configuration_result = nil - expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error + expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error expect(test_configuration_result.class).to be(Array) end end @@ -99,13 +99,13 @@ EOH expect(Chef::Log).to receive(:warn).at_least(:once) expect(lcm).to receive(:dsc_module_import_failure?).and_call_original test_configuration_result = nil - expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error + expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error end it "should return a (possibly empty) array of ResourceInfo instances" do expect(Chef::Log).to receive(:warn).at_least(:once) test_configuration_result = nil - expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error + expect { test_configuration_result = lcm.test_configuration("config", {}) }.not_to raise_error expect(test_configuration_result.class).to be(Array) end end @@ -118,7 +118,7 @@ EOH it "should log a warning" do expect(Chef::Log).to receive(:warn).at_least(:once) expect(lcm).to receive(:dsc_module_import_failure?).and_call_original - expect {lcm.test_configuration("config", {})}.not_to raise_error + expect { lcm.test_configuration("config", {}) }.not_to raise_error end end end @@ -136,4 +136,3 @@ EOH end end end - diff --git a/spec/unit/util/dsc/resource_store.rb b/spec/unit/util/dsc/resource_store.rb index 5adcd378c0..84b39190b2 100644 --- a/spec/unit/util/dsc/resource_store.rb +++ b/spec/unit/util/dsc/resource_store.rb @@ -24,14 +24,14 @@ describe Chef::Util::DSC::ResourceStore do let(:resource_a) { { "ResourceType" => "AFoo", "Name" => "Foo", - "Module" => {"Name" => "ModuleA"}, + "Module" => { "Name" => "ModuleA" }, } } let(:resource_b) { { "ResourceType" => "BFoo", "Name" => "Foo", - "Module" => {"Name" => "ModuleB"}, + "Module" => { "Name" => "ModuleB" }, } } |