summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-02-13 09:52:10 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2017-02-13 09:52:10 -0800
commit404a9bc88be538769c6c80b3b31f39a6582991d2 (patch)
tree2f8795e5f64153440c22a522d669c235a627f289 /spec
parentb949a48acc21d4b64869bd7b834708d5232b1f2a (diff)
downloadchef-404a9bc88be538769c6c80b3b31f39a6582991d2.tar.gz
fix specs: RedundantReturn, RedundantSelf, RedundantBegin
department of redundancy department Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/dsc_script_spec.rb6
-rw-r--r--spec/functional/resource/user/dscl_spec.rb6
-rw-r--r--spec/integration/recipes/recipe_dsl_spec.rb62
-rw-r--r--spec/support/chef_helpers.rb12
-rw-r--r--spec/support/platforms/prof/gc.rb10
-rw-r--r--spec/unit/provider/deploy_spec.rb2
-rw-r--r--spec/unit/provider/package/ips_spec.rb4
7 files changed, 47 insertions, 55 deletions
diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb
index 8afcdbb590..ce92c468f0 100644
--- a/spec/functional/resource/dsc_script_spec.rb
+++ b/spec/functional/resource/dsc_script_spec.rb
@@ -65,10 +65,8 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do
end
def delete_user(target_user)
- begin
- shell_out!("net user #{target_user} /delete")
- rescue Mixlib::ShellOut::ShellCommandFailed
- end
+ shell_out!("net user #{target_user} /delete")
+ rescue Mixlib::ShellOut::ShellCommandFailed
end
let(:dsc_env_variable) { "chefenvtest" }
diff --git a/spec/functional/resource/user/dscl_spec.rb b/spec/functional/resource/user/dscl_spec.rb
index bedb37838c..ed96e31bac 100644
--- a/spec/functional/resource/user/dscl_spec.rb
+++ b/spec/functional/resource/user/dscl_spec.rb
@@ -28,11 +28,9 @@ describe "Chef::Resource::User with Chef::Provider::User::Dscl provider", metada
include Chef::Mixin::ShellOut
def clean_user
- begin
- shell_out!("/usr/bin/dscl . -delete '/Users/#{username}'")
- rescue Mixlib::ShellOut::ShellCommandFailed
+ shell_out!("/usr/bin/dscl . -delete '/Users/#{username}'")
+ rescue Mixlib::ShellOut::ShellCommandFailed
# Raised when the user is already cleaned
- end
end
def user_should_exist
diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb
index ce784b11ca..370d202678 100644
--- a/spec/integration/recipes/recipe_dsl_spec.rb
+++ b/spec/integration/recipes/recipe_dsl_spec.rb
@@ -861,7 +861,7 @@ describe "Recipe DSL methods" do
before { resource_class_a } # pull on it so it gets defined before the recipe runs
it "two_classes_one_dsl resolves to A (alphabetically earliest)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -891,7 +891,7 @@ describe "Recipe DSL methods" do
before { resource_class_z } # pull on it so it gets defined before the recipe runs
it "two_classes_one_dsl resolves to B (alphabetically earliest)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -909,7 +909,7 @@ describe "Recipe DSL methods" do
end
it "two_classes_one_dsl resolves to Z (respects the priority array)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -927,7 +927,7 @@ describe "Recipe DSL methods" do
end
it "two_classes_one_dsl resolves to B (picks the next thing in the priority array)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -948,7 +948,7 @@ describe "Recipe DSL methods" do
end
it "two_classes_one_dsl resolves to Z (respects the most recent priority array)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -966,7 +966,7 @@ describe "Recipe DSL methods" do
end
it "two_classes_one_dsl resolves to B (picks the first match from the other priority array)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -991,7 +991,7 @@ describe "Recipe DSL methods" do
end
it "two_classes_one_dsl resolves to B (picks the first match outside the priority array)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -1044,7 +1044,7 @@ describe "Recipe DSL methods" do
before { provider_class_a.provides two_classes_one_dsl }
it "two_classes_one_dsl resolves to A (alphabetically earliest)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -1056,7 +1056,7 @@ describe "Recipe DSL methods" do
before { provider_class_a.provides(two_classes_one_dsl) { false } }
it "two_classes_one_dsl resolves to B (since A declined)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -1085,7 +1085,7 @@ describe "Recipe DSL methods" do
before { provider_class_z.provides two_classes_one_dsl }
it "two_classes_one_dsl resolves to B (alphabetically earliest)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -1097,7 +1097,7 @@ describe "Recipe DSL methods" do
before { Chef.set_provider_priority_array two_classes_one_dsl, [ provider_class_z, provider_class ] }
it "two_classes_one_dsl resolves to Z (respects the priority map)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -1114,7 +1114,7 @@ describe "Recipe DSL methods" do
before { Chef.set_provider_priority_array two_classes_one_dsl, [ provider_class_z, provider_class ] }
it "two_classes_one_dsl resolves to B (the next one in the priority map)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -1128,7 +1128,7 @@ describe "Recipe DSL methods" do
before { Chef.set_provider_priority_array two_classes_one_dsl, [ provider_class ] }
it "two_classes_one_dsl resolves to B (the one in the next priority map)" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
instance_eval("#{two_classes_one_dsl} 'blah'")
end
@@ -1158,7 +1158,7 @@ describe "Recipe DSL methods" do
before { resource_class_blarghle } # pull on it so it gets defined before the recipe runs
it "on os = blarghle, two_classes_one_dsl resolves to Blarghle" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "blarghle"
@@ -1169,7 +1169,7 @@ describe "Recipe DSL methods" do
end
it "on os = linux, two_classes_one_dsl resolves to B" do
- two_classes_one_dsl = self.two_classes_one_dsl
+ two_classes_one_dsl = two_classes_one_dsl
recipe = converge do
# this is an ugly way to test, make Cheffish expose node attrs
run_context.node.automatic[:os] = "linux"
@@ -1202,7 +1202,7 @@ describe "Recipe DSL methods" do
context "with provides? returning true to my_resource" do
before do
- my_resource = self.my_resource
+ my_resource = my_resource
resource_class.define_singleton_method(:provides?) do |node, resource_name|
@called_provides = true
resource_name == my_resource
@@ -1210,7 +1210,7 @@ describe "Recipe DSL methods" do
end
it "my_resource returns the resource and calls provides?, but does not emit a warning" do
- dsl_name = self.my_resource
+ dsl_name = my_resource
recipe = converge do
instance_eval("#{dsl_name} 'foo'")
end
@@ -1222,7 +1222,7 @@ describe "Recipe DSL methods" do
context "with provides? returning true to blarghle_blarghle_little_star and not resource_name" do
before do
- blarghle_blarghle_little_star = self.blarghle_blarghle_little_star
+ blarghle_blarghle_little_star = blarghle_blarghle_little_star
resource_class.define_singleton_method(:provides?) do |node, resource_name|
@called_provides = true
resource_name == blarghle_blarghle_little_star
@@ -1230,7 +1230,7 @@ describe "Recipe DSL methods" do
end
it "my_resource does not return the resource" do
- dsl_name = self.my_resource
+ dsl_name = my_resource
expect_converge do
instance_eval("#{dsl_name} 'foo'")
end.to raise_error(Chef::Exceptions::NoSuchResourceType)
@@ -1239,7 +1239,7 @@ describe "Recipe DSL methods" do
it "blarghle_blarghle_little_star 'foo' returns the resource and emits a warning" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- dsl_name = self.blarghle_blarghle_little_star
+ dsl_name = blarghle_blarghle_little_star
recipe = converge do
instance_eval("#{dsl_name} 'foo'")
end
@@ -1281,7 +1281,7 @@ describe "Recipe DSL methods" do
end
it "my_resource runs the provider and does not emit a warning" do
- my_resource = self.my_resource
+ my_resource = my_resource
recipe = converge do
instance_eval("#{my_resource} 'foo'")
end
@@ -1311,7 +1311,7 @@ describe "Recipe DSL methods" do
end
it "my_resource runs the first provider" do
- my_resource = self.my_resource
+ my_resource = my_resource
recipe = converge do
instance_eval("#{my_resource} 'foo'")
end
@@ -1328,7 +1328,7 @@ describe "Recipe DSL methods" do
# TODO no warning? ick
it "my_resource runs the provider anyway" do
- my_resource = self.my_resource
+ my_resource = my_resource
recipe = converge do
instance_eval("#{my_resource} 'foo'")
end
@@ -1338,7 +1338,7 @@ describe "Recipe DSL methods" do
context "and another provider supporting :my_resource with supports? true" do
let(:provider_class2) do
- my_resource = self.my_resource
+ my_resource = my_resource
Class.new(BaseThingy::Provider) do
def self.name
"MyProvider2"
@@ -1360,7 +1360,7 @@ describe "Recipe DSL methods" do
before { provider_class2 } # make sure the provider class shows up
it "my_resource runs the other provider" do
- my_resource = self.my_resource
+ my_resource = my_resource
recipe = converge do
instance_eval("#{my_resource} 'foo'")
end
@@ -1373,7 +1373,7 @@ describe "Recipe DSL methods" do
context "with provides? returning true" do
before do
- my_resource = self.my_resource
+ my_resource = my_resource
provider_class.define_singleton_method(:provides?) do |node, resource|
@called_provides = true
resource.declared_type == my_resource
@@ -1386,7 +1386,7 @@ describe "Recipe DSL methods" do
end
it "my_resource calls the provider (and calls provides?), but does not emit a warning" do
- my_resource = self.my_resource
+ my_resource = my_resource
recipe = converge do
instance_eval("#{my_resource} 'foo'")
end
@@ -1399,7 +1399,7 @@ describe "Recipe DSL methods" do
context "that does not call provides :my_resource" do
it "my_resource calls the provider (and calls provides?), and emits a warning" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- my_resource = self.my_resource
+ my_resource = my_resource
recipe = converge do
instance_eval("#{my_resource} 'foo'")
end
@@ -1412,7 +1412,7 @@ describe "Recipe DSL methods" do
context "with provides? returning false to my_resource" do
before do
- my_resource = self.my_resource
+ my_resource = my_resource
provider_class.define_singleton_method(:provides?) do |node, resource|
@called_provides = true
false
@@ -1426,7 +1426,7 @@ describe "Recipe DSL methods" do
it "my_resource fails to find a provider (and calls provides)" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- my_resource = self.my_resource
+ my_resource = my_resource
expect_converge do
instance_eval("#{my_resource} 'foo'")
end.to raise_error(Chef::Exceptions::ProviderNotFound)
@@ -1437,7 +1437,7 @@ describe "Recipe DSL methods" do
context "that does not provide :my_resource" do
it "my_resource fails to find a provider (and calls provides)" do
Chef::Config[:treat_deprecation_warnings_as_errors] = false
- my_resource = self.my_resource
+ my_resource = my_resource
expect_converge do
instance_eval("#{my_resource} 'foo'")
end.to raise_error(Chef::Exceptions::ProviderNotFound)
diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb
index d0b5ad0bfd..444e5a30c8 100644
--- a/spec/support/chef_helpers.rb
+++ b/spec/support/chef_helpers.rb
@@ -53,13 +53,11 @@ end
# This is a temporary fix to get tests passing on systems that have no `diff`
# until we can replace shelling out to `diff` with ruby diff-lcs
def has_diff?
- begin
- diff_cmd = Mixlib::ShellOut.new("diff -v")
- diff_cmd.run_command
- true
- rescue Errno::ENOENT
- false
- end
+ diff_cmd = Mixlib::ShellOut.new("diff -v")
+ diff_cmd.run_command
+ true
+rescue Errno::ENOENT
+ false
end
# This is a helper to determine if the ruby in the PATH contains
diff --git a/spec/support/platforms/prof/gc.rb b/spec/support/platforms/prof/gc.rb
index 2e1b45c294..b494ff9646 100644
--- a/spec/support/platforms/prof/gc.rb
+++ b/spec/support/platforms/prof/gc.rb
@@ -35,12 +35,10 @@ module RSpec
end
def working_set_size
- begin
- ::GC.start
- ::GC::Profiler.result.scan(LINE_PATTERN)[-1][2].to_i if ::GC::Profiler.enabled?
- ensure
- ::GC::Profiler.clear
- end
+ ::GC.start
+ ::GC::Profiler.result.scan(LINE_PATTERN)[-1][2].to_i if ::GC::Profiler.enabled?
+ ensure
+ ::GC::Profiler.clear
end
def handle_count
diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb
index b30ddb736a..b0ede7e260 100644
--- a/spec/unit/provider/deploy_spec.rb
+++ b/spec/unit/provider/deploy_spec.rb
@@ -595,7 +595,7 @@ describe Chef::Provider::Deploy do
callback_code = Proc.new do
snitch = 42
- temp_collection = self.resource_collection
+ temp_collection = resource_collection
run("tehMice")
snitch = temp_collection.lookup("execute[tehMice]")
end
diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb
index 156adf402a..3bbdd26ce3 100644
--- a/spec/unit/provider/package/ips_spec.rb
+++ b/spec/unit/provider/package/ips_spec.rb
@@ -41,7 +41,7 @@ installed on the system. Try specifying -r to query remotely:
crypto/gnupg
PKG_STATUS
- return OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1)
+ OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 1)
end
def remote_output
@@ -59,7 +59,7 @@ Packaging Date: April 1, 2012 05:55:52 PM
PKG_STATUS
stdin = StringIO.new
stderr = ""
- return OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0)
+ OpenStruct.new(:stdout => stdout, :stdin => stdin, :stderr => stderr, :status => @status, :exitstatus => 0)
end
context "when loading current resource" do