summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/chef_helpers.rb1
-rw-r--r--spec/support/lib/chef/resource/cat.rb4
-rw-r--r--spec/support/lib/chef/resource/one_two_three_four.rb2
-rw-r--r--spec/support/lib/chef/resource/openldap_includer.rb1
-rw-r--r--spec/support/lib/chef/resource/zen_follower.rb2
-rw-r--r--spec/support/lib/chef/resource/zen_master.rb3
-rw-r--r--spec/support/lib/library_load_order.rb2
-rw-r--r--spec/support/matchers/leak.rb4
-rw-r--r--spec/support/mock/constant.rb2
-rw-r--r--spec/support/mock/platform.rb8
-rw-r--r--spec/support/platform_helpers.rb9
-rw-r--r--spec/support/platforms/prof/gc.rb1
-rw-r--r--spec/support/platforms/prof/win32.rb1
-rw-r--r--spec/support/shared/context/client.rb8
-rw-r--r--spec/support/shared/examples/client.rb4
-rw-r--r--spec/support/shared/functional/diff_disabled.rb2
-rw-r--r--spec/support/shared/functional/directory_resource.rb2
-rw-r--r--spec/support/shared/functional/file_resource.rb29
-rw-r--r--spec/support/shared/functional/http.rb3
-rw-r--r--spec/support/shared/functional/securable_resource.rb2
-rw-r--r--spec/support/shared/functional/securable_resource_with_reporting.rb8
-rw-r--r--spec/support/shared/functional/win32_service.rb2
-rw-r--r--spec/support/shared/functional/windows_script.rb4
-rw-r--r--spec/support/shared/integration/integration_helper.rb4
-rw-r--r--spec/support/shared/matchers/exit_with_code.rb2
-rw-r--r--spec/support/shared/unit/api_error_inspector.rb2
-rw-r--r--spec/support/shared/unit/api_versioning.rb6
-rw-r--r--spec/support/shared/unit/knife_shared.rb1
-rw-r--r--spec/support/shared/unit/mock_shellout.rb3
-rw-r--r--spec/support/shared/unit/platform_introspector.rb12
-rw-r--r--spec/support/shared/unit/provider/file.rb28
-rw-r--r--spec/support/shared/unit/provider/useradd_based_user_provider.rb37
-rw-r--r--spec/support/shared/unit/resource/static_provider_resolution.rb5
-rw-r--r--spec/support/shared/unit/script_resource.rb2
-rw-r--r--spec/support/shared/unit/user_and_client_shared.rb7
-rw-r--r--spec/support/shared/unit/windows_script_resource.rb1
36 files changed, 95 insertions, 119 deletions
diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb
index a7c3b849cd..aa60737c86 100644
--- a/spec/support/chef_helpers.rb
+++ b/spec/support/chef_helpers.rb
@@ -25,7 +25,6 @@ Chef::Log.init(StringIO.new)
Chef::Log.level(Chef::Config.log_level)
Chef::Config.solo(false)
-
def sha256_checksum(path)
OpenSSL::Digest::SHA256.hexdigest(File.read(path))
end
diff --git a/spec/support/lib/chef/resource/cat.rb b/spec/support/lib/chef/resource/cat.rb
index 44acddb653..94190e1f5b 100644
--- a/spec/support/lib/chef/resource/cat.rb
+++ b/spec/support/lib/chef/resource/cat.rb
@@ -22,12 +22,12 @@ class Chef
attr_accessor :action
- def initialize(name, run_context=nil)
+ def initialize(name, run_context = nil)
super
@action = "sell"
end
- def pretty_kitty(arg=nil)
+ def pretty_kitty(arg = nil)
if arg == true or arg == false
@pretty_kitty = arg
end
diff --git a/spec/support/lib/chef/resource/one_two_three_four.rb b/spec/support/lib/chef/resource/one_two_three_four.rb
index efeeff0710..d46d20d2b5 100644
--- a/spec/support/lib/chef/resource/one_two_three_four.rb
+++ b/spec/support/lib/chef/resource/one_two_three_four.rb
@@ -26,7 +26,7 @@ class Chef
@i_can_count = tf
end
- def something(arg=nil)
+ def something(arg = nil)
if arg == true or arg == false
@something = arg
end
diff --git a/spec/support/lib/chef/resource/openldap_includer.rb b/spec/support/lib/chef/resource/openldap_includer.rb
index 7a284cfc61..5a7651b10d 100644
--- a/spec/support/lib/chef/resource/openldap_includer.rb
+++ b/spec/support/lib/chef/resource/openldap_includer.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
class Chef
class Resource
class OpenldapIncluder < Chef::Resource::LWRPBase
diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb
index 135aeb1513..84fc71cc99 100644
--- a/spec/support/lib/chef/resource/zen_follower.rb
+++ b/spec/support/lib/chef/resource/zen_follower.rb
@@ -24,7 +24,7 @@ class Chef
provides :follower, platform: "zen"
- def master(arg=nil)
+ def master(arg = nil)
if !arg.nil?
@master = arg
end
diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb
index 530f2ea703..f5137c18ec 100644
--- a/spec/support/lib/chef/resource/zen_master.rb
+++ b/spec/support/lib/chef/resource/zen_master.rb
@@ -26,12 +26,11 @@ class Chef
attr_reader :peace
-
def peace(tf)
@peace = tf
end
- def something(arg=nil)
+ def something(arg = nil)
if !arg.nil?
@something = arg
end
diff --git a/spec/support/lib/library_load_order.rb b/spec/support/lib/library_load_order.rb
index c47a2f2c74..6b4c54fe4f 100644
--- a/spec/support/lib/library_load_order.rb
+++ b/spec/support/lib/library_load_order.rb
@@ -18,5 +18,3 @@ module LibraryLoadOrder
load_order << file
end
end
-
-
diff --git a/spec/support/matchers/leak.rb b/spec/support/matchers/leak.rb
index 0e31415940..f50a1bf5f7 100644
--- a/spec/support/matchers/leak.rb
+++ b/spec/support/matchers/leak.rb
@@ -20,7 +20,7 @@ module Matchers
module LeakBase
include RSpec::Matchers
- def initialize(opts={}, &block)
+ def initialize(opts = {}, &block)
@warmup = opts[:warmup] || 5
@iterations = opts[:iterations] || 100
@variance = opts[:variance] || 5000
@@ -35,6 +35,7 @@ module Matchers
end
private
+
def match(measure, given_proc)
profiler.start
@@ -90,6 +91,7 @@ module Matchers
def leak_memory(opts, &block)
Matchers::LeakMemory.new(opts, &block)
end
+
def leak_handles(opts, &block)
Matchers::LeakHandles.new(opts, &block)
end
diff --git a/spec/support/mock/constant.rb b/spec/support/mock/constant.rb
index 98756d715f..a2abc1905e 100644
--- a/spec/support/mock/constant.rb
+++ b/spec/support/mock/constant.rb
@@ -9,7 +9,7 @@ def mock_constants(constants, &block)
constants.each do |constant, val|
source_object, const_name = parse_constant(constant)
saved_constants[constant] = source_object.const_get(const_name)
- with_warnings(nil) {source_object.const_set(const_name, val) }
+ with_warnings(nil) { source_object.const_set(const_name, val) }
end
begin
diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb
index a8bbf13589..ef94678b64 100644
--- a/spec/support/mock/platform.rb
+++ b/spec/support/mock/platform.rb
@@ -16,10 +16,10 @@ def platform_mock(platform = :unix, &block)
end
if block_given?
- mock_constants({"RUBY_PLATFORM" => (platform == :windows ? "i386-mingw32" : "x86_64-darwin11.2.0"),
- "File::PATH_SEPARATOR" => (platform == :windows ? ";" : ":"),
- "File::ALT_SEPARATOR" => (platform == :windows ? "\\" : nil) }) do
-yield
+ mock_constants({ "RUBY_PLATFORM" => (platform == :windows ? "i386-mingw32" : "x86_64-darwin11.2.0"),
+ "File::PATH_SEPARATOR" => (platform == :windows ? ";" : ":"),
+ "File::ALT_SEPARATOR" => (platform == :windows ? "\\" : nil) }) do
+ yield
end
end
end
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index a29cb61d00..b50c2a01f0 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -65,10 +65,10 @@ def windows_2008r2_or_later?
host = wmi.first_of("Win32_OperatingSystem")
version = host["version"]
return false unless version
- components = version.split(".").map do | component |
+ components = version.split(".").map do |component|
component.to_i
end
- components.length >=2 && components[0] >= 6 && components[1] >= 1
+ components.length >= 2 && components[0] >= 6 && components[1] >= 1
end
def windows_powershell_dsc?
@@ -114,7 +114,6 @@ def mac_osx?
false
end
-
# detects if the hardware is 64-bit (evaluates to true in "WOW64" mode in a 32-bit app on a 64-bit system)
def windows64?
windows? && ( ENV["PROCESSOR_ARCHITECTURE"] == "AMD64" || ENV["PROCESSOR_ARCHITEW6432"] == "AMD64" )
@@ -166,7 +165,7 @@ def selinux_enabled?
# specs independent of product.
selinuxenabled_path = which("selinuxenabled")
if selinuxenabled_path
- cmd = Mixlib::ShellOut.new(selinuxenabled_path, :returns => [0,1])
+ cmd = Mixlib::ShellOut.new(selinuxenabled_path, :returns => [0, 1])
cmd_result = cmd.run_command
case cmd_result.exitstatus
when 1
@@ -213,7 +212,7 @@ class GCEDetector
end
def gce?
- GCEDetector.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR,80)
+ GCEDetector.can_metadata_connect?(Ohai::Mixin::GCEMetadata::GCE_METADATA_ADDR, 80)
rescue SocketError
false
end
diff --git a/spec/support/platforms/prof/gc.rb b/spec/support/platforms/prof/gc.rb
index 81fb28dda7..2e1b45c294 100644
--- a/spec/support/platforms/prof/gc.rb
+++ b/spec/support/platforms/prof/gc.rb
@@ -51,4 +51,3 @@ module RSpec
end
end
end
-
diff --git a/spec/support/platforms/prof/win32.rb b/spec/support/platforms/prof/win32.rb
index 61e9eec853..1cfbecc95d 100644
--- a/spec/support/platforms/prof/win32.rb
+++ b/spec/support/platforms/prof/win32.rb
@@ -43,4 +43,3 @@ module RSpec
end
end
end
-
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index 3c88e36fbb..d8676ef168 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -98,7 +98,7 @@ shared_context "a client run" do
# previous step.
expect(Chef::ServerAPI).to receive(:new).
with(Chef::Config[:chef_server_url], client_name: fqdn,
- signing_key_filename: Chef::Config[:client_key]).
+ signing_key_filename: Chef::Config[:client_key]).
exactly(:once).
and_return(http_node_load)
@@ -123,7 +123,7 @@ shared_context "a client run" do
expect_any_instance_of(Chef::CookbookSynchronizer).to receive(:sync_cookbooks)
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url]).and_return(http_cookbook_sync)
expect(http_cookbook_sync).to receive(:post).
- with("environments/_default/cookbook_versions", {:run_list => []}).
+ with("environments/_default/cookbook_versions", { :run_list => [] }).
and_return({})
end
@@ -183,7 +183,7 @@ shared_context "converge completed" do
# --Client#save_updated_node
expect(Chef::ServerAPI).to receive(:new).with(Chef::Config[:chef_server_url], client_name: fqdn,
- signing_key_filename: Chef::Config[:client_key], validate_utf8: false).and_return(http_node_save)
+ signing_key_filename: Chef::Config[:client_key], validate_utf8: false).and_return(http_node_save)
expect(http_node_save).to receive(:put).with("nodes/#{fqdn}", node.for_json).and_return(true)
end
end
@@ -231,7 +231,7 @@ end
shared_context "audit phase completed with failed controls" do
let(:audit_runner) { instance_double("Chef::Audit::Runner", :failed? => true,
- :num_failed => 1, :num_total => 3) }
+ :num_failed => 1, :num_total => 3) }
let(:audit_error) do
err = Chef::Exceptions::AuditsFailed.new(audit_runner.num_failed, audit_runner.num_total)
diff --git a/spec/support/shared/examples/client.rb b/spec/support/shared/examples/client.rb
index 5af63dc307..3c13cd767e 100644
--- a/spec/support/shared/examples/client.rb
+++ b/spec/support/shared/examples/client.rb
@@ -24,7 +24,7 @@ shared_examples "a completed run with audit failure" do
end
it "converges, runs audits, saves the node and raises the error in a wrapping error" do
- expect{ client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error|
+ expect { client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error|
expect(error.wrapped_errors.size).to eq(run_errors.size)
run_errors.each do |run_error|
expect(error.wrapped_errors).to include(run_error)
@@ -42,7 +42,7 @@ shared_examples "a failed run" do
include_context "run failed"
it "skips node save and raises the error in a wrapping error" do
- expect{ client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error|
+ expect { client.run }.to raise_error(Chef::Exceptions::RunFailedWrappingError) do |error|
expect(error.wrapped_errors.size).to eq(run_errors.size)
run_errors.each do |run_error|
expect(error.wrapped_errors).to include(run_error)
diff --git a/spec/support/shared/functional/diff_disabled.rb b/spec/support/shared/functional/diff_disabled.rb
index 7ee9808a94..c40b1e6e49 100644
--- a/spec/support/shared/functional/diff_disabled.rb
+++ b/spec/support/shared/functional/diff_disabled.rb
@@ -1,5 +1,5 @@
-shared_context "diff disabled" do
+shared_context "diff disabled" do
before do
Chef::Config[:diff_disabled] = true
end
diff --git a/spec/support/shared/functional/directory_resource.rb b/spec/support/shared/functional/directory_resource.rb
index 88e716b498..084cd43009 100644
--- a/spec/support/shared/functional/directory_resource.rb
+++ b/spec/support/shared/functional/directory_resource.rb
@@ -20,7 +20,7 @@ shared_examples_for "a directory resource" do
include_context "diff disabled"
- let(:expect_updated?) {true}
+ let(:expect_updated?) { true }
context "when the target directory does not exist" do
before do
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index c7a9611786..5f34f1efe6 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -44,7 +44,6 @@ shared_context "deploying via destdir" do
end
end
-
shared_examples_for "a file with the wrong content" do
before do
# Assert starting state is as expected
@@ -103,7 +102,7 @@ shared_examples_for "a file with the wrong content" do
end
it "raises an exception" do
- expect{ resource.run_action(:create) }.to raise_error(Chef::Exceptions::ChecksumMismatch)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::ChecksumMismatch)
end
end
end
@@ -308,14 +307,14 @@ shared_examples_for "a file resource" do
describe "when setting atomic_update" do
it "booleans should work" do
- expect {resource.atomic_update(true)}.not_to raise_error
- expect {resource.atomic_update(false)}.not_to raise_error
+ expect { resource.atomic_update(true) }.not_to raise_error
+ expect { resource.atomic_update(false) }.not_to raise_error
end
it "anything else should raise an error" do
- expect {resource.atomic_update(:copy)}.to raise_error(ArgumentError)
- expect {resource.atomic_update(:move)}.to raise_error(ArgumentError)
- expect {resource.atomic_update(958)}.to raise_error(ArgumentError)
+ expect { resource.atomic_update(:copy) }.to raise_error(ArgumentError)
+ expect { resource.atomic_update(:move) }.to raise_error(ArgumentError)
+ expect { resource.atomic_update(958) }.to raise_error(ArgumentError)
end
end
@@ -351,13 +350,13 @@ shared_examples_for "file resource not pointing to a real file" do
describe "when force_unlink is set to false" do
it ":create raises an error" do
- expect {resource.run_action(:create) }.to raise_error(Chef::Exceptions::FileTypeMismatch)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::FileTypeMismatch)
end
end
describe "when force_unlink is not set (default)" do
it ":create raises an error" do
- expect {resource.run_action(:create) }.to raise_error(Chef::Exceptions::FileTypeMismatch)
+ expect { resource.run_action(:create) }.to raise_error(Chef::Exceptions::FileTypeMismatch)
end
end
end
@@ -405,7 +404,6 @@ shared_examples_for "a configured file resource" do
File.join(CHEF_SPEC_DATA, "file-test-target")
}
-
describe "when configured not to manage symlink's target" do
before(:each) do
# configure not to manage symlink source
@@ -574,7 +572,6 @@ shared_examples_for "a configured file resource" do
File.open(path, "wb") { |f| f.write(expected_content) }
end
-
include_context "setup broken permissions"
include_examples "a securable resource with existing target"
@@ -721,7 +718,7 @@ shared_examples_for "a configured file resource" do
it_behaves_like "file resource not pointing to a real file"
end
- context "when the target file is a blockdev",:unix_only, :requires_root, :not_supported_on_solaris do
+ context "when the target file is a blockdev", :unix_only, :requires_root, :not_supported_on_solaris do
include Chef::Mixin::ShellOut
let(:path) do
File.join(CHEF_SPEC_DATA, "testdev")
@@ -739,7 +736,7 @@ shared_examples_for "a configured file resource" do
it_behaves_like "file resource not pointing to a real file"
end
- context "when the target file is a chardev",:unix_only, :requires_root, :not_supported_on_solaris do
+ context "when the target file is a chardev", :unix_only, :requires_root, :not_supported_on_solaris do
include Chef::Mixin::ShellOut
let(:path) do
File.join(CHEF_SPEC_DATA, "testdev")
@@ -757,7 +754,7 @@ shared_examples_for "a configured file resource" do
it_behaves_like "file resource not pointing to a real file"
end
- context "when the target file is a pipe",:unix_only do
+ context "when the target file is a pipe", :unix_only do
include Chef::Mixin::ShellOut
let(:path) do
File.join(CHEF_SPEC_DATA, "testpipe")
@@ -775,7 +772,7 @@ shared_examples_for "a configured file resource" do
it_behaves_like "file resource not pointing to a real file"
end
- context "when the target file is a socket",:unix_only do
+ context "when the target file is a socket", :unix_only do
require "socket"
# It turns out that the path to a socket can have at most ~104
@@ -1018,7 +1015,7 @@ shared_examples_for "a configured file resource" do
end
-shared_context Chef::Resource::File do
+shared_context Chef::Resource::File do
if windows?
require "chef/win32/file"
end
diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb
index 2779730268..8e6b5bfa89 100644
--- a/spec/support/shared/functional/http.rb
+++ b/spec/support/shared/functional/http.rb
@@ -37,7 +37,7 @@ module ChefHTTPShared
content
end
- def start_tiny_server(server_opts={})
+ def start_tiny_server(server_opts = {})
nyan_uncompressed_size = File::Stat.new(nyan_uncompressed_filename).size
nyan_compressed_size = File::Stat.new(nyan_compressed_filename).size
@@ -162,7 +162,6 @@ module ChefHTTPShared
#
@api.get("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }')
@api.post("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }')
-
end
def stop_tiny_server
diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb
index 330183ebb1..dd8a0216bc 100644
--- a/spec/support/shared/functional/securable_resource.rb
+++ b/spec/support/shared/functional/securable_resource.rb
@@ -515,7 +515,7 @@ shared_examples_for "a securable resource without existing target" do
resource.inherits(false)
resource.run_action(:create)
- descriptor.dacl.each do | ace |
+ descriptor.dacl.each do |ace|
expect(ace.inherited?).to eq(false)
end
end
diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb
index c9b5bae465..0bec29783a 100644
--- a/spec/support/shared/functional/securable_resource_with_reporting.rb
+++ b/spec/support/shared/functional/securable_resource_with_reporting.rb
@@ -21,7 +21,6 @@ ALL_EXPANDED_PERMISSIONS = ["generic read",
"read attributes",
"write attributes"]
-
shared_examples_for "a securable resource with reporting" do
include_context "diff disabled"
@@ -273,7 +272,6 @@ shared_examples_for "a securable resource with reporting" do
# Windows reporting data should look like this (+/- ish):
# { "owner" => "bob", "checksum" => "ffff", "access control" => { "bob" => { "permissions" => ["perm1", "perm2", ...], "flags" => [] }}}
-
before do
resource.action(:create)
end
@@ -293,14 +291,13 @@ shared_examples_for "a securable resource with reporting" do
resource.run_action(:create)
# TODO: most stable way to specify?
expect(resource.owner).to eq(etc.getpwuid(process.uid).name)
- expect(resource.state[:expanded_rights]).to eq({ "CURRENTUSER" => { "permissions" => ALL_EXPANDED_PERMISSIONS, "flags" => [] }})
+ expect(resource.state[:expanded_rights]).to eq({ "CURRENTUSER" => { "permissions" => ALL_EXPANDED_PERMISSIONS, "flags" => [] } })
expect(resource.state[:expanded_deny_rights]).to eq({})
expect(resource.state[:inherits]).to be_truthy
end
end
-
- context "and owner is specified with a string (username) in new_resource" do
+ context "and owner is specified with a string (username) in new_resource" do
# TODO/bug: duplicated from the "securable resource" tests
let(:expected_user_name) { "Guest" }
@@ -392,7 +389,6 @@ shared_examples_for "a securable resource with reporting" do
end
end
-
end
end
end
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index 5bd2d772cb..0f9072bdef 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -35,10 +35,8 @@ shared_context "using Win32::Service" do
if File.exists?(test_service_file)
File.delete(test_service_file)
end
-
end
-
# Definition for the test-service
let(:test_service) {
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb
index cad0d7e12d..67a53306ba 100644
--- a/spec/support/shared/functional/windows_script.rb
+++ b/spec/support/shared/functional/windows_script.rb
@@ -27,7 +27,7 @@ shared_context Chef::Resource::WindowsScript do
@ohai_reader.all_plugins(["platform", "kernel"])
new_node = Chef::Node.new
- new_node.consume_external_attrs(@ohai_reader.data,{})
+ new_node.consume_external_attrs(@ohai_reader.data, {})
events = Chef::EventDispatch::Dispatcher.new
@@ -116,7 +116,7 @@ shared_context Chef::Resource::WindowsScript do
let (:guard_architecture) { :i386 }
it "raises an error" do
resource.only_if resource_guard_command, :architecture => guard_architecture
- expect{ resource.run_action(:run) }.to raise_error(
+ expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
/cannot execute script with requested architecture 'i386' on Windows Nano Server/)
end
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index 5d4c01a44e..29f2eef50f 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -99,7 +99,7 @@ module IntegrationSupport
File.expand_path(relative_path, (@parent_path || @repository_dir))
end
- def cb_metadata(name, version, extra_text="")
+ def cb_metadata(name, version, extra_text = "")
"name #{name.inspect}; version #{version.inspect}#{extra_text}"
end
@@ -128,7 +128,7 @@ module IntegrationSupport
# TODO: "force" actually means "silence all exceptions". this
# silences a weird permissions error on Windows that we should track
# down, but for now there's no reason for it to blow up our CI.
- FileUtils.remove_entry_secure(@repository_dir, force=Chef::Platform.windows?)
+ FileUtils.remove_entry_secure(@repository_dir, force = Chef::Platform.windows?)
ensure
@repository_dir = nil
end
diff --git a/spec/support/shared/matchers/exit_with_code.rb b/spec/support/shared/matchers/exit_with_code.rb
index cf1825f2ed..c5458eea0e 100644
--- a/spec/support/shared/matchers/exit_with_code.rb
+++ b/spec/support/shared/matchers/exit_with_code.rb
@@ -14,7 +14,7 @@ RSpec::Matchers.define :exit_with_code do |exp_code|
failure_message do |block|
"expected block to call exit(#{exp_code}) but exit" +
- (actual.nil? ? " not called" : "(#{actual}) was called")
+ (actual.nil? ? " not called" : "(#{actual}) was called")
end
failure_message_when_negated do |block|
diff --git a/spec/support/shared/unit/api_error_inspector.rb b/spec/support/shared/unit/api_error_inspector.rb
index 6e074d38a7..45bfcc67da 100644
--- a/spec/support/shared/unit/api_error_inspector.rb
+++ b/spec/support/shared/unit/api_error_inspector.rb
@@ -16,8 +16,6 @@
# limitations under the License.
#
-
-
# == API Error Inspector Examples
# These tests are work in progress. They exercise the code enough to ensure it
# runs without error, but don't make assertions about the output. This is
diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb
index 195b65ff5b..b61469a2d0 100644
--- a/spec/support/shared/unit/api_versioning.rb
+++ b/spec/support/shared/unit/api_versioning.rb
@@ -32,7 +32,7 @@ shared_examples_for "version handling" do
end
it "raises the original exception" do
- expect{ object.send(method) }.to raise_error(exception_406)
+ expect { object.send(method) }.to raise_error(exception_406)
end
end # when the server does not support the min or max server API version that Chef::UserV1 supports
end # version handling
@@ -60,7 +60,7 @@ shared_examples_for "user and client reregister" do
it "raises an error about only V0 being supported" do
expect(object).to receive(:reregister_only_v0_supported_error_msg).with(max_version, min_version)
- expect{ object.reregister }.to raise_error(Chef::Exceptions::OnlyApiVersion0SupportedForAction)
+ expect { object.reregister }.to raise_error(Chef::Exceptions::OnlyApiVersion0SupportedForAction)
end
end
@@ -70,7 +70,7 @@ shared_examples_for "user and client reregister" do
end
it "raises the original error" do
- expect{ object.reregister }.to raise_error(generic_exception)
+ expect { object.reregister }.to raise_error(generic_exception)
end
end
end
diff --git a/spec/support/shared/unit/knife_shared.rb b/spec/support/shared/unit/knife_shared.rb
index 8f97cf60c0..0af05ffb80 100644
--- a/spec/support/shared/unit/knife_shared.rb
+++ b/spec/support/shared/unit/knife_shared.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-
shared_examples_for "mandatory field missing" do
context "when field is nil" do
before do
diff --git a/spec/support/shared/unit/mock_shellout.rb b/spec/support/shared/unit/mock_shellout.rb
index 05924e8a40..dac51be798 100644
--- a/spec/support/shared/unit/mock_shellout.rb
+++ b/spec/support/shared/unit/mock_shellout.rb
@@ -34,12 +34,15 @@ class MockShellout
exitstatus: 0,
}.merge(properties)
end
+
def method_missing(name, *args)
@properties[name.to_sym]
end
+
def error?
exitstatus != 0
end
+
def error!
raise Mixlib::ShellOut::ShellCommandFailed, "Expected process to exit with 0, but received #{exitstatus}" if error?
end
diff --git a/spec/support/shared/unit/platform_introspector.rb b/spec/support/shared/unit/platform_introspector.rb
index 30a2f61a70..2e6f74fb14 100644
--- a/spec/support/shared/unit/platform_introspector.rb
+++ b/spec/support/shared/unit/platform_introspector.rb
@@ -17,7 +17,6 @@
# limitations under the License.
#
-
shared_examples_for "a platform introspector" do
before(:each) do
@platform_hash = {}
@@ -27,12 +26,12 @@ shared_examples_for "a platform introspector" do
"1.2.3" => "#{x}-1.2.3",
}
end
- @platform_hash["debian"] = {["5", "6"] => "debian-5/6", "default" => "debian"}
+ @platform_hash["debian"] = { ["5", "6"] => "debian-5/6", "default" => "debian" }
@platform_hash["default"] = "default"
# The following @platform_hash keys are used for testing version constraints
- @platform_hash["exact_match"] = { "1.2.3" => "exact", ">= 1.0" => "not exact"}
+ @platform_hash["exact_match"] = { "1.2.3" => "exact", ">= 1.0" => "not exact" }
@platform_hash["multiple_matches"] = { "~> 2.3.4" => "matched ~> 2.3.4", ">= 2.3" => "matched >=2.3" }
- @platform_hash["invalid_cookbook_version"] = {">= 21" => "Matches a single number"}
+ @platform_hash["invalid_cookbook_version"] = { ">= 21" => "Matches a single number" }
@platform_hash["successful_matches"] = { "< 3.0" => "matched < 3.0", ">= 3.0" => "matched >= 3.0" }
@platform_family_hash = {
@@ -93,7 +92,7 @@ shared_examples_for "a platform introspector" do
it "raises RuntimeError" do
node.automatic_attrs[:platform] = "multiple_matches"
node.automatic_attrs[:platform_version] = "2.3.4"
- expect {platform_introspector.value_for_platform(@platform_hash)}.to raise_error(RuntimeError)
+ expect { platform_introspector.value_for_platform(@platform_hash) }.to raise_error(RuntimeError)
end
it "should not require .0 to match >= 21.0" do
@@ -171,7 +170,7 @@ shared_examples_for "a platform introspector" do
"centos" => { "default" => [ :restart, :reload, :status ] },
"redhat" => { "default" => [ :restart, :reload, :status ] },
"fedora" => { "default" => [ :restart, :reload, :status ] },
- "default" => { "default" => [:restart, :reload ] }}
+ "default" => { "default" => [:restart, :reload ] } }
end
it "returns the correct default for a given platform" do
@@ -188,4 +187,3 @@ shared_examples_for "a platform introspector" do
end
end
-
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index 8ed67eb5a8..5e5fc058e7 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -117,7 +117,7 @@ class BasicTempfile < ::File
end
def self.new(basename)
- super(make_tmp_path(basename), File::RDWR|File::CREAT|File::EXCL, 0600)
+ super(make_tmp_path(basename), File::RDWR | File::CREAT | File::EXCL, 0600)
end
def unlink
@@ -419,12 +419,12 @@ shared_examples_for Chef::Provider::File do
[:create, :create_if_missing, :touch].each do |action|
context "action #{action}" do
it "raises EnclosingDirectoryDoesNotExist" do
- expect {provider.run_action(action)}.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
+ expect { provider.run_action(action) }.to raise_error(Chef::Exceptions::EnclosingDirectoryDoesNotExist)
end
it "does not raise an exception in why-run mode" do
Chef::Config[:why_run] = true
- expect {provider.run_action(action)}.not_to raise_error
+ expect { provider.run_action(action) }.not_to raise_error
Chef::Config[:why_run] = false
end
end
@@ -435,19 +435,19 @@ shared_examples_for Chef::Provider::File do
before { setup_unwritable_file }
it "action delete raises InsufficientPermissions" do
- expect {provider.run_action(:delete)}.to raise_error(Chef::Exceptions::InsufficientPermissions)
+ expect { provider.run_action(:delete) }.to raise_error(Chef::Exceptions::InsufficientPermissions)
end
it "action delete also raises InsufficientPermissions in why-run mode" do
Chef::Config[:why_run] = true
- expect {provider.run_action(:delete)}.to raise_error(Chef::Exceptions::InsufficientPermissions)
+ expect { provider.run_action(:delete) }.to raise_error(Chef::Exceptions::InsufficientPermissions)
Chef::Config[:why_run] = false
end
end
end
context "action create" do
- it "should create the file, update its contents and then set the acls on the file" do
+ it "should create the file, update its contents and then set the acls on the file" do
setup_missing_file
expect(provider).to receive(:do_create_file)
expect(provider).to receive(:do_contents_changes)
@@ -476,7 +476,7 @@ shared_examples_for Chef::Provider::File do
allow(File).to receive(:directory?).with("C:\\Windows\\system32/cmd.exe").and_return(false)
provider.new_resource.verify windows? ? "REM" : "true"
provider.new_resource.verify windows? ? "cmd.exe /c exit 1" : "false"
- expect{provider.send(:do_validate_content)}.to raise_error(Chef::Exceptions::ValidationFailed)
+ expect { provider.send(:do_validate_content) }.to raise_error(Chef::Exceptions::ValidationFailed)
end
end
end
@@ -520,14 +520,14 @@ shared_examples_for Chef::Provider::File do
let(:diff_for_reporting) { "+++\n---\n+foo\n-bar\n" }
before do
allow(provider).to receive(:contents_changed?).and_return(true)
- diff = double("Diff", :for_output => ["+++","---","+foo","-bar"],
+ diff = double("Diff", :for_output => ["+++", "---", "+foo", "-bar"],
:for_reporting => diff_for_reporting )
allow(diff).to receive(:diff).with(resource_path, tempfile_path).and_return(true)
expect(provider).to receive(:diff).at_least(:once).and_return(diff)
expect(provider).to receive(:checksum).with(tempfile_path).and_return(tempfile_sha256)
allow(provider).to receive(:managing_content?).and_return(true)
allow(provider).to receive(:checksum).with(resource_path).and_return(tempfile_sha256)
- expect(resource).not_to receive(:checksum).with(tempfile_sha256) # do not mutate the new resource
+ expect(resource).not_to receive(:checksum).with(tempfile_sha256) # do not mutate the new resource
expect(provider.deployment_strategy).to receive(:deploy).with(tempfile_path, normalized_path)
end
context "when the file was created" do
@@ -549,7 +549,7 @@ shared_examples_for Chef::Provider::File do
end
context "when the file was not created" do
before do
- allow(provider).to receive(:do_backup) # stub do_backup
+ allow(provider).to receive(:do_backup) # stub do_backup
expect(provider).to receive(:needs_creating?).at_least(:once).and_return(false)
end
@@ -570,7 +570,7 @@ shared_examples_for Chef::Provider::File do
end
end
- it "does nothing when the contents have not changed" do
+ it "does nothing when the contents have not changed" do
allow(provider).to receive(:contents_changed?).and_return(false)
expect(provider).not_to receive(:diff)
provider.send(:do_contents_changes)
@@ -580,20 +580,20 @@ shared_examples_for Chef::Provider::File do
it "does nothing when there is no content to deploy (tempfile returned from contents is nil)" do
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(nil)
expect(provider).not_to receive(:diff)
- expect{ provider.send(:do_contents_changes) }.not_to raise_error
+ expect { provider.send(:do_contents_changes) }.not_to raise_error
end
it "raises an exception when the content object returns a tempfile with a nil path" do
tempfile = double("Tempfile", :path => nil)
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile)
- expect{ provider.send(:do_contents_changes) }.to raise_error
+ expect { provider.send(:do_contents_changes) }.to raise_error
end
it "raises an exception when the content object returns a tempfile that does not exist" do
tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz")
expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile)
expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(false)
- expect{ provider.send(:do_contents_changes) }.to raise_error
+ expect { provider.send(:do_contents_changes) }.to raise_error
end
end
diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
index ccc6e3fec6..6694aa346c 100644
--- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb
+++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
@@ -46,7 +46,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
@current_resource.manage_home false
@current_resource.force false
@current_resource.non_unique false
- @current_resource.supports({:manage_home => false, :non_unique => false})
+ @current_resource.supports({ :manage_home => false, :non_unique => false })
end
describe "when setting option" do
@@ -64,8 +64,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
end
it "should set the option for #{attribute} if the new resources #{attribute} is not nil, without homedir management" do
- allow(@new_resource).to receive(:supports).and_return({:manage_home => false,
- :non_unique => false})
+ allow(@new_resource).to receive(:supports).and_return({ :manage_home => false,
+ :non_unique => false })
allow(@new_resource).to receive(attribute).and_return("hola")
expect(provider.universal_options).to eql([option, "hola"])
end
@@ -81,7 +81,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should combine all the possible options" do
combined_opts = []
- supported_useradd_options.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option|
+ supported_useradd_options.sort { |a, b| a[0] <=> b[0] }.each do |attribute, option|
allow(@new_resource).to receive(attribute).and_return("hola")
combined_opts << option << "hola"
end
@@ -103,8 +103,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when the resource has a different home directory and supports home directory management" do
before do
allow(@new_resource).to receive(:home).and_return("/wowaweea")
- allow(@new_resource).to receive(:supports).and_return({:manage_home => true,
- :non_unique => false})
+ allow(@new_resource).to receive(:supports).and_return({ :manage_home => true,
+ :non_unique => false })
end
it "should set -m -d /homedir" do
@@ -128,8 +128,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when the resource supports non_unique ids" do
before do
- allow(@new_resource).to receive(:supports).and_return({:manage_home => false,
- :non_unique => true})
+ allow(@new_resource).to receive(:supports).and_return({ :manage_home => false,
+ :non_unique => true })
end
it "should set -m -o" do
@@ -161,7 +161,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "runs useradd with the computed command options" do
command = ["useradd",
- "-c", "Adam Jacob",
+ "-c", "Adam Jacob",
"-g", "23" ]
command.concat(["-p", "abracadabra"]) if supported_useradd_options.key?("password")
command.concat([ "-s", "/usr/bin/zsh",
@@ -247,14 +247,14 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should run userdel with the new resources user name and -r if manage_home is true" do
@new_resource.supports({ :manage_home => true,
- :non_unique => false})
+ :non_unique => false })
expect(provider).to receive(:shell_out!).with("userdel", "-r", @new_resource.username).and_return(true)
provider.remove_user
end
it "should run userdel with the new resources user name if non_unique is true" do
@new_resource.supports({ :manage_home => false,
- :non_unique => true})
+ :non_unique => true })
expect(provider).to receive(:shell_out!).with("userdel", @new_resource.username).and_return(true)
provider.remove_user
end
@@ -285,7 +285,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should return false if status begins with P" do
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
expect(provider.check_lock).to eql(false)
end
@@ -293,7 +293,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should return false if status begins with N" do
@stdout = "root N"
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
expect(provider.check_lock).to eql(false)
end
@@ -301,7 +301,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should return true if status begins with L" do
@stdout = "root L"
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
expect(provider.check_lock).to eql(true)
end
@@ -309,7 +309,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should raise a Chef::Exceptions::User if passwd -S fails on anything other than redhat/centos" do
@node.automatic_attrs[:platform] = "ubuntu"
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
expect(passwd_s_status).to receive(:exitstatus).and_return(1)
expect { provider.check_lock }.to raise_error(Chef::Exceptions::User)
@@ -320,7 +320,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
@node.automatic_attrs[:platform] = os
expect(passwd_s_status).to receive(:exitstatus).and_return(1)
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
rpm_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "passwd-0.73-1\n", :stderr => "")
expect(provider).to receive(:shell_out!).with("rpm -q passwd").and_return(rpm_status)
@@ -331,7 +331,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
@node.automatic_attrs[:platform] = os
expect(passwd_s_status).to receive(:exitstatus).and_return(1)
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_s_status)
rpm_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "passwd-0.73-2\n", :stderr => "")
expect(provider).to receive(:shell_out!).with("rpm -q passwd").and_return(rpm_status)
@@ -349,7 +349,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
before do
passwd_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "", :stderr => "passwd: user 'chef-test' does not exist\n")
expect(provider).to receive(:shell_out!).
- with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}).
+ with("passwd", "-S", @new_resource.username, { :returns => [0, 1] }).
and_return(passwd_status)
Chef::Config[:why_run] = true
end
@@ -431,4 +431,3 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
end
end
end
-
diff --git a/spec/support/shared/unit/resource/static_provider_resolution.rb b/spec/support/shared/unit/resource/static_provider_resolution.rb
index 56ed49e00d..4ae5d4576f 100644
--- a/spec/support/shared/unit/resource/static_provider_resolution.rb
+++ b/spec/support/shared/unit/resource/static_provider_resolution.rb
@@ -16,8 +16,6 @@
# limitations under the License.
#
-
-
#
# This is for typical "static" provider resolution which maps resources onto
# providers based only on the node data. Its not really 'static' because it
@@ -25,7 +23,7 @@
# a static mapping for the node (unlike the service resource which is
# complicated).
#
-def static_provider_resolution(opts={})
+def static_provider_resolution(opts = {})
action = opts[:action]
provider_class = opts[:provider]
resource_class = opts[:resource]
@@ -63,4 +61,3 @@ def static_provider_resolution(opts={})
end
end
end
-
diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb
index ba33d69a59..a80ab81fb9 100644
--- a/spec/support/shared/unit/script_resource.rb
+++ b/spec/support/shared/unit/script_resource.rb
@@ -74,7 +74,7 @@ shared_examples_for "a script resource" do
it "inherits exactly the :cwd, :environment, :group, :path, :user, and :umask attributes from a parent resource class" do
inherited_difference = Chef::Resource::Script.guard_inherited_attributes -
- [:cwd, :environment, :group, :path, :user, :umask ]
+ [:cwd, :environment, :group, :path, :user, :umask ]
expect(inherited_difference).to eq([])
end
diff --git a/spec/support/shared/unit/user_and_client_shared.rb b/spec/support/shared/unit/user_and_client_shared.rb
index c8208c149b..e3862943bc 100644
--- a/spec/support/shared/unit/user_and_client_shared.rb
+++ b/spec/support/shared/unit/user_and_client_shared.rb
@@ -27,7 +27,7 @@ shared_examples_for "user or client create" do
it "creates a new object via the API with a public_key when it exists" do
object.public_key "some_public_key"
- expect(rest_v1).to receive(:post).with(url, payload.merge({:public_key => "some_public_key"})).and_return({})
+ expect(rest_v1).to receive(:post).with(url, payload.merge({ :public_key => "some_public_key" })).and_return({})
object.create
end
@@ -49,7 +49,7 @@ shared_examples_for "user or client create" do
end
it "creates a new object via the API with create_key" do
- expect(rest_v1).to receive(:post).with(url, payload.merge({:create_key => true})).and_return({})
+ expect(rest_v1).to receive(:post).with(url, payload.merge({ :create_key => true })).and_return({})
object.create
end
end
@@ -104,7 +104,7 @@ shared_examples_for "user or client create" do
it "creates a new object via the API with a public_key when it exists" do
object.public_key "some_public_key"
- expect(rest_v0).to receive(:post).with(url, payload.merge({:public_key => "some_public_key"})).and_return({})
+ expect(rest_v0).to receive(:post).with(url, payload.merge({ :public_key => "some_public_key" })).and_return({})
object.create
end
@@ -112,4 +112,3 @@ shared_examples_for "user or client create" do
end # when server API V1 is not valid on the Chef Server receiving the request
end # user or client create
-
diff --git a/spec/support/shared/unit/windows_script_resource.rb b/spec/support/shared/unit/windows_script_resource.rb
index 1dcbae76aa..2dc0229c90 100644
--- a/spec/support/shared/unit/windows_script_resource.rb
+++ b/spec/support/shared/unit/windows_script_resource.rb
@@ -78,4 +78,3 @@ shared_examples_for "a Windows script resource" do
end
end
-