diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-02-05 15:00:00 -0800 |
commit | 686113531d23f30e9973d659c456ae33eb9cff1f (patch) | |
tree | f225de7251a8b49b8d183dd168bab0a0addbe23f /spec/unit/util | |
parent | d1cf34b059a16a81e0fc48de52ba29863bb41fe6 (diff) | |
download | chef-686113531d23f30e9973d659c456ae33eb9cff1f.tar.gz |
autofixing whitespace cops
4174 Style/SpaceInsideHashLiteralBraces
1860 Style/SpaceAroundOperators
1336 Style/SpaceInsideBlockBraces
1292 Style/AlignHash
997 Style/SpaceAfterComma
860 Style/SpaceAroundEqualsInParameterDefault
310 Style/EmptyLines
294 Style/IndentationConsistency
267 Style/TrailingWhitespace
238 Style/ExtraSpacing
212 Style/SpaceBeforeBlockBraces
166 Style/MultilineOperationIndentation
144 Style/TrailingBlankLines
120 Style/EmptyLineBetweenDefs
101 Style/IndentationWidth
82 Style/SpaceAroundBlockParameters
40 Style/EmptyLinesAroundMethodBody
29 Style/EmptyLinesAroundAccessModifier
1 Style/RescueEnsureAlignment
Diffstat (limited to 'spec/unit/util')
-rw-r--r-- | spec/unit/util/backup_spec.rb | 1 | ||||
-rw-r--r-- | spec/unit/util/diff_spec.rb | 7 | ||||
-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 | ||||
-rw-r--r-- | spec/unit/util/file_edit_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/util/powershell/cmdlet_spec.rb | 16 | ||||
-rw-r--r-- | spec/unit/util/powershell/ps_credential_spec.rb | 2 | ||||
-rw-r--r-- | spec/unit/util/selinux_spec.rb | 9 |
10 files changed, 45 insertions, 51 deletions
diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb index 8d7caff8d6..3454e07692 100644 --- a/spec/unit/util/backup_spec.rb +++ b/spec/unit/util/backup_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # - require "spec_helper" require "tmpdir" diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb index 8a2bef2858..29c645bb1d 100644 --- a/spec/unit/util/diff_spec.rb +++ b/spec/unit/util/diff_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # - require "spec_helper" require "tmpdir" @@ -553,11 +552,11 @@ describe Chef::Util::Diff, :uses_diff => true do let(:plain_ascii) { "This is a text file.\nWith more than one line.\nAnd a \tTab.\nAnd lets make sure that other printable chars work too: ~!@\#$%^&*()`:\"<>?{}|_+,./;'[]\\-=\n" } # these are all byte sequences that are illegal in the other encodings... (but they may legally transcode) - let(:utf_8) { "testing utf-8 unicode...\n\n\non a new line: \xE2\x80\x93\n" } # unicode em-dash + let(:utf_8) { "testing utf-8 unicode...\n\n\non a new line: \xE2\x80\x93\n" } # unicode em-dash let(:latin_1) { "It is more metal.\nif you have an \xFDmlaut.\n" } # NB: changed to y-with-diaresis, but i'm American so I don't know the difference let(:shift_jis) { "I have no idea what this character is:\n \x83\x80.\n" } # seriously, no clue, but \x80 is nice and illegal in other encodings - let(:differ) do # subject + let(:differ) do # subject differ = Chef::Util::Diff.new differ.diff(old_file, new_file) differ @@ -569,11 +568,9 @@ describe Chef::Util::Diff, :uses_diff => true do it_behaves_like "a diff util" end - describe "when file path doesn't have spaces" do include_context "using file paths without spaces" it_behaves_like "a diff util" end end - 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" }, } } diff --git a/spec/unit/util/file_edit_spec.rb b/spec/unit/util/file_edit_spec.rb index af8dd4907d..1a71d1d856 100644 --- a/spec/unit/util/file_edit_spec.rb +++ b/spec/unit/util/file_edit_spec.rb @@ -111,7 +111,7 @@ twice end it "should throw an exception if the input file does not exist" do - expect{Chef::Util::FileEdit.new("nonexistfile")}.to raise_error(ArgumentError) + expect { Chef::Util::FileEdit.new("nonexistfile") }.to raise_error(ArgumentError) end # CHEF-5018: people have monkey patched this and it has accidentally been broken @@ -124,7 +124,7 @@ twice let(:hosts_content) { "" } it "should not throw an exception" do - expect{ fedit }.not_to raise_error + expect { fedit }.not_to raise_error end end diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb index 2d6b34ded8..5c0e66aee2 100644 --- a/spec/unit/util/powershell/cmdlet_spec.rb +++ b/spec/unit/util/powershell/cmdlet_spec.rb @@ -69,38 +69,38 @@ describe Chef::Util::Powershell::Cmdlet do describe '#command_switches_string' do it "raises an ArgumentError if the key is not a symbol" do expect { - @cmdlet.send(:command_switches_string, {"foo" => "bar"}) + @cmdlet.send(:command_switches_string, { "foo" => "bar" }) }.to raise_error(ArgumentError) end it "does not allow invalid switch names" do expect { - @cmdlet.send(:command_switches_string, {:foo! => "bar"}) + @cmdlet.send(:command_switches_string, { :foo! => "bar" }) }.to raise_error(ArgumentError) end it "ignores switches with a false value" do - expect(@cmdlet.send(:command_switches_string, {foo: false})).to eql("") + expect(@cmdlet.send(:command_switches_string, { foo: false })).to eql("") end it "should correctly handle a value type of string" do - expect(@cmdlet.send(:command_switches_string, {foo: "bar"})).to eql("-foo 'bar'") + expect(@cmdlet.send(:command_switches_string, { foo: "bar" })).to eql("-foo 'bar'") end it "should correctly handle a value type of string even when it is 0 length" do - expect(@cmdlet.send(:command_switches_string, {foo: ""})).to eql("-foo ''") + expect(@cmdlet.send(:command_switches_string, { foo: "" })).to eql("-foo ''") end it "should not quote integers" do - expect(@cmdlet.send(:command_switches_string, {foo: 1})).to eql("-foo 1") + expect(@cmdlet.send(:command_switches_string, { foo: 1 })).to eql("-foo 1") end it "should not quote floats" do - expect(@cmdlet.send(:command_switches_string, {foo: 1.0})).to eql("-foo 1.0") + expect(@cmdlet.send(:command_switches_string, { foo: 1.0 })).to eql("-foo 1.0") end it "has just the switch when the value is true" do - expect(@cmdlet.send(:command_switches_string, {foo: true})).to eql("-foo") + expect(@cmdlet.send(:command_switches_string, { foo: true })).to eql("-foo") end end end diff --git a/spec/unit/util/powershell/ps_credential_spec.rb b/spec/unit/util/powershell/ps_credential_spec.rb index 88e772c4e6..6f65174d15 100644 --- a/spec/unit/util/powershell/ps_credential_spec.rb +++ b/spec/unit/util/powershell/ps_credential_spec.rb @@ -24,7 +24,7 @@ describe Chef::Util::Powershell::PSCredential do let (:password) { "ThIsIsThEpAsSwOrD" } context "when username and password are provided" do - let(:ps_credential) { Chef::Util::Powershell::PSCredential.new(username, password)} + let(:ps_credential) { Chef::Util::Powershell::PSCredential.new(username, password) } context "when calling to_psobject" do it "should create the script to create a PSCredential when calling" do allow(ps_credential).to receive(:encrypt).with(password).and_return("encrypted") diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb index 205553aa0c..609ff02215 100644 --- a/spec/unit/util/selinux_spec.rb +++ b/spec/unit/util/selinux_spec.rb @@ -16,7 +16,6 @@ # limitations under the License. # - require "spec_helper" describe Chef::Util::Selinux do @@ -62,7 +61,7 @@ describe Chef::Util::Selinux do describe "when selinux is enabled" do before do cmd_result = double("Cmd Result", :exitstatus => 0) - expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result) + expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result) end it "should report selinux is enabled" do @@ -75,7 +74,7 @@ describe Chef::Util::Selinux do describe "when selinux is disabled" do before do cmd_result = double("Cmd Result", :exitstatus => 1) - expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result) + expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result) end it "should report selinux is disabled" do @@ -88,11 +87,11 @@ describe Chef::Util::Selinux do describe "when selinux gives an unexpected status" do before do cmd_result = double("Cmd Result", :exitstatus => 101) - expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, {:returns=>[0, 1]}).and_return(cmd_result) + expect(@test_instance).to receive(:shell_out!).once.with(@selinux_enabled_path, { :returns => [0, 1] }).and_return(cmd_result) end it "should throw an error" do - expect {@test_instance.selinux_enabled?}.to raise_error(RuntimeError) + expect { @test_instance.selinux_enabled? }.to raise_error(RuntimeError) end end end |