summaryrefslogtreecommitdiff
path: root/spec/support
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-07-02 10:25:16 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2018-07-02 10:25:16 -0700
commit35603c7ce1bd3ccf35334ed65152140f0ecaf080 (patch)
tree452c84ce196ce00d672c71a8fa65f86c5a074fac /spec/support
parenteda2808dce8146bfdb308dd658b1dd565df3562b (diff)
downloadchef-35603c7ce1bd3ccf35334ed65152140f0ecaf080.tar.gz
fix Style/HashSyntax
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'spec/support')
-rw-r--r--spec/support/platform_helpers.rb2
-rw-r--r--spec/support/shared/context/client.rb20
-rw-r--r--spec/support/shared/functional/securable_resource.rb22
-rw-r--r--spec/support/shared/functional/securable_resource_with_reporting.rb10
-rw-r--r--spec/support/shared/functional/win32_service.rb10
-rw-r--r--spec/support/shared/functional/windows_script.rb6
-rw-r--r--spec/support/shared/integration/app_server_support.rb6
-rw-r--r--spec/support/shared/integration/integration_helper.rb4
-rw-r--r--spec/support/shared/integration/knife_support.rb4
-rw-r--r--spec/support/shared/unit/api_error_inspector.rb10
-rw-r--r--spec/support/shared/unit/api_versioning.rb4
-rw-r--r--spec/support/shared/unit/execute_resource.rb4
-rw-r--r--spec/support/shared/unit/provider/file.rb24
-rw-r--r--spec/support/shared/unit/provider/useradd_based_user_provider.rb20
-rw-r--r--spec/support/shared/unit/user_and_client_shared.rb6
15 files changed, 76 insertions, 76 deletions
diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb
index 8569523e05..6ae052ba1d 100644
--- a/spec/support/platform_helpers.rb
+++ b/spec/support/platform_helpers.rb
@@ -202,7 +202,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
diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb
index 4b90fcaedd..6797a4ad22 100644
--- a/spec/support/shared/context/client.rb
+++ b/spec/support/shared/context/client.rb
@@ -11,16 +11,16 @@ shared_context "client" do
let(:ohai_data) do
{
- :fqdn => fqdn,
- :hostname => hostname,
- :machinename => machinename,
- :platform => platform,
- :platform_version => platform_version,
+ fqdn: fqdn,
+ hostname: hostname,
+ machinename: machinename,
+ platform: platform,
+ platform_version: platform_version,
}
end
let(:ohai_system) do
- ohai = instance_double("Ohai::System", :all_plugins => true, :data => ohai_data, logger: logger)
+ ohai = instance_double("Ohai::System", all_plugins: true, data: ohai_data, logger: logger)
allow(ohai).to receive(:[]) do |k|
ohai_data[k]
end
@@ -80,7 +80,7 @@ shared_context "a client run" do
let(:reporting_rest_client) { double("Chef::ServerAPI (reporting client)") }
let(:runner) { instance_double("Chef::Runner") }
- let(:audit_runner) { instance_double("Chef::Audit::Runner", :failed? => false) }
+ let(:audit_runner) { instance_double("Chef::Audit::Runner", failed?: false) }
def stub_for_register
# --Client.register
@@ -136,7 +136,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], version_class: Chef::CookbookManifestVersions).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
@@ -250,8 +250,8 @@ end
shared_context "audit phase completed with failed controls" do
let(:audit_runner) do
- instance_double("Chef::Audit::Runner", :failed? => true,
- :num_failed => 1, :num_total => 3) end
+ instance_double("Chef::Audit::Runner", failed?: true,
+ num_failed: 1, num_total: 3) end
let(:audit_error) do
err = Chef::Exceptions::AuditsFailed.new(audit_runner.num_failed, audit_runner.num_total)
diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb
index 65f512b5bf..0df006cccc 100644
--- a/spec/support/shared/functional/securable_resource.rb
+++ b/spec/support/shared/functional/securable_resource.rb
@@ -95,7 +95,7 @@ shared_context "use Windows permissions", :windows_only do
def extract_ace_properties(aces)
hashes = []
aces.each do |ace|
- hashes << { :mask => ace.mask, :type => ace.type, :flags => ace.flags }
+ hashes << { mask: ace.mask, type: ace.type, flags: ace.flags }
end
hashes
end
@@ -103,36 +103,36 @@ shared_context "use Windows permissions", :windows_only do
# Standard expected rights
let(:expected_read_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ,
}
end
let(:expected_read_execute_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE,
}
end
let(:expected_write_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE,
}
end
let(:expected_modify_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_READ | Chef::ReservedNames::Win32::API::Security::GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_READ | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_WRITE | Chef::ReservedNames::Win32::API::Security::FILE_GENERIC_EXECUTE | Chef::ReservedNames::Win32::API::Security::DELETE,
}
end
let(:expected_full_control_perms) do
{
- :generic => Chef::ReservedNames::Win32::API::Security::GENERIC_ALL,
- :specific => Chef::ReservedNames::Win32::API::Security::FILE_ALL_ACCESS,
+ generic: Chef::ReservedNames::Win32::API::Security::GENERIC_ALL,
+ specific: Chef::ReservedNames::Win32::API::Security::FILE_ALL_ACCESS,
}
end
diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb
index 0bec29783a..cd2b83fda1 100644
--- a/spec/support/shared/functional/securable_resource_with_reporting.rb
+++ b/spec/support/shared/functional/securable_resource_with_reporting.rb
@@ -36,7 +36,7 @@ shared_examples_for "a securable resource with reporting" do
# umask
# let(:default_mode) { (0666 & ~File.umask).to_s(8) }
- describe "reading file security metadata for reporting on unix", :unix_only => true do
+ describe "reading file security metadata for reporting on unix", unix_only: true do
# According to POSIX standard created files get either the
# effective gid of the process or inherits the gid of the parent
# directory based on file system. Since it's hard to guess what
@@ -70,7 +70,7 @@ shared_examples_for "a securable resource with reporting" do
end
end
- context "and owner is specified with a String (username) in new_resource", :requires_root => true do
+ context "and owner is specified with a String (username) in new_resource", requires_root: true do
# TODO/bug: duplicated from the "securable resource" tests
@@ -91,7 +91,7 @@ shared_examples_for "a securable resource with reporting" do
end
- context "and owner is specified with an Integer (uid) in new_resource", :requires_root => true do
+ context "and owner is specified with an Integer (uid) in new_resource", requires_root: true do
# TODO: duplicated from "securable resource"
if ohai[:platform] == "aix"
@@ -113,7 +113,7 @@ shared_examples_for "a securable resource with reporting" do
end
end
- context "and group is specified with a String (group name)", :requires_root => true do
+ context "and group is specified with a String (group name)", requires_root: true do
let(:expected_group_name) { Etc.getgrent.name }
@@ -128,7 +128,7 @@ shared_examples_for "a securable resource with reporting" do
end
- context "and group is specified with an Integer (gid)", :requires_root => true do
+ context "and group is specified with an Integer (gid)", requires_root: true do
let(:expected_gid) { Etc.getgrent.gid }
before do
diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb
index 3199caa34f..a528db4a53 100644
--- a/spec/support/shared/functional/win32_service.rb
+++ b/spec/support/shared/functional/win32_service.rb
@@ -39,11 +39,11 @@ shared_context "using Win32::Service" do
let(:test_service) do
{
- :service_name => "spec-service",
- :service_display_name => "Spec Test Service",
- :service_description => "Service for testing Chef::Application::WindowsServiceManager.",
- :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")),
- :delayed_start => true,
+ service_name: "spec-service",
+ service_display_name: "Spec Test Service",
+ service_description: "Service for testing Chef::Application::WindowsServiceManager.",
+ service_file_path: File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")),
+ delayed_start: true,
}
end
diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb
index e5ac0741bd..5eb68952d7 100644
--- a/spec/support/shared/functional/windows_script.rb
+++ b/spec/support/shared/functional/windows_script.rb
@@ -93,7 +93,7 @@ shared_context Chef::Resource::WindowsScript do
context "when the guard's architecture is specified as 64-bit" do
let (:guard_architecture) { :x86_64 }
it "executes a 64-bit guard", :windows64_only do
- resource.only_if resource_guard_command, :architecture => guard_architecture
+ resource.only_if resource_guard_command, architecture: guard_architecture
resource.run_action(:run)
expect(get_guard_process_architecture).to eq("amd64")
end
@@ -102,7 +102,7 @@ shared_context Chef::Resource::WindowsScript do
context "when the guard's architecture is specified as 32-bit", :not_supported_on_nano do
let (:guard_architecture) { :i386 }
it "executes a 32-bit guard" do
- resource.only_if resource_guard_command, :architecture => guard_architecture
+ resource.only_if resource_guard_command, architecture: guard_architecture
resource.run_action(:run)
expect(get_guard_process_architecture).to eq("x86")
end
@@ -111,7 +111,7 @@ shared_context Chef::Resource::WindowsScript do
context "when the guard's architecture is specified as 32-bit", :windows_nano_only do
let (:guard_architecture) { :i386 }
it "raises an error" do
- resource.only_if resource_guard_command, :architecture => guard_architecture
+ resource.only_if resource_guard_command, architecture: guard_architecture
expect { resource.run_action(:run) }.to raise_error(
Chef::Exceptions::Win32ArchitectureIncorrect,
/cannot execute script with requested architecture 'i386' on Windows Nano Server/)
diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb
index e2bb3812ea..c0b24d9443 100644
--- a/spec/support/shared/integration/app_server_support.rb
+++ b/spec/support/shared/integration/app_server_support.rb
@@ -25,9 +25,9 @@ module AppServerSupport
server = nil
thread = Thread.new do
Rack::Handler::WEBrick.run(app,
- :Port => 9018,
- :AccessLog => [],
- :Logger => WEBrick::Log.new(StringIO.new, 7)
+ Port: 9018,
+ AccessLog: [],
+ Logger: WEBrick::Log.new(StringIO.new, 7)
) do |found_server|
server = found_server
end
diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb
index 29f2eef50f..5fc9de4de7 100644
--- a/spec/support/shared/integration/integration_helper.rb
+++ b/spec/support/shared/integration/integration_helper.rb
@@ -140,12 +140,12 @@ module IntegrationSupport
# Versioned cookbooks
- RSpec.shared_context "with versioned cookbooks", :versioned_cookbooks => true do
+ RSpec.shared_context "with versioned cookbooks", versioned_cookbooks: true do
before(:each) { Chef::Config[:versioned_cookbooks] = true }
after(:each) { Chef::Config.delete(:versioned_cookbooks) }
end
- RSpec.shared_context "without versioned cookbooks", :versioned_cookbooks => false do
+ RSpec.shared_context "without versioned cookbooks", versioned_cookbooks: false do
# Just make sure this goes back to default
before(:each) { Chef::Config[:versioned_cookbooks] = false }
after(:each) { Chef::Config.delete(:versioned_cookbooks) }
diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb
index 86764cad66..5058b7b278 100644
--- a/spec/support/shared/integration/knife_support.rb
+++ b/spec/support/shared/integration/knife_support.rb
@@ -40,8 +40,8 @@ module KnifeSupport
# Work on machines where we can't access /var
Dir.mktmpdir("checksums") do |checksums_cache_dir|
Chef::Config[:cache_options] = {
- :path => checksums_cache_dir,
- :skip_expires => true,
+ path: checksums_cache_dir,
+ skip_expires: true,
}
# This is Chef::Knife.run without load_commands--we'll load stuff
diff --git a/spec/support/shared/unit/api_error_inspector.rb b/spec/support/shared/unit/api_error_inspector.rb
index 45bfcc67da..06f2e4bb57 100644
--- a/spec/support/shared/unit/api_error_inspector.rb
+++ b/spec/support/shared/unit/api_error_inspector.rb
@@ -28,11 +28,11 @@ shared_examples_for "an api error inspector" do
before do
@node_name = "test-node.example.com"
@config = {
- :validation_client_name => "testorg-validator",
- :validation_key => "/etc/chef/testorg-validator.pem",
- :chef_server_url => "https://chef-api.example.com",
- :node_name => "testnode-name",
- :client_key => "/etc/chef/client.pem",
+ validation_client_name: "testorg-validator",
+ validation_key: "/etc/chef/testorg-validator.pem",
+ chef_server_url: "https://chef-api.example.com",
+ node_name: "testnode-name",
+ client_key: "/etc/chef/client.pem",
}
@description = Chef::Formatters::ErrorDescription.new("Error registering the node:")
@outputter = Chef::Formatters::IndentableOutputStream.new(StringIO.new, STDERR)
diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb
index 28141b73b1..9c179efa82 100644
--- a/spec/support/shared/unit/api_versioning.rb
+++ b/spec/support/shared/unit/api_versioning.rb
@@ -19,7 +19,7 @@
require "chef/exceptions"
shared_examples_for "version handling" do
- let(:response_406) { OpenStruct.new(:code => "406") }
+ let(:response_406) { OpenStruct.new(code: "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
before do
@@ -38,7 +38,7 @@ shared_examples_for "version handling" do
end # version handling
shared_examples_for "user and client reregister" do
- let(:response_406) { OpenStruct.new(:code => "406") }
+ let(:response_406) { OpenStruct.new(code: "406") }
let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) }
let(:generic_exception) { Exception.new }
let(:min_version) { "2" }
diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb
index c97577107e..05c2fc4a9a 100644
--- a/spec/support/shared/unit/execute_resource.rb
+++ b/spec/support/shared/unit/execute_resource.rb
@@ -57,7 +57,7 @@ shared_examples_for "an execute resource" do
end
it "should accept a hash for the environment" do
- test_hash = { :one => :two }
+ test_hash = { one: :two }
@resource.environment(test_hash)
expect(@resource.environment).to eql(test_hash)
end
@@ -155,7 +155,7 @@ shared_examples_for "an execute resource" do
before do
@resource.command("grep")
@resource.cwd("/tmp/")
- @resource.environment({ :one => :two })
+ @resource.environment({ one: :two })
@resource.group("legos")
@resource.returns(1)
@resource.user("root")
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb
index d508e76b24..a7c7af92f6 100644
--- a/spec/support/shared/unit/provider/file.rb
+++ b/spec/support/shared/unit/provider/file.rb
@@ -258,11 +258,11 @@ shared_examples_for Chef::Provider::File do
allow(ChefConfig).to receive(:windows?).and_return(false)
# mock up the filesystem to behave like unix
setup_normal_file
- stat_struct = double("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
+ stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
resource_real_path = File.realpath(resource.path)
expect(File).to receive(:stat).with(resource_real_path).at_least(:once).and_return(stat_struct)
- allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", :name => "wheel"))
- allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", :name => "root"))
+ allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", name: "wheel"))
+ allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", name: "root"))
end
context "when the new_resource does not specify any state" do
@@ -383,11 +383,11 @@ shared_examples_for Chef::Provider::File do
allow(ChefConfig).to receive(:windows?).and_return(false)
# mock up the filesystem to behave like unix
setup_normal_file
- stat_struct = double("::File.stat", :mode => 0600, :uid => 0, :gid => 0, :mtime => 10000)
+ stat_struct = double("::File.stat", mode: 0600, uid: 0, gid: 0, mtime: 10000)
resource_real_path = File.realpath(resource.path)
allow(File).to receive(:stat).with(resource_real_path).and_return(stat_struct)
- allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", :name => "wheel"))
- allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", :name => "root"))
+ allow(Etc).to receive(:getgrgid).with(0).and_return(double("Group Ent", name: "wheel"))
+ allow(Etc).to receive(:getpwuid).with(0).and_return(double("User Ent", name: "root"))
provider.send(:load_resource_attributes_from_file, resource)
end
@@ -460,7 +460,7 @@ shared_examples_for Chef::Provider::File do
before { setup_normal_file }
let(:tempfile) do
- t = double("Tempfile", :path => "/tmp/foo-bar-baz", :closed? => true)
+ t = double("Tempfile", path: "/tmp/foo-bar-baz", closed?: true)
allow(content).to receive(:tempfile).and_return(t)
t
end
@@ -515,7 +515,7 @@ shared_examples_for Chef::Provider::File do
before do
setup_normal_file
provider.load_current_resource
- tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz")
+ tempfile = double("Tempfile", path: "/tmp/foo-bar-baz")
allow(content).to receive(:tempfile).and_return(tempfile)
expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(true)
expect(tempfile).to receive(:close).once
@@ -528,8 +528,8 @@ 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"],
- :for_reporting => diff_for_reporting )
+ 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)
@@ -592,13 +592,13 @@ shared_examples_for Chef::Provider::File do
end
it "raises an exception when the content object returns a tempfile with a nil path" do
- tempfile = double("Tempfile", :path => nil)
+ 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(RuntimeError)
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")
+ 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(RuntimeError)
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 caa76e4ad6..a6301f9ae7 100644
--- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb
+++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb
@@ -68,8 +68,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
@@ -257,7 +257,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
describe "when checking the lock" do
# lazy initialize so we can modify stdout and stderr strings
let(:passwd_s_status) do
- double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => @stdout, :stderr => @stderr, :error! => nil)
+ double("Mixlib::ShellOut command", exitstatus: 0, stdout: @stdout, stderr: @stderr, error!: nil)
end
before(:each) do
@@ -273,7 +273,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
@@ -281,7 +281,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
@@ -289,7 +289,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
@@ -297,7 +297,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
it "should raise a ShellCommandFailed exception if passwd -S exits with something other than 0 or 1" do
expect(passwd_s_status).to receive(:error!).and_raise(Mixlib::ShellOut::ShellCommandFailed)
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 raise_error(Mixlib::ShellOut::ShellCommandFailed)
end
@@ -306,16 +306,16 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option
expect(passwd_s_status).to receive(:stdout).and_return("")
expect(passwd_s_status).to receive(:stderr).and_return("")
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 raise_error(Chef::Exceptions::User)
end
context "when in why run mode" do
before do
- passwd_status = double("Mixlib::ShellOut command", :exitstatus => 0, :stdout => "", :stderr => "passwd: user 'chef-test' does not exist\n")
+ 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)
# ubuntu returns 252 on user-does-not-exist so will raise if #error! is called or if
# shell_out! is used
diff --git a/spec/support/shared/unit/user_and_client_shared.rb b/spec/support/shared/unit/user_and_client_shared.rb
index 6c31ca22d1..40042933e2 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