summaryrefslogtreecommitdiff
path: root/spec/unit/util
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2016-02-09 07:53:56 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2016-02-09 07:53:56 -0800
commitf073747786abbe6ada55ed24b696a03e39c3c45d (patch)
tree7971d871e89d522a58291713761a6c83f68e8d19 /spec/unit/util
parentc6e69783705cfd48bfea0c943dc071964dd21311 (diff)
downloadchef-f073747786abbe6ada55ed24b696a03e39c3c45d.tar.gz
auto fixing some rubocops
Style/NegatedWhile Style/ParenthesesAroundCondition Style/WhileUntilDo Style/WordArray Performance/ReverseEach Style/ColonMethodCall
Diffstat (limited to 'spec/unit/util')
-rw-r--r--spec/unit/util/backup_spec.rb6
-rw-r--r--spec/unit/util/dsc/configuration_generator_spec.rb6
-rw-r--r--spec/unit/util/dsc/lcm_output_parser_spec.rb20
-rw-r--r--spec/unit/util/editor_spec.rb16
4 files changed, 24 insertions, 24 deletions
diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb
index 3454e07692..2d20021b23 100644
--- a/spec/unit/util/backup_spec.rb
+++ b/spec/unit/util/backup_spec.rb
@@ -76,7 +76,7 @@ describe Chef::Util::Backup do
end
it "should keep only 1 backup copy" do
- expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b", "c"])
+ expect(@backup).to receive(:sorted_backup_files).and_return(%w(a b c))
expect(@backup).to receive(:delete_backup).with("b")
expect(@backup).to receive(:delete_backup).with("c")
@backup.backup!
@@ -89,13 +89,13 @@ describe Chef::Util::Backup do
end
it "should not delete anything if we only have one other backup" do
- expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b"])
+ expect(@backup).to receive(:sorted_backup_files).and_return(%w(a b))
expect(@backup).not_to receive(:delete_backup)
@backup.backup!
end
it "should keep only 2 backup copies" do
- expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b", "c", "d"])
+ expect(@backup).to receive(:sorted_backup_files).and_return(%w(a b c d))
expect(@backup).to receive(:delete_backup).with("c")
expect(@backup).to receive(:delete_backup).with("d")
@backup.backup!
diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb
index d59423e1e5..5b739c33c0 100644
--- a/spec/unit/util/dsc/configuration_generator_spec.rb
+++ b/spec/unit/util/dsc/configuration_generator_spec.rb
@@ -151,7 +151,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do
allow(File).to receive(:join) do |a, b|
[a, b].join("++")
end
- allow(Dir).to receive(:entries).with("tmp++hello") { ["f1", "f2", "f3"] }
+ allow(Dir).to receive(:entries).with("tmp++hello") { %w(f1 f2 f3) }
expect(conf_man.send(:find_configuration_document, "hello")).to be_nil
end
end
@@ -179,12 +179,12 @@ describe Chef::Util::DSC::ConfigurationGenerator do
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" => %w(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" => %w(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
diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb
index 69eb8724ea..d59497de6f 100644
--- a/spec/unit/util/dsc/lcm_output_parser_spec.rb
+++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb
@@ -24,11 +24,11 @@ describe Chef::Util::DSC::LocalConfigurationManager::Parser 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
@@ -40,7 +40,7 @@ logtype: [machinename]: LCM: [ Start Resource ] [name]
logtype: [machinename]: LCM: [ End Resource ] [name]
logtype: [machinename]: LCM: [ End Set ]
EOF
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
expect(resources.length).to eq(1)
expect(resources[0].name).to eq("[name]")
end
@@ -54,7 +54,7 @@ logtype: [machinename]: LCM: [ End Set ] [name]
logtype: [machinename]: LCM: [ End Resource ] [name]
logtype: [machinename]: LCM: [ End Set ]
EOF
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
expect(resources[0].changes_state?).to be_truthy
end
@@ -68,7 +68,7 @@ logtype: [machinename]: LCM: [ End Set ] [name]
logtype: [machinename]: LCM: [ End Resource ] [name]
logtype: [machinename]: LCM: [ End Set ]
EOF
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
expect(resources[0].change_log).to match_array(["[name]", "[message]", "[name]"])
end
@@ -80,7 +80,7 @@ logtype: [machinename]: LCM: [ Skip Set ] [name]
logtype: [machinename]: LCM: [ End Resource ] [name]
logtype: [machinename]: LCM: [ End Set ]
EOF
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
expect(resources[0].changes_state?).to be_falsey
end
@@ -92,7 +92,7 @@ logtype: [machinename]: LCM: [ Skip Set ] [name]
logtype: [machinename]: LCM: [ End Resource ] [name]
logtype: [machinename]: LCM: [ End Set ]
EOF
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
expect(resources[0].change_log).to be_empty
end
end
@@ -114,7 +114,7 @@ logtype: [machinename]: LCM: [ End Set ]
logtype: [machinename]: LCM: [ End Set ]
EOF
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
expect(resources[0].changes_state?).to be_falsey
expect(resources[1].changes_state?).to be_truthy
end
@@ -135,7 +135,7 @@ logtype: [machinename]: LCM: [ End Resource ]
logtype: [machinename]: LCM: [ End Set ]
EOF
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
expect(resources[0].changes_state?).to be_falsey
expect(resources[1].changes_state?).to be_truthy
end
@@ -154,7 +154,7 @@ logtype: [machinename]: LCM: [ End Set ]
logtype: [machinename]: LCM: [ End Resource ]
logtype: [machinename]: LCM: [ End Set ]
EOF
- resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)
+ resources = Chef::Util::DSC::LocalConfigurationManager::Parser.parse(str)
expect(resources[0].changes_state?).to be_truthy
expect(resources[0].name).to eql("[name]")
expect(resources[1].changes_state?).to be_truthy
diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb
index 9db7e85931..cdba502101 100644
--- a/spec/unit/util/editor_spec.rb
+++ b/spec/unit/util/editor_spec.rb
@@ -16,7 +16,7 @@ describe Chef::Util::Editor do
end
subject(:editor) { described_class.new(input_lines) }
- let(:input_lines) { ["one", "two", "two", "three"] }
+ let(:input_lines) { %w(one two two three) }
describe '#append_line_after' do
context "when there is no match" do
@@ -34,7 +34,7 @@ describe Chef::Util::Editor do
it("returns the number of added lines") { is_expected.to eq(2) }
it "adds a line after each match" do
execute
- expect(editor.lines).to be == ["one", "two", "new", "two", "new", "three"]
+ expect(editor.lines).to be == %w(one two new two new three)
end
end
@@ -51,7 +51,7 @@ describe Chef::Util::Editor do
it("returns the number of added lines") { is_expected.to eq(1) }
it "adds a line to the end" do
execute
- expect(editor.lines).to be == ["one", "two", "two", "three", "new"]
+ expect(editor.lines).to be == %w(one two two three new)
end
end
@@ -86,7 +86,7 @@ describe Chef::Util::Editor do
it("returns the number of removed lines") { is_expected.to eq(2) }
it "removes the matching lines" do
execute
- expect(editor.lines).to be == ["one", "three"]
+ expect(editor.lines).to be == %w(one three)
end
end
@@ -112,14 +112,14 @@ describe Chef::Util::Editor do
it("returns the number of changed lines") { is_expected.to eq(2) }
it "replaces the matching portions" do
execute
- expect(editor.lines).to be == ["one", "new", "new", "three"]
+ expect(editor.lines).to be == %w(one new new three)
end
end
it "matches a Regexp" do
expect(editor.replace(/^ee/, "new")).to be == 0
expect(editor.replace(/ee$/, "new")).to be == 1
- expect(editor.lines).to be == ["one", "two", "two", "thrnew"]
+ expect(editor.lines).to be == %w(one two two thrnew)
end
end
@@ -139,14 +139,14 @@ describe Chef::Util::Editor do
it("returns the number of replaced lines") { is_expected.to eq(2) }
it "replaces the matching line" do
execute
- expect(editor.lines).to be == ["one", "new", "new", "three"]
+ expect(editor.lines).to be == %w(one new new three)
end
end
it "matches a Regexp" do
expect(editor.replace_lines(/^ee/, "new")).to be == 0
expect(editor.replace_lines(/ee$/, "new")).to be == 1
- expect(editor.lines).to be == ["one", "two", "two", "new"]
+ expect(editor.lines).to be == %w(one two two new)
end
end
end