diff options
author | Thom May <thom@chef.io> | 2016-01-14 14:08:03 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2016-01-14 14:08:03 +0000 |
commit | 51cfbdc4d16739caac4d946fadbe678444aafe34 (patch) | |
tree | 56dfd8f1cd9fd933de27268b32402e955a43ac2b /spec/functional | |
parent | 05064423057d4cf46f4713b81b08829cf6d20af6 (diff) | |
download | chef-51cfbdc4d16739caac4d946fadbe678444aafe34.tar.gz |
Use double quotes by default
This is an entirely mechanically generated (chefstyle -a) change, to go
along with chef/chefstyle#5 . We should pick something and use it
consistently, and my opinion is that double quotes are the appropriate
thing.
Diffstat (limited to 'spec/functional')
67 files changed, 742 insertions, 742 deletions
diff --git a/spec/functional/application_spec.rb b/spec/functional/application_spec.rb index 4d24549696..c21a892b54 100644 --- a/spec/functional/application_spec.rb +++ b/spec/functional/application_spec.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/shell_out' +require "spec_helper" +require "chef/mixin/shell_out" describe Chef::Application do include Chef::Mixin::ShellOut diff --git a/spec/functional/audit/rspec_formatter_spec.rb b/spec/functional/audit/rspec_formatter_spec.rb index 009374db68..b6b7cd7c78 100644 --- a/spec/functional/audit/rspec_formatter_spec.rb +++ b/spec/functional/audit/rspec_formatter_spec.rb @@ -18,12 +18,12 @@ # limitations under the License. # -require 'spec_helper' -require 'rspec/core/sandbox' -require 'chef/audit/runner' -require 'rspec/support/spec/in_sub_process' -require 'rspec/support/spec/stderr_splitter' -require 'chef/audit/rspec_formatter' +require "spec_helper" +require "rspec/core/sandbox" +require "chef/audit/runner" +require "rspec/support/spec/in_sub_process" +require "rspec/support/spec/stderr_splitter" +require "chef/audit/rspec_formatter" describe Chef::Audit::RspecFormatter do include RSpec::Support::InSubProcess diff --git a/spec/functional/audit/runner_spec.rb b/spec/functional/audit/runner_spec.rb index 4f7f27150c..64c361655d 100644 --- a/spec/functional/audit/runner_spec.rb +++ b/spec/functional/audit/runner_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' -require 'rspec/core/sandbox' -require 'chef/audit/runner' -require 'rspec/support/spec/in_sub_process' -require 'rspec/support/spec/stderr_splitter' -require 'tempfile' +require "spec_helper" +require "rspec/core/sandbox" +require "chef/audit/runner" +require "rspec/support/spec/in_sub_process" +require "rspec/support/spec/stderr_splitter" +require "tempfile" ## # This functional test ensures that our runner can be setup to not interfere with existing RSpec diff --git a/spec/functional/dsl/reboot_pending_spec.rb b/spec/functional/dsl/reboot_pending_spec.rb index 1d11f38dbc..966f8b58c5 100644 --- a/spec/functional/dsl/reboot_pending_spec.rb +++ b/spec/functional/dsl/reboot_pending_spec.rb @@ -47,19 +47,19 @@ describe Chef::DSL::RebootPending, :windows_only do describe 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations' do let(:reg_key) { 'HKLM\SYSTEM\CurrentControlSet\Control\Session Manager' } - let(:original_set) { registry.value_exists?(reg_key, { :name => 'PendingFileRenameOperations' }) } + let(:original_set) { registry.value_exists?(reg_key, { :name => "PendingFileRenameOperations" }) } it "returns true if the registry value exists" do - skip 'found existing registry key' if original_set + skip "found existing registry key" if original_set registry.set_value(reg_key, - { :name => 'PendingFileRenameOperations', :type => :multi_string, :data => ['\??\C:\foo.txt|\??\C:\bar.txt'] }) + { :name => "PendingFileRenameOperations", :type => :multi_string, :data => ['\??\C:\foo.txt|\??\C:\bar.txt'] }) expect(recipe.reboot_pending?).to be_truthy end after do unless original_set - registry.delete_value(reg_key, { :name => 'PendingFileRenameOperations' }) + registry.delete_value(reg_key, { :name => "PendingFileRenameOperations" }) end end end @@ -69,7 +69,7 @@ describe Chef::DSL::RebootPending, :windows_only do let(:original_set) { registry.key_exists?(reg_key) } it "returns true if the registry key exists" do - skip 'found existing registry key' if original_set + skip "found existing registry key" if original_set pending "Permissions are limited to 'TrustedInstaller' by default" registry.create_key(reg_key, false) @@ -88,7 +88,7 @@ describe Chef::DSL::RebootPending, :windows_only do let(:original_set) { registry.key_exists?(reg_key) } it "returns true if the registry key exists" do - skip 'found existing registry key' if original_set + skip "found existing registry key" if original_set registry.create_key(reg_key, false) expect(recipe.reboot_pending?).to be_truthy @@ -103,7 +103,7 @@ describe Chef::DSL::RebootPending, :windows_only do describe "when there is nothing to indicate a reboot is pending" do it "should return false" do - skip 'reboot pending' if @any_flag.any? { |_,v| v == true } + skip "reboot pending" if @any_flag.any? { |_,v| v == true } expect(recipe.reboot_pending?).to be_falsey end end diff --git a/spec/functional/dsl/registry_helper_spec.rb b/spec/functional/dsl/registry_helper_spec.rb index df5b09f1f6..20efade913 100644 --- a/spec/functional/dsl/registry_helper_spec.rb +++ b/spec/functional/dsl/registry_helper_spec.rb @@ -25,8 +25,8 @@ describe Chef::Resource::RegistryKey, :windows_only do ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root" ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Branch" ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root', Win32::Registry::KEY_ALL_ACCESS) do |reg| - reg['RootType1', Win32::Registry::REG_SZ] = 'fibrous' - reg.write('Roots', Win32::Registry::REG_MULTI_SZ, ["strong roots", "healthy tree"]) + reg["RootType1", Win32::Registry::REG_SZ] = "fibrous" + reg.write("Roots", Win32::Registry::REG_MULTI_SZ, ["strong roots", "healthy tree"]) end events = Chef::EventDispatch::Dispatcher.new diff --git a/spec/functional/event_loggers/windows_eventlog_spec.rb b/spec/functional/event_loggers/windows_eventlog_spec.rb index 0723e7b984..cfab3763e1 100644 --- a/spec/functional/event_loggers/windows_eventlog_spec.rb +++ b/spec/functional/event_loggers/windows_eventlog_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' -require 'securerandom' -require 'chef/event_loggers/windows_eventlog' +require "spec_helper" +require "securerandom" +require "chef/event_loggers/windows_eventlog" if Chef::Platform.windows? and not Chef::Platform::windows_server_2003? - require 'win32/eventlog' + require "win32/eventlog" include Win32 end @@ -31,45 +31,45 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_o let(:logger) { Chef::EventLoggers::WindowsEventLogger.new } let(:flags) { nil } let(:node) { nil } - let(:run_status) { double('Run Status', {run_id: run_id, elapsed_time: elapsed_time }) } + let(:run_status) { double("Run Status", {run_id: run_id, elapsed_time: elapsed_time }) } let(:event_log) { EventLog.new("Application") } let!(:offset) { event_log.read_last_event.record_number } - let(:mock_exception) { double('Exception', {message: SecureRandom.uuid, backtrace:[SecureRandom.uuid, SecureRandom.uuid]})} + let(:mock_exception) { double("Exception", {message: SecureRandom.uuid, backtrace:[SecureRandom.uuid, SecureRandom.uuid]})} - it 'is available' do + it "is available" do expect(Chef::EventLoggers::WindowsEventLogger.available?).to be_truthy end - it 'writes run_start event with event_id 10000 and contains version' do + it "writes run_start event with event_id 10000 and contains version" do logger.run_start(version) - expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10000 && + expect(event_log.read(flags, offset).any? { |e| e.source == "Chef" && e.event_id == 10000 && e.string_inserts[0].include?(version)}).to be_truthy end - it 'writes run_started event with event_id 10001 and contains the run_id' do + it "writes run_started event with event_id 10001 and contains the run_id" do logger.run_started(run_status) - expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10001 && + expect(event_log.read(flags, offset).any? { |e| e.source == "Chef" && e.event_id == 10001 && e.string_inserts[0].include?(run_id)}).to be_truthy end - it 'writes run_completed event with event_id 10002 and contains the run_id and elapsed time' do + it "writes run_completed event with event_id 10002 and contains the run_id and elapsed time" do logger.run_started(run_status) logger.run_completed(node) - expect(event_log.read(flags, offset).any? { |e| e.source == 'Chef' && e.event_id == 10002 && + expect(event_log.read(flags, offset).any? { |e| e.source == "Chef" && e.event_id == 10002 && e.string_inserts[0].include?(run_id) && e.string_inserts[1].include?(elapsed_time.to_s) }).to be_truthy end - it 'writes run_failed event with event_id 10003 and contains the run_id, elapsed time, and exception info' do + it "writes run_failed event with event_id 10003 and contains the run_id, elapsed time, and exception info" do logger.run_started(run_status) logger.run_failed(mock_exception) expect(event_log.read(flags, offset).any? do |e| - e.source == 'Chef' && e.event_id == 10003 && + e.source == "Chef" && e.event_id == 10003 && e.string_inserts[0].include?(run_id) && e.string_inserts[1].include?(elapsed_time.to_s) && e.string_inserts[2].include?(mock_exception.class.name) && @@ -79,11 +79,11 @@ describe Chef::EventLoggers::WindowsEventLogger, :windows_only, :not_supported_o end).to be_truthy end - it 'writes run_failed event with event_id 10003 even when run_status is not set' do + it "writes run_failed event with event_id 10003 even when run_status is not set" do logger.run_failed(mock_exception) expect(event_log.read(flags, offset).any? do |e| - e.source == 'Chef' && e.event_id == 10003 && + e.source == "Chef" && e.event_id == 10003 && e.string_inserts[0].include?("UNKNOWN") && e.string_inserts[1].include?("UNKNOWN") && e.string_inserts[2].include?(mock_exception.class.name) && diff --git a/spec/functional/file_content_management/deploy_strategies_spec.rb b/spec/functional/file_content_management/deploy_strategies_spec.rb index 793da28ef9..b11c3d5abf 100644 --- a/spec/functional/file_content_management/deploy_strategies_spec.rb +++ b/spec/functional/file_content_management/deploy_strategies_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" shared_examples_for "a content deploy strategy" do diff --git a/spec/functional/http/simple_spec.rb b/spec/functional/http/simple_spec.rb index 36468b4eba..7b395cba30 100644 --- a/spec/functional/http/simple_spec.rb +++ b/spec/functional/http/simple_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'tiny_server' -require 'support/shared/functional/http' +require "spec_helper" +require "tiny_server" +require "support/shared/functional/http" describe Chef::HTTP::Simple do include ChefHTTPShared @@ -84,14 +84,14 @@ describe Chef::HTTP::Simple do context "when Chef::Log.level = :debug" do before do Chef::Log.level = :debug - @debug_log = '' + @debug_log = "" allow(Chef::Log).to receive(:debug) { |str| @debug_log << str } end - let(:source) { 'http://localhost:9000' } + let(:source) { "http://localhost:9000" } it "Logs the request and response for 200's but not the body" do - http_client.get('http://localhost:9000/nyan_cat.png') + http_client.get("http://localhost:9000/nyan_cat.png") expect(@debug_log).to match(/200/) expect(@debug_log).to match(/HTTP Request Header Data/) expect(@debug_log).to match(/HTTP Status and Header Data/) @@ -101,7 +101,7 @@ describe Chef::HTTP::Simple do end it "Logs the request and response for 200 POST, but not the body" do - http_client.post('http://localhost:9000/posty', 'hithere') + http_client.post("http://localhost:9000/posty", "hithere") expect(@debug_log).to match(/200/) expect(@debug_log).to match(/HTTP Request Header Data/) expect(@debug_log).to match(/HTTP Status and Header Data/) @@ -113,7 +113,7 @@ describe Chef::HTTP::Simple do it "Logs the request and response and bodies for 400 response" do expect do - http_client.get('http://localhost:9000/bad_request') + http_client.get("http://localhost:9000/bad_request") end.to raise_error(Net::HTTPServerException) expect(@debug_log).to match(/400/) expect(@debug_log).to match(/HTTP Request Header Data/) @@ -126,7 +126,7 @@ describe Chef::HTTP::Simple do it "Logs the request and response and bodies for 400 POST response" do expect do - http_client.post('http://localhost:9000/bad_request', 'hithere') + http_client.post("http://localhost:9000/bad_request", "hithere") end.to raise_error(Net::HTTPServerException) expect(@debug_log).to match(/400/) expect(@debug_log).to match(/HTTP Request Header Data/) diff --git a/spec/functional/knife/configure_spec.rb b/spec/functional/knife/configure_spec.rb index 3bef18a0aa..4c02f15200 100644 --- a/spec/functional/knife/configure_spec.rb +++ b/spec/functional/knife/configure_spec.rb @@ -16,23 +16,23 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/knife/configure' -require 'ohai' +require "chef/knife/configure" +require "ohai" describe "knife configure" do let (:ohai) do o = Ohai::System.new o.load_plugins - o.require_plugin 'os' - o.require_plugin 'hostname' + o.require_plugin "os" + o.require_plugin "hostname" o end it "loads the fqdn from Ohai" do knife_configure = Chef::Knife::Configure.new - hostname_guess = ohai[:fqdn] || ohai[:machinename] || ohai[:hostname] || 'localhost' + hostname_guess = ohai[:fqdn] || ohai[:machinename] || ohai[:hostname] || "localhost" expect(knife_configure.guess_servername).to eql(hostname_guess) end end diff --git a/spec/functional/knife/cookbook_delete_spec.rb b/spec/functional/knife/cookbook_delete_spec.rb index bffad8cbed..9b847ba2da 100644 --- a/spec/functional/knife/cookbook_delete_spec.rb +++ b/spec/functional/knife/cookbook_delete_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tiny_server' +require "spec_helper" +require "tiny_server" describe Chef::Knife::CookbookDelete do before(:all) do @@ -32,7 +32,7 @@ describe Chef::Knife::CookbookDelete do Chef::Config[:node_name] = nil Chef::Config[:client_key] = nil - Chef::Config[:chef_server_url] = 'http://localhost:9000' + Chef::Config[:chef_server_url] = "http://localhost:9000" end after(:all) do @@ -44,7 +44,7 @@ describe Chef::Knife::CookbookDelete do before do @knife.name_args = %w{no-such-cookbook} - @api.get("/cookbooks/no-such-cookbook", 404, Chef::JSONCompat.to_json({'error'=>'dear Tim, no. -Sent from my iPad'})) + @api.get("/cookbooks/no-such-cookbook", 404, Chef::JSONCompat.to_json({"error"=>"dear Tim, no. -Sent from my iPad"})) end around do |ex| @@ -71,7 +71,7 @@ describe Chef::Knife::CookbookDelete do context "when there is only one version of a cookbook" do before do @knife.name_args = %w{obsolete-cookbook} - @cookbook_list = {'obsolete-cookbook' => { 'versions' => ['version' => '1.0.0']} } + @cookbook_list = {"obsolete-cookbook" => { "versions" => ["version" => "1.0.0"]} } @api.get("/cookbooks/obsolete-cookbook", 200, Chef::JSONCompat.to_json(@cookbook_list)) end @@ -112,9 +112,9 @@ describe Chef::Knife::CookbookDelete do context "when there are several versions of a cookbook" do before do @knife.name_args = %w{obsolete-cookbook} - versions = ['1.0.0', '1.1.0', '1.2.0'] - with_version = lambda { |version| { 'version' => version } } - @cookbook_list = {'obsolete-cookbook' => { 'versions' => versions.map(&with_version) } } + versions = ["1.0.0", "1.1.0", "1.2.0"] + with_version = lambda { |version| { "version" => version } } + @cookbook_list = {"obsolete-cookbook" => { "versions" => versions.map(&with_version) } } @api.get("/cookbooks/obsolete-cookbook", 200, Chef::JSONCompat.to_json(@cookbook_list)) end diff --git a/spec/functional/knife/exec_spec.rb b/spec/functional/knife/exec_spec.rb index 6262094a9f..9fa0bcc83a 100644 --- a/spec/functional/knife/exec_spec.rb +++ b/spec/functional/knife/exec_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tiny_server' +require "spec_helper" +require "tiny_server" describe Chef::Knife::Exec do before(:all) do @@ -32,7 +32,7 @@ describe Chef::Knife::Exec do Chef::Config[:node_name] = nil Chef::Config[:client_key] = nil - Chef::Config[:chef_server_url] = 'http://localhost:9000' + Chef::Config[:chef_server_url] = "http://localhost:9000" $output = StringIO.new end diff --git a/spec/functional/knife/smoke_test.rb b/spec/functional/knife/smoke_test.rb index b718bc50e0..77ee4a88fb 100644 --- a/spec/functional/knife/smoke_test.rb +++ b/spec/functional/knife/smoke_test.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe "knife smoke tests" do diff --git a/spec/functional/knife/ssh_spec.rb b/spec/functional/knife/ssh_spec.rb index 0844a0aa85..56ba2ecfa2 100644 --- a/spec/functional/knife/ssh_spec.rb +++ b/spec/functional/knife/ssh_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tiny_server' +require "spec_helper" +require "tiny_server" describe Chef::Knife::Ssh do @@ -50,7 +50,7 @@ describe Chef::Knife::Ssh do describe "identity file" do context "when knife[:ssh_identity_file] is set" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/aws.rsa" end @@ -62,7 +62,7 @@ describe Chef::Knife::Ssh do context "when knife[:ssh_identity_file] is set and frozen" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_identity_file] = "~/.ssh/aws.rsa".freeze end @@ -74,7 +74,7 @@ describe Chef::Knife::Ssh do context "when -i is provided" do before do - setup_knife(['-i ~/.ssh/aws.rsa', '*:*', 'uptime']) + setup_knife(["-i ~/.ssh/aws.rsa", "*:*", "uptime"]) Chef::Config[:knife][:ssh_identity_file] = nil end @@ -92,7 +92,7 @@ describe Chef::Knife::Ssh do context "when knife[:ssh_identity_file] is not provided]" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_identity_file] = nil end @@ -106,7 +106,7 @@ describe Chef::Knife::Ssh do describe "port" do context "when -p 31337 is provided" do before do - setup_knife(['-p 31337', '*:*', 'uptime']) + setup_knife(["-p 31337", "*:*", "uptime"]) end it "uses the ssh_port" do @@ -119,7 +119,7 @@ describe Chef::Knife::Ssh do describe "user" do context "when knife[:ssh_user] is set" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_user] = "ubuntu" end @@ -131,7 +131,7 @@ describe Chef::Knife::Ssh do context "when knife[:ssh_user] is set and frozen" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_user] = "ubuntu".freeze end @@ -143,7 +143,7 @@ describe Chef::Knife::Ssh do context "when -x is provided" do before do - setup_knife(['-x ubuntu', '*:*', 'uptime']) + setup_knife(["-x ubuntu", "*:*", "uptime"]) Chef::Config[:knife][:ssh_user] = nil end @@ -161,7 +161,7 @@ describe Chef::Knife::Ssh do context "when knife[:ssh_user] is not provided]" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_user] = nil end @@ -175,7 +175,7 @@ describe Chef::Knife::Ssh do describe "attribute" do context "when knife[:ssh_attribute] is set" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_attribute] = "ec2.public_hostname" end @@ -187,7 +187,7 @@ describe Chef::Knife::Ssh do context "when knife[:ssh_attribute] is not provided]" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_attribute] = nil end @@ -199,7 +199,7 @@ describe Chef::Knife::Ssh do context "when -a ec2.public_ipv4 is provided" do before do - setup_knife(['-a ec2.public_hostname', '*:*', 'uptime']) + setup_knife(["-a ec2.public_hostname", "*:*", "uptime"]) Chef::Config[:knife][:ssh_attribute] = nil end @@ -212,7 +212,7 @@ describe Chef::Knife::Ssh do # This is the setting imported from knife.rb Chef::Config[:knife][:ssh_attribute] = "fqdn" # Then we run knife with the -a flag, which sets the above variable - setup_knife(['-a ec2.public_hostname', '*:*', 'uptime']) + setup_knife(["-a ec2.public_hostname", "*:*", "uptime"]) @knife.run expect(@knife.config[:attribute]).to eq("ec2.public_hostname") end @@ -222,7 +222,7 @@ describe Chef::Knife::Ssh do describe "gateway" do context "when knife[:ssh_gateway] is set" do before do - setup_knife(['*:*', 'uptime']) + setup_knife(["*:*", "uptime"]) Chef::Config[:knife][:ssh_gateway] = "user@ec2.public_hostname" end @@ -235,7 +235,7 @@ describe Chef::Knife::Ssh do context "when -G user@ec2.public_hostname is provided" do before do - setup_knife(['-G user@ec2.public_hostname', '*:*', 'uptime']) + setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"]) Chef::Config[:knife][:ssh_gateway] = nil end @@ -248,7 +248,7 @@ describe Chef::Knife::Ssh do context "when the gateway requires a password" do before do - setup_knife(['-G user@ec2.public_hostname', '*:*', 'uptime']) + setup_knife(["-G user@ec2.public_hostname", "*:*", "uptime"]) Chef::Config[:knife][:ssh_gateway] = nil allow(@knife.session).to receive(:via) do |host, user, options| raise Net::SSH::AuthenticationFailed unless options[:password] @@ -274,7 +274,7 @@ describe Chef::Knife::Ssh do Chef::Config[:node_name] = nil Chef::Config[:client_key] = nil - Chef::Config[:chef_server_url] = 'http://localhost:9000' + Chef::Config[:chef_server_url] = "http://localhost:9000" @api.get("/search/node?q=*:*&sort=X_CHEF_id_CHEF_X%20asc&start=0", 200) { %({"total":1, "start":0, "rows":[{"name":"i-xxxxxxxx", "json_class":"Chef::Node", "automatic":{"fqdn":"the.fqdn", "ec2":{"public_hostname":"the_public_hostname"}},"recipes":[]}]}) diff --git a/spec/functional/mixin/powershell_out_spec.rb b/spec/functional/mixin/powershell_out_spec.rb index 9cc8aeed7e..9d966c0b55 100644 --- a/spec/functional/mixin/powershell_out_spec.rb +++ b/spec/functional/mixin/powershell_out_spec.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/powershell_out' +require "spec_helper" +require "chef/mixin/powershell_out" describe Chef::Mixin::PowershellOut, windows_only: true do include Chef::Mixin::PowershellOut diff --git a/spec/functional/mixin/shell_out_spec.rb b/spec/functional/mixin/shell_out_spec.rb index 8f8b54414a..3c05eec8aa 100644 --- a/spec/functional/mixin/shell_out_spec.rb +++ b/spec/functional/mixin/shell_out_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Mixin::ShellOut do include Chef::Mixin::ShellOut @@ -24,24 +24,24 @@ describe Chef::Mixin::ShellOut do describe "when environment['LC_ALL'] is not set" do it "should use the default shell_out setting" do cmd = if windows? - shell_out_with_systems_locale('echo %LC_ALL%') + shell_out_with_systems_locale("echo %LC_ALL%") else - shell_out_with_systems_locale('echo $LC_ALL') + shell_out_with_systems_locale("echo $LC_ALL") end - expect(cmd.stdout.chomp).to match_environment_variable('LC_ALL') + expect(cmd.stdout.chomp).to match_environment_variable("LC_ALL") end end describe "when environment['LC_ALL'] is set" do it "should use the option's setting" do cmd = if windows? - shell_out_with_systems_locale('echo %LC_ALL%', :environment => {'LC_ALL' => 'POSIX'}) + shell_out_with_systems_locale("echo %LC_ALL%", :environment => {"LC_ALL" => "POSIX"}) else - shell_out_with_systems_locale('echo $LC_ALL', :environment => {'LC_ALL' => 'POSIX'}) + shell_out_with_systems_locale("echo $LC_ALL", :environment => {"LC_ALL" => "POSIX"}) end - expect(cmd.stdout.chomp).to eq 'POSIX' + expect(cmd.stdout.chomp).to eq "POSIX" end end end diff --git a/spec/functional/notifications_spec.rb b/spec/functional/notifications_spec.rb index d448ea175d..ec6e514836 100644 --- a/spec/functional/notifications_spec.rb +++ b/spec/functional/notifications_spec.rb @@ -1,5 +1,5 @@ -require 'spec_helper' -require 'chef/recipe' +require "spec_helper" +require "chef/recipe" # The goal of these tests is to make sure that loading resources from a file creates the necessary notifications. diff --git a/spec/functional/provider/remote_file/cache_control_data_spec.rb b/spec/functional/provider/remote_file/cache_control_data_spec.rb index 41f228ae3c..5b31f64f64 100755 --- a/spec/functional/provider/remote_file/cache_control_data_spec.rb +++ b/spec/functional/provider/remote_file/cache_control_data_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'uri' +require "spec_helper" +require "uri" describe Chef::Provider::RemoteFile::CacheControlData do @@ -75,7 +75,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do # file system API's on both Windows and Unix systems. context "when the length of the uri exceeds the path length limits for the local file system" do let(:uri_exceeds_file_system_limit) do - URI.parse("http://www.bing.com/" + ('0' * 1024)) + URI.parse("http://www.bing.com/" + ("0" * 1024)) end let(:uri) { uri_exceeds_file_system_limit } diff --git a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb index 2b582feb05..529f5da884 100644 --- a/spec/functional/provider/whyrun_safe_ruby_block_spec.rb +++ b/spec/functional/provider/whyrun_safe_ruby_block_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::WhyrunSafeRubyBlock do let(:node) { Chef::Node.new } diff --git a/spec/functional/rebooter_spec.rb b/spec/functional/rebooter_spec.rb index 79f3a49010..da104c0304 100644 --- a/spec/functional/rebooter_spec.rb +++ b/spec/functional/rebooter_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Platform::Rebooter do @@ -68,7 +68,7 @@ describe Chef::Platform::Rebooter do run_context.cancel_reboot end - shared_context 'test a reboot method' do + shared_context "test a reboot method" do def test_rebooter_method(method_sym, is_windows, expected_reboot_str) allow(ChefConfig).to receive(:windows?).and_return(is_windows) expect(rebooter).to receive(:shell_out!).once.with(expected_reboot_str) @@ -78,25 +78,25 @@ describe Chef::Platform::Rebooter do end describe 'when using #reboot_if_needed!' do - include_context 'test a reboot method' + include_context "test a reboot method" - it 'should produce the correct string on Windows' do + it "should produce the correct string on Windows" do test_rebooter_method(:reboot_if_needed!, true, expected[:windows]) end - it 'should produce the correct (Linux-specific) string on non-Windows' do + it "should produce the correct (Linux-specific) string on non-Windows" do test_rebooter_method(:reboot_if_needed!, false, expected[:linux]) end end describe 'when using #reboot!' do - include_context 'test a reboot method' + include_context "test a reboot method" - it 'should produce the correct string on Windows' do + it "should produce the correct string on Windows" do test_rebooter_method(:reboot!, true, expected[:windows]) end - it 'should produce the correct (Linux-specific) string on non-Windows' do + it "should produce the correct (Linux-specific) string on non-Windows" do test_rebooter_method(:reboot!, false, expected[:linux]) end end diff --git a/spec/functional/resource/aix_service_spec.rb b/spec/functional/resource/aix_service_spec.rb index 604c04dad7..e249bd9bc0 100755 --- a/spec/functional/resource/aix_service_spec.rb +++ b/spec/functional/resource/aix_service_spec.rb @@ -17,24 +17,24 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' -require 'chef/mixin/shell_out' +require "spec_helper" +require "functional/resource/base" +require "chef/mixin/shell_out" shared_examples "src service" do include Chef::Mixin::ShellOut def service_should_be_started - expect(shell_out!("lssrc -a | grep #{new_resource.service_name}").stdout.split(' ').last).to eq("active") + expect(shell_out!("lssrc -a | grep #{new_resource.service_name}").stdout.split(" ").last).to eq("active") end def service_should_be_stopped - expect(shell_out!("lssrc -a | grep #{new_resource.service_name}").stdout.split(' ').last).to eq("inoperative") + expect(shell_out!("lssrc -a | grep #{new_resource.service_name}").stdout.split(" ").last).to eq("inoperative") end def get_service_pid - args = shell_out!("lssrc -a | grep #{new_resource.service_name}").stdout.split(' ') + args = shell_out!("lssrc -a | grep #{new_resource.service_name}").stdout.split(" ") if args.length == 3 args[1] else diff --git a/spec/functional/resource/aixinit_service_spec.rb b/spec/functional/resource/aixinit_service_spec.rb index 3e19a16af0..6b87725c34 100755 --- a/spec/functional/resource/aixinit_service_spec.rb +++ b/spec/functional/resource/aixinit_service_spec.rb @@ -17,10 +17,10 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' -require 'chef/mixin/shell_out' -require 'fileutils' +require "spec_helper" +require "functional/resource/base" +require "chef/mixin/shell_out" +require "fileutils" describe Chef::Resource::Service, :requires_root, :aix_only do @@ -130,7 +130,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do context "when the service doesn't set a priority" do it "creates symlink with status S" do new_resource.run_action(:enable) - valide_symlinks(["/etc/rc.d/rc2.d/Schefinittest"],2,'S') + valide_symlinks(["/etc/rc.d/rc2.d/Schefinittest"],2,"S") end end @@ -141,7 +141,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do it "creates a symlink with status S and a priority" do new_resource.run_action(:enable) - valide_symlinks(["/etc/rc.d/rc2.d/S75chefinittest"], 2,'S',75) + valide_symlinks(["/etc/rc.d/rc2.d/S75chefinittest"], 2,"S",75) end end @@ -153,7 +153,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do it "create symlink with status start (S) or stop (K) and a priority " do new_resource.run_action(:enable) - valide_symlinks(["/etc/rc.d/rc2.d/S20chefinittest", "/etc/rc.d/rc3.d/K10chefinittest"], 2,'S',new_resource.priority) + valide_symlinks(["/etc/rc.d/rc2.d/S20chefinittest", "/etc/rc.d/rc3.d/K10chefinittest"], 2,"S",new_resource.priority) end end end @@ -171,7 +171,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do it "creates symlink with status K" do new_resource.run_action(:disable) - valide_symlinks(["/etc/rc.d/rc2.d/Kchefinittest"], 2,'K') + valide_symlinks(["/etc/rc.d/rc2.d/Kchefinittest"], 2,"K") end end @@ -187,7 +187,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do it "creates a symlink with status K and a priority" do new_resource.run_action(:disable) - valide_symlinks(["/etc/rc.d/rc2.d/K25chefinittest"], 2,'K',25) + valide_symlinks(["/etc/rc.d/rc2.d/K25chefinittest"], 2,"K",25) end end @@ -204,7 +204,7 @@ describe Chef::Resource::Service, :requires_root, :aix_only do it "create symlink with status stop (K) and a priority " do new_resource.run_action(:disable) - valide_symlinks(["/etc/rc.d/rc2.d/K80chefinittest"], 2,'K',80) + valide_symlinks(["/etc/rc.d/rc2.d/K80chefinittest"], 2,"K",80) end end end diff --git a/spec/functional/resource/bash_spec.rb b/spec/functional/resource/bash_spec.rb index 209ec4a12f..0edc415ac1 100644 --- a/spec/functional/resource/bash_spec.rb +++ b/spec/functional/resource/bash_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' +require "spec_helper" +require "functional/resource/base" describe Chef::Resource::Bash, :unix_only do let(:code) { "echo hello" } @@ -28,7 +28,7 @@ describe Chef::Resource::Bash, :unix_only do } describe "when setting the command attribute" do - let (:command) { 'wizard racket' } + let (:command) { "wizard racket" } # in Chef-12 the `command` attribute is largely useless, but does set the identity attribute # so that notifications need to target the value of the command. it will not run the `command` @@ -81,7 +81,7 @@ describe Chef::Resource::Bash, :unix_only do end it "times out when a timeout is set on the resource" do - resource.code 'sleep 600' + resource.code "sleep 600" resource.timeout 0.1 expect { resource.run_action(:run) }.to raise_error(Mixlib::ShellOut::CommandTimeout) end diff --git a/spec/functional/resource/batch_spec.rb b/spec/functional/resource/batch_spec.rb index 39133fd40b..09d51e8eec 100644 --- a/spec/functional/resource/batch_spec.rb +++ b/spec/functional/resource/batch_spec.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::WindowsScript::Batch, :windows_only do include_context Chef::Resource::WindowsScript - let(:output_command) { ' > ' } + let(:output_command) { " > " } - let (:architecture_command) { '@echo %PROCESSOR_ARCHITECTURE%' } + let (:architecture_command) { "@echo %PROCESSOR_ARCHITECTURE%" } it_behaves_like "a Windows script running on Windows" diff --git a/spec/functional/resource/bff_spec.rb b/spec/functional/resource/bff_spec.rb index b969254b6b..a8083b049e 100644 --- a/spec/functional/resource/bff_spec.rb +++ b/spec/functional/resource/bff_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'functional/resource/base' -require 'chef/mixin/shell_out' +require "functional/resource/base" +require "chef/mixin/shell_out" # Run the test only for AIX platform. -describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform] != 'aix' do +describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform] != "aix" do include Chef::Mixin::ShellOut let(:new_resource) do @@ -43,7 +43,7 @@ describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform before(:all) do @pkg_name = "PkgA.rte" @pkg_path = "/tmp/PkgA.1.0.0.0.bff" - FileUtils.cp 'spec/functional/assets/PkgA.1.0.0.0.bff' , @pkg_path + FileUtils.cp "spec/functional/assets/PkgA.1.0.0.0.bff" , @pkg_path end after(:all) do @@ -78,7 +78,7 @@ describe Chef::Resource::BffPackage, :requires_root, :external => ohai[:platform before(:each) do shell_out("installp -aYF -d #{@pkg_path} #{@pkg_name}") @pkg_path = "/tmp/PkgA.2.0.0.0.bff" - FileUtils.cp 'spec/functional/assets/PkgA.2.0.0.0.bff' , @pkg_path + FileUtils.cp "spec/functional/assets/PkgA.2.0.0.0.bff" , @pkg_path end it "should upgrade package" do diff --git a/spec/functional/resource/cookbook_file_spec.rb b/spec/functional/resource/cookbook_file_spec.rb index 6d4c5b4a8f..e91737572b 100644 --- a/spec/functional/resource/cookbook_file_spec.rb +++ b/spec/functional/resource/cookbook_file_spec.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::CookbookFile do include_context Chef::Resource::File - let(:file_base) { 'cookbook_file_spec' } - let(:source) { 'java.response' } - let(:cookbook_name) { 'java' } + let(:file_base) { "cookbook_file_spec" } + let(:source) { "java.response" } + let(:cookbook_name) { "java" } let(:expected_content) do - content = File.open(File.join(CHEF_SPEC_DATA, 'cookbooks', 'java', 'files', 'default', 'java.response'), "rb") do |f| + content = File.open(File.join(CHEF_SPEC_DATA, "cookbooks", "java", "files", "default", "java.response"), "rb") do |f| f.read end content.force_encoding(Encoding::BINARY) if content.respond_to?(:force_encoding) @@ -39,7 +39,7 @@ describe Chef::Resource::CookbookFile do def create_resource # set up cookbook collection for this run to use, based on our # spec data. - cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, 'cookbooks')) + cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) Chef::Cookbook::FileVendor.fetch_from_disk(cookbook_repo) loader = Chef::CookbookLoader.new(cookbook_repo) loader.load_cookbooks @@ -66,7 +66,7 @@ describe Chef::Resource::CookbookFile do # implementation # stages files in temp. context "targets a file outside of the system temp directory" do - let(:windows_non_temp_dir) { File.join(ENV['systemdrive'], make_tmpname(file_base, "non-temp")) } + let(:windows_non_temp_dir) { File.join(ENV["systemdrive"], make_tmpname(file_base, "non-temp")) } let(:path) { File.join(windows_non_temp_dir, make_tmpname(file_base)) } before do diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb index ed30756583..ac13f934ff 100644 --- a/spec/functional/resource/cron_spec.rb +++ b/spec/functional/resource/cron_spec.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' -require 'chef/mixin/shell_out' +require "spec_helper" +require "functional/resource/base" +require "chef/mixin/shell_out" describe Chef::Resource::Cron, :requires_root, :unix_only do @@ -55,17 +55,17 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do # Actual tests let(:new_resource) do new_resource = Chef::Resource::Cron.new("Chef functional test cron", run_context) - new_resource.user 'root' + new_resource.user "root" # @hourly is not supported on solaris, aix if ohai[:platform] == "solaris" || ohai[:platform] == "solaris2" || ohai[:platform] == "aix" new_resource.minute "0 * * * *" else - new_resource.minute '@hourly' + new_resource.minute "@hourly" end - new_resource.hour '' - new_resource.day '' - new_resource.month '' - new_resource.weekday '' + new_resource.hour "" + new_resource.day "" + new_resource.month "" + new_resource.weekday "" new_resource.command "/bin/true" new_resource end @@ -107,7 +107,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do exclude_solaris = ["solaris", "opensolaris", "solaris2", "omnios"].include?(ohai[:platform]) describe "create action with various attributes", :external => exclude_solaris do def create_and_validate_with_attribute(resource, attribute, value) - if ohai[:platform] == 'aix' + if ohai[:platform] == "aix" expect {resource.run_action(:create)}.to raise_error(Chef::Exceptions::Cron, /Aix cron entry does not support environment variables. Please set them in script and use script in cron./) else resource.run_action(:create) @@ -117,7 +117,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do end def cron_attribute_should_exists(cron_name, attribute, value) - return if ['aix', 'solaris'].include?(ohai[:platform]) + return if ["aix", "solaris"].include?(ohai[:platform]) # Test if the attribute exists on newly created cron cron_should_exists(cron_name, "") expect(shell_out("crontab -l -u #{new_resource.user} | grep \"#{attribute.upcase}=#{value}\"").exitstatus).to eq(0) diff --git a/spec/functional/resource/deploy_revision_spec.rb b/spec/functional/resource/deploy_revision_spec.rb index 4bce309a51..8b888ddf6a 100644 --- a/spec/functional/resource/deploy_revision_spec.rb +++ b/spec/functional/resource/deploy_revision_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tmpdir' +require "spec_helper" +require "tmpdir" # Deploy relies heavily on symlinks, so it doesn't work on windows. describe Chef::Resource::DeployRevision, :unix_only => true do diff --git a/spec/functional/resource/directory_spec.rb b/spec/functional/resource/directory_spec.rb index 88a810964f..2097ad02b7 100644 --- a/spec/functional/resource/directory_spec.rb +++ b/spec/functional/resource/directory_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Directory do include_context Chef::Resource::Directory diff --git a/spec/functional/resource/dpkg_package_spec.rb b/spec/functional/resource/dpkg_package_spec.rb index aebe2475a5..ebfb1e3ffb 100644 --- a/spec/functional/resource/dpkg_package_spec.rb +++ b/spec/functional/resource/dpkg_package_spec.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/shell_out' +require "spec_helper" +require "chef/mixin/shell_out" describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: "x86_64" do include Chef::Mixin::ShellOut @@ -61,7 +61,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: it "installs a package when given only the filename as a name argument (no source)" do dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') + shell_out!("dpkg -s chef-integration-test") end it "installs a package when given the name and a source argument" do @@ -69,7 +69,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.source test1_0 dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') + shell_out!("dpkg -s chef-integration-test") end it "installs a package when given a different name and a source argument" do @@ -77,7 +77,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.source test1_0 dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') + shell_out!("dpkg -s chef-integration-test") end it "installs a package when given a path as a package_name and no source" do @@ -85,7 +85,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.package_name test1_0 dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') + shell_out!("dpkg -s chef-integration-test") end it "raises an error when the name is not a path and the source is not given" do @@ -109,15 +109,15 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: shell_out!("dpkg -i #{test1_0}") dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') + shell_out!("dpkg -s chef-integration-test") end it "should handle a multipackage install" do set_dpkg_package_name [ test1_0, test2_0 ] dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') - shell_out!('dpkg -s chef-integration-test2') + shell_out!("dpkg -s chef-integration-test") + shell_out!("dpkg -s chef-integration-test2") end it "should not update multipackages that are up-to-date" do @@ -125,8 +125,8 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name [ test1_0, test2_0 ] dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') - shell_out!('dpkg -s chef-integration-test2') + shell_out!("dpkg -s chef-integration-test") + shell_out!("dpkg -s chef-integration-test2") end it "should install the second if the first is installed" do @@ -134,8 +134,8 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name [ test1_0, test2_0 ] dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') - shell_out!('dpkg -s chef-integration-test2') + shell_out!("dpkg -s chef-integration-test") + shell_out!("dpkg -s chef-integration-test2") end it "should install the first if the second is installed" do @@ -143,8 +143,8 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name [ test1_0, test2_0 ] dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test') - shell_out!('dpkg -s chef-integration-test2') + shell_out!("dpkg -s chef-integration-test") + shell_out!("dpkg -s chef-integration-test2") end end @@ -191,13 +191,13 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: shell_out!("dpkg -i #{test1_0}") dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should do nothing if the package is not installed when the name is a source" do dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should remove a package that is installed when the name is the package name and source is nil" do @@ -205,14 +205,14 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name "chef-integration-test" dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should do nothing if the package is not installed when the name is the package name and the source is nil" do set_dpkg_package_name "chef-integration-test" dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should remove a package that is installed when the name is changed but the source is a package" do @@ -221,7 +221,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.source test1_0 dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should do nothing if the package is not installed when the name is changed but the source is a package" do @@ -229,7 +229,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.source test1_0 dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should remove a package if the name is a file that does not exist, but the source exists" do @@ -239,7 +239,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.source test1_0 dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should do nothing if the package is not installed when the name is a file that does not exist, but the source exists" do @@ -249,7 +249,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.source test1_0 dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should remove a package if the package_name is correct, but the source does not exist" do @@ -259,7 +259,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.source File.join(test1_0, "make.it.fail") dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should do nothing if the package_name is correct, but the source does not exist, and the package is not installed" do @@ -268,7 +268,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: dpkg_package.source File.join(test1_0, "make.it.fail") dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') + should_be_purged_or_removed("chef-integration-test") end it "should remove both packages when called with two" do @@ -276,8 +276,8 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ] dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') - should_be_purged_or_removed('chef-integration-test2', action) + should_be_purged_or_removed("chef-integration-test") + should_be_purged_or_removed("chef-integration-test2", action) end it "should remove a package when only the first one is installed" do @@ -285,8 +285,8 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ] dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') - should_be_purged_or_removed('chef-integration-test2') + should_be_purged_or_removed("chef-integration-test") + should_be_purged_or_removed("chef-integration-test2") end it "should remove a package when only the second one is installed" do @@ -294,16 +294,16 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ] dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') - should_be_purged_or_removed('chef-integration-test2', action) + should_be_purged_or_removed("chef-integration-test") + should_be_purged_or_removed("chef-integration-test2", action) end it "should do nothing when both packages are not installed" do set_dpkg_package_name [ "chef-integration-test", "chef-integration-test2" ] dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test') - should_be_purged_or_removed('chef-integration-test2') + should_be_purged_or_removed("chef-integration-test") + should_be_purged_or_removed("chef-integration-test2") end end @@ -318,7 +318,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name "chef-integration-test2" dpkg_package.run_action(action) expect(dpkg_package).not_to be_updated_by_last_action - shell_out!('dpkg -s chef-integration-test2') # its still 'installed' + shell_out!("dpkg -s chef-integration-test2") # its still 'installed' end end @@ -333,7 +333,7 @@ describe Chef::Resource::DpkgPackage, :requires_root, :debian_family_only, arch: set_dpkg_package_name "chef-integration-test2" dpkg_package.run_action(action) expect(dpkg_package).to be_updated_by_last_action - should_be_purged_or_removed('chef-integration-test2', action) + should_be_purged_or_removed("chef-integration-test2", action) end end end diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb index 24503f1ec7..07c0bf5eb9 100644 --- a/spec/functional/resource/dsc_resource_spec.rb +++ b/spec/functional/resource/dsc_resource_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::DscResource, :windows_powershell_dsc_only do before(:all) do @ohai = Ohai::System.new - @ohai.all_plugins(['platform', 'os', 'languages/powershell']) + @ohai.all_plugins(["platform", "os", "languages/powershell"]) end let(:event_dispatch) { Chef::EventDispatch::Dispatcher.new } @@ -38,25 +38,25 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do Chef::Resource::DscResource.new("dsc_resource_test", run_context) } - context 'when Powershell does not support Invoke-DscResource' - context 'when Powershell supports Invoke-DscResource' do + context "when Powershell does not support Invoke-DscResource" + context "when Powershell supports Invoke-DscResource" do before do if !Chef::Platform.supports_dsc_invoke_resource?(node) - skip 'Requires Powershell >= 5.0.10018.0' + skip "Requires Powershell >= 5.0.10018.0" elsif !Chef::Platform.dsc_refresh_mode_disabled?(node) - skip 'Requires LCM RefreshMode is Disabled' + skip "Requires LCM RefreshMode is Disabled" end end - context 'with an invalid dsc resource' do - it 'raises an exception if the resource is not found' do - new_resource.resource 'thisdoesnotexist' + context "with an invalid dsc resource" do + it "raises an exception if the resource is not found" do + new_resource.resource "thisdoesnotexist" expect { new_resource.run_action(:run) }.to raise_error( Chef::Exceptions::ResourceNotFound) end end - context 'with a valid dsc resource' do - let(:tmp_file_name) { Dir::Tmpname.create('tmpfile') {} } + context "with a valid dsc resource" do + let(:tmp_file_name) { Dir::Tmpname.create("tmpfile") {} } let(:test_text) { "'\"!@#$%^&*)(}{][\u2713~n"} before do @@ -69,16 +69,16 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only do File.delete(tmp_file_name) if File.exists? tmp_file_name end - it 'converges the resource if it is not converged' do + it "converges the resource if it is not converged" do new_resource.run_action(:run) - contents = File.open(tmp_file_name, 'rb:bom|UTF-16LE') do |f| - f.read.encode('UTF-8') + contents = File.open(tmp_file_name, "rb:bom|UTF-16LE") do |f| + f.read.encode("UTF-8") end expect(contents).to eq(test_text) expect(new_resource).to be_updated end - it 'does not converge the resource if it is already converged' do + it "does not converge the resource if it is already converged" do new_resource.run_action(:run) expect(new_resource).to be_updated reresource = diff --git a/spec/functional/resource/dsc_script_spec.rb b/spec/functional/resource/dsc_script_spec.rb index 2e0830e02e..67fa30d815 100644 --- a/spec/functional/resource/dsc_script_spec.rb +++ b/spec/functional/resource/dsc_script_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/shell_out' -require 'chef/mixin/windows_architecture_helper' -require 'support/shared/integration/integration_helper' +require "spec_helper" +require "chef/mixin/shell_out" +require "chef/mixin/windows_architecture_helper" +require "support/shared/integration/integration_helper" describe Chef::Resource::DscScript, :windows_powershell_dsc_only do include Chef::Mixin::WindowsArchitectureHelper @@ -35,10 +35,10 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do def create_config_script_from_code(code, configuration_name, data = false) script_code = data ? code : "Configuration '#{configuration_name}'\n{\n\t#{code}\n}\n" - data_suffix = data ? '_config_data' : '' - extension = data ? 'psd1' : 'ps1' + data_suffix = data ? "_config_data" : "" + extension = data ? "psd1" : "ps1" script_path = "#{@temp_dir}/dsc_functional_test#{data_suffix}.#{extension}" - ::File.open(script_path, 'wt') do | script | + ::File.open(script_path, "wt") do | script | script.write(script_code) end script_path @@ -61,28 +61,28 @@ describe Chef::Resource::DscScript, :windows_powershell_dsc_only do end end - let(:dsc_env_variable) { 'chefenvtest' } - let(:dsc_env_value1) { 'value1' } - let(:env_value2) { 'value2' } + let(:dsc_env_variable) { "chefenvtest" } + let(:dsc_env_value1) { "value1" } + let(:env_value2) { "value2" } let(:dsc_test_run_context) { node = Chef::Node.new - node.automatic['platform'] = 'windows' - node.automatic['platform_version'] = '6.1' - node.automatic['kernel'][:machine] = :x86_64 # Only 64-bit architecture is supported - node.automatic[:languages][:powershell][:version] = '4.0' + node.automatic["platform"] = "windows" + node.automatic["platform_version"] = "6.1" + node.automatic["kernel"][:machine] = :x86_64 # Only 64-bit architecture is supported + node.automatic[:languages][:powershell][:version] = "4.0" empty_events = Chef::EventDispatch::Dispatcher.new Chef::RunContext.new(node, {}, empty_events) } - let(:dsc_test_resource_name) { 'DSCTest' } + let(:dsc_test_resource_name) { "DSCTest" } let(:dsc_test_resource_base) { Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context) } let(:test_registry_key) { 'HKEY_LOCAL_MACHINE\Software\Chef\Spec\Functional\Resource\dsc_script_spec' } - let(:test_registry_value) { 'Registration' } - let(:test_registry_data1) { 'LL927' } - let(:test_registry_data2) { 'LL928' } - let(:reg_key_name_param_name) { 'testregkeyname' } - let(:reg_key_value_param_name) { 'testregvaluename' } + let(:test_registry_value) { "Registration" } + let(:test_registry_data1) { "LL927" } + let(:test_registry_data2) { "LL928" } + let(:reg_key_name_param_name) { "testregkeyname" } + let(:reg_key_value_param_name) { "testregvaluename" } let(:registry_embedded_parameters) { "$#{reg_key_name_param_name} = '#{test_registry_key}';$#{reg_key_value_param_name} = '#{test_registry_value}'"} let(:dsc_reg_code) { <<-EOH #{registry_embedded_parameters} @@ -103,15 +103,15 @@ EOH EOH } - let(:dsc_user_prefix) { 'dsc' } - let(:dsc_user_suffix) { 'chefx' } + let(:dsc_user_prefix) { "dsc" } + let(:dsc_user_suffix) { "chefx" } let(:dsc_user) {"#{dsc_user_prefix}_usr_#{dsc_user_suffix}" } - let(:dsc_user_prefix_env_var_name) { 'dsc_user_env_prefix' } - let(:dsc_user_suffix_env_var_name) { 'dsc_user_env_suffix' } + let(:dsc_user_prefix_env_var_name) { "dsc_user_env_prefix" } + let(:dsc_user_suffix_env_var_name) { "dsc_user_env_suffix" } let(:dsc_user_prefix_env_code) { "$env:#{dsc_user_prefix_env_var_name}"} let(:dsc_user_suffix_env_code) { "$env:#{dsc_user_suffix_env_var_name}"} - let(:dsc_user_prefix_param_name) { 'dsc_user_prefix_param' } - let(:dsc_user_suffix_param_name) { 'dsc_user_suffix_param' } + let(:dsc_user_prefix_param_name) { "dsc_user_prefix_param" } + let(:dsc_user_suffix_param_name) { "dsc_user_suffix_param" } let(:dsc_user_prefix_param_code) { "$#{dsc_user_prefix_param_name}"} let(:dsc_user_suffix_param_code) { "$#{dsc_user_suffix_param_name}"} let(:dsc_user_env_code) { "\"$(#{dsc_user_prefix_env_code})_usr_$(#{dsc_user_suffix_env_code})\""} @@ -129,7 +129,7 @@ EOH EOH } - let(:config_param_section) { '' } + let(:config_param_section) { "" } let(:dsc_user_code) { "'#{dsc_user}'" } let(:dsc_user_prefix_code) { dsc_user_prefix } let(:dsc_user_suffix_code) { dsc_user_suffix } @@ -170,10 +170,10 @@ EOH EOH } - let(:dsc_environment_env_var_name) { 'dsc_test_cwd' } + let(:dsc_environment_env_var_name) { "dsc_test_cwd" } let(:dsc_environment_no_fail_not_etc_directory) { "#{ENV['systemroot']}\\system32" } let(:dsc_environment_fail_etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" } - let(:exception_message_signature) { 'LL927-LL928' } + let(:exception_message_signature) { "LL927-LL928" } let(:dsc_environment_config) {<<-EOH if (($pwd.path -eq '#{dsc_environment_fail_etc_directory}') -and (test-path('#{dsc_environment_fail_etc_directory}'))) { @@ -214,19 +214,19 @@ EOH test_key_resource.run_action(:delete_key) end - shared_examples_for 'a dsc_script resource with specified PowerShell configuration code' do + shared_examples_for "a dsc_script resource with specified PowerShell configuration code" do let(:test_registry_data) { test_registry_data1 } - it 'should create a registry key with a specific registry value and data' do + it "should create a registry key with a specific registry value and data" do expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false) dsc_test_resource.run_action(:run) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(true) expect(dsc_test_resource.registry_value_exists?(test_registry_key, {:name => test_registry_value, :type => :string, :data => test_registry_data})).to eq(true) end - it_should_behave_like 'a dsc_script resource with configuration affected by cwd' + it_should_behave_like "a dsc_script resource with configuration affected by cwd" end - shared_examples_for 'a dsc_script resource with configuration affected by cwd' do + shared_examples_for "a dsc_script resource with configuration affected by cwd" do after(:each) do removal_resource = Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context) removal_resource.code <<-EOH @@ -239,14 +239,14 @@ EOH removal_resource.run_action(:run) end - describe 'when the DSC configuration contains code that raises an exception if cwd has a specific value' do + describe "when the DSC configuration contains code that raises an exception if cwd has a specific value" do let(:dsc_code) { dsc_environment_config } - it 'should not raise an exception if the cwd is not etc' do + it "should not raise an exception if the cwd is not etc" do dsc_test_resource.cwd(dsc_environment_no_fail_not_etc_directory) expect {dsc_test_resource.run_action(:run)}.not_to raise_error end - it 'should raise an exception if the cwd is etc' do + it "should raise an exception if the cwd is etc" do dsc_test_resource.cwd(dsc_environment_fail_etc_directory) expect {dsc_test_resource.run_action(:run)}.to raise_error(Chef::Exceptions::PowershellCmdletException) begin @@ -258,14 +258,14 @@ EOH end end - shared_examples_for 'a parameterized DSC configuration script' do + shared_examples_for "a parameterized DSC configuration script" do let(:dsc_user_prefix_code) { dsc_user_prefix_env_code } let(:dsc_user_suffix_code) { dsc_user_suffix_env_code } - it_behaves_like 'a dsc_script with configuration that uses environment variables' + it_behaves_like "a dsc_script with configuration that uses environment variables" end - shared_examples_for 'a dsc_script without configuration data that takes parameters' do - context 'when configuration data is not specified' do + shared_examples_for "a dsc_script without configuration data that takes parameters" do + context "when configuration data is not specified" do before(:each) do test_key_resource = Chef::Resource::RegistryKey.new(test_registry_key, dsc_test_run_context) @@ -282,19 +282,19 @@ EOH let(:test_registry_data) { test_registry_data1 } let(:dsc_parameterized_env_param_value) { "val" + Random::rand.to_s } - it 'should have a default value of nil for the configuration_data attribute' do + it "should have a default value of nil for the configuration_data attribute" do expect(dsc_test_resource.configuration_data).to eql(nil) end - it 'should have a default value of nil for the configuration_data_path attribute' do + it "should have a default value of nil for the configuration_data_path attribute" do expect(dsc_test_resource.configuration_data_script).to eql(nil) end let(:dsc_test_resource) { dsc_resource_from_path } - let(:registry_embedded_parameters) { '' } + let(:registry_embedded_parameters) { "" } let(:dsc_code) { dsc_reg_script } - it 'should set a registry key according to parameters passed to the configuration' do + it "should set a registry key according to parameters passed to the configuration" do dsc_test_resource.configuration_name(config_name_value) dsc_test_resource.flags({:"#{reg_key_name_param_name}" => test_registry_key, :"#{reg_key_value_param_name}" => test_registry_value}) expect(dsc_test_resource.registry_key_exists?(test_registry_key)).to eq(false) @@ -305,20 +305,20 @@ EOH end end - shared_examples_for 'a dsc_script with configuration data' do - let(:configuration_data_attribute) { 'configuration_data' } - it_behaves_like 'a dsc_script with configuration data set via an attribute' + shared_examples_for "a dsc_script with configuration data" do + let(:configuration_data_attribute) { "configuration_data" } + it_behaves_like "a dsc_script with configuration data set via an attribute" - let(:configuration_data_attribute) { 'configuration_data_script' } - it_behaves_like 'a dsc_script with configuration data set via an attribute' + let(:configuration_data_attribute) { "configuration_data_script" } + it_behaves_like "a dsc_script with configuration data set via an attribute" end - shared_examples_for 'a dsc_script with configuration data set via an attribute' do - it 'should run a configuration script that creates a user' do + shared_examples_for "a dsc_script with configuration data set via an attribute" do + it "should run a configuration script that creates a user" do config_data_value = dsc_user_config_data dsc_test_resource.configuration_name(config_name_value) - if configuration_data_attribute == 'configuration_data_script' - config_data_value = create_config_script_from_code(dsc_user_config_data, '', true) + if configuration_data_attribute == "configuration_data_script" + config_data_value = create_config_script_from_code(dsc_user_config_data, "", true) end dsc_test_resource.environment({dsc_user_prefix_env_var_name => dsc_user_prefix, dsc_user_suffix_env_var_name => dsc_user_suffix}) @@ -330,57 +330,57 @@ EOH end end - shared_examples_for 'a dsc_script with configuration data that takes parameters' do + shared_examples_for "a dsc_script with configuration data that takes parameters" do let(:dsc_user_code) { dsc_user_param_code } let(:config_param_section) { config_params } let(:config_flags) {{:"#{dsc_user_prefix_param_name}" => "#{dsc_user_prefix}", :"#{dsc_user_suffix_param_name}" => "#{dsc_user_suffix}"}} - it 'does not directly contain the user name' do + it "does not directly contain the user name" do configuration_script_content = ::File.open(dsc_test_resource.command) do | file | file.read end expect(configuration_script_content.include?(dsc_user)).to be(false) end - it_behaves_like 'a dsc_script with configuration data' + it_behaves_like "a dsc_script with configuration data" end - shared_examples_for 'a dsc_script with configuration data that uses environment variables' do + shared_examples_for "a dsc_script with configuration data that uses environment variables" do let(:dsc_user_code) { dsc_user_env_code } - it 'does not directly contain the user name' do + it "does not directly contain the user name" do configuration_script_content = ::File.open(dsc_test_resource.command) do | file | file.read end expect(configuration_script_content.include?(dsc_user)).to be(false) end - it_behaves_like 'a dsc_script with configuration data' + it_behaves_like "a dsc_script with configuration data" end - context 'when supplying configuration through the configuration attribute' do + context "when supplying configuration through the configuration attribute" do let(:dsc_test_resource) { dsc_resource_from_code } - it_behaves_like 'a dsc_script resource with specified PowerShell configuration code' + it_behaves_like "a dsc_script resource with specified PowerShell configuration code" end - context 'when supplying configuration using the path attribute' do + context "when supplying configuration using the path attribute" do let(:dsc_test_resource) { dsc_resource_from_path } - it_behaves_like 'a dsc_script resource with specified PowerShell configuration code' + it_behaves_like "a dsc_script resource with specified PowerShell configuration code" end - context 'when running a configuration that manages users' do + context "when running a configuration that manages users" do before(:each) do delete_user(dsc_user) end let(:dsc_code) { dsc_user_resources_code } - let(:config_name_value) { 'DSCTestConfig' } + let(:config_name_value) { "DSCTestConfig" } let(:dsc_test_resource) { dsc_resource_from_path } - it_behaves_like 'a dsc_script with configuration data' - it_behaves_like 'a dsc_script with configuration data that uses environment variables' - it_behaves_like 'a dsc_script with configuration data that takes parameters' - it_behaves_like 'a dsc_script without configuration data that takes parameters' + it_behaves_like "a dsc_script with configuration data" + it_behaves_like "a dsc_script with configuration data that uses environment variables" + it_behaves_like "a dsc_script with configuration data that takes parameters" + it_behaves_like "a dsc_script without configuration data that takes parameters" end - context 'when using ps_credential' do + context "when using ps_credential" do include IntegrationSupport before(:each) do @@ -393,7 +393,7 @@ EOH let(:configuration_data_path) { 'C:\\configurationdata.psd1' } let(:self_signed_cert_path) do - File.join(CHEF_SPEC_DATA, 'dsc_lcm.pfx') + File.join(CHEF_SPEC_DATA, "dsc_lcm.pfx") end let(:dsc_configuration_script) do @@ -440,7 +440,7 @@ $ConfigurationData | out-file '#{configuration_data_path}' -force end let(:powershell_script_resource) do - Chef::Resource::PowershellScript.new('configure-lcm', dsc_test_run_context).tap do |r| + Chef::Resource::PowershellScript.new("configure-lcm", dsc_test_run_context).tap do |r| r.code(dsc_configuration_script) r.architecture(:x86_64) end @@ -460,7 +460,7 @@ EOF end end - it 'allows the use of ps_credential' do + it "allows the use of ps_credential" do expect(user_exists?(dsc_user)).to eq(false) powershell_script_resource.run_action(:run) expect(File).to exist(configuration_data_path) diff --git a/spec/functional/resource/env_spec.rb b/spec/functional/resource/env_spec.rb index b9dcd7b33a..60322e91a9 100755 --- a/spec/functional/resource/env_spec.rb +++ b/spec/functional/resource/env_spec.rb @@ -16,27 +16,27 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Env, :windows_only do - context 'when running on Windows' do - let(:chef_env_test_lower_case) { 'chefenvtest' } - let(:chef_env_test_mixed_case) { 'chefENVtest' } - let(:env_dne_key) { 'env_dne_key' } - let(:env_value1) { 'value1' } - let(:env_value2) { 'value2' } - - let(:env_value_expandable) { '%SystemRoot%' } + context "when running on Windows" do + let(:chef_env_test_lower_case) { "chefenvtest" } + let(:chef_env_test_mixed_case) { "chefENVtest" } + let(:env_dne_key) { "env_dne_key" } + let(:env_value1) { "value1" } + let(:env_value2) { "value2" } + + let(:env_value_expandable) { "%SystemRoot%" } let(:test_run_context) { node = Chef::Node.new - node.default['os'] = 'windows' - node.default['platform'] = 'windows' - node.default['platform_version'] = '6.1' + node.default["os"] = "windows" + node.default["platform"] = "windows" + node.default["platform_version"] = "6.1" empty_events = Chef::EventDispatch::Dispatcher.new Chef::RunContext.new(node, {}, empty_events) } let(:test_resource) { - Chef::Resource::Env.new('unknown', test_run_context) + Chef::Resource::Env.new("unknown", test_run_context) } before(:each) do @@ -47,7 +47,7 @@ describe Chef::Resource::Env, :windows_only do end context "when the create action is invoked" do - it 'should create an environment variable for action create' do + it "should create an environment variable for action create" do expect(ENV[chef_env_test_lower_case]).to eq(nil) test_resource.key_name(chef_env_test_lower_case) test_resource.value(env_value1) @@ -76,7 +76,7 @@ describe Chef::Resource::Env, :windows_only do expect(ENV[chef_env_test_lower_case]).to eq(env_value2) end - it 'should not expand environment variables if the variable is not PATH' do + it "should not expand environment variables if the variable is not PATH" do expect(ENV[chef_env_test_lower_case]).to eq(nil) test_resource.key_name(chef_env_test_lower_case) test_resource.value(env_value_expandable) @@ -115,7 +115,7 @@ describe Chef::Resource::Env, :windows_only do expect(ENV[chef_env_test_lower_case]).to eq(env_value2) end - it 'should not expand environment variables if the variable is not PATH' do + it "should not expand environment variables if the variable is not PATH" do test_resource.key_name(chef_env_test_lower_case) test_resource.value(env_value1) test_resource.run_action(:create) @@ -125,27 +125,27 @@ describe Chef::Resource::Env, :windows_only do expect(ENV[chef_env_test_lower_case]).to eq(env_value_expandable) end - context 'when using PATH' do + context "when using PATH" do let(:random_name) { Time.now.to_i } let(:env_val) { "#{env_value_expandable}_#{random_name}"} - let!(:path_before) { test_resource.provider_for_action(test_resource.action).env_value('PATH') || '' } - let!(:env_path_before) { ENV['PATH'] } + let!(:path_before) { test_resource.provider_for_action(test_resource.action).env_value("PATH") || "" } + let!(:env_path_before) { ENV["PATH"] } - it 'should expand PATH' do + it "should expand PATH" do expect(path_before).not_to include(env_val) - test_resource.key_name('PATH') + test_resource.key_name("PATH") test_resource.value("#{path_before};#{env_val}") test_resource.run_action(:create) - expect(ENV['PATH']).not_to include(env_val) - expect(ENV['PATH']).to include("#{random_name}") + expect(ENV["PATH"]).not_to include(env_val) + expect(ENV["PATH"]).to include("#{random_name}") end after(:each) do # cleanup so we don't flood the path - test_resource.key_name('PATH') + test_resource.key_name("PATH") test_resource.value(path_before) test_resource.run_action(:create) - ENV['PATH'] = env_path_before + ENV["PATH"] = env_path_before end end diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb index 9369a8050d..74daf75b08 100644 --- a/spec/functional/resource/execute_spec.rb +++ b/spec/functional/resource/execute_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' -require 'timeout' +require "spec_helper" +require "functional/resource/base" +require "timeout" describe Chef::Resource::Execute do let(:resource) { @@ -106,7 +106,7 @@ describe Chef::Resource::Execute do it "guard adds additional values in its :environment and runs" do resource.only_if %{ruby -e 'exit 1 if ENV["SGCE_SECRET"] != "regularsecret"'}, { - :environment => { 'SGCE_SECRET' => "regularsecret" } + :environment => { "SGCE_SECRET" => "regularsecret" } } resource.run_action(:run) expect(resource).to be_updated_by_last_action @@ -114,7 +114,7 @@ describe Chef::Resource::Execute do it "guard adds additional values in its :environment and does not run" do resource.only_if %{ruby -e 'exit 1 if ENV["SGCE_SECRET"] == "regularsecret"'}, { - :environment => { 'SGCE_SECRET' => "regularsecret" } + :environment => { "SGCE_SECRET" => "regularsecret" } } resource.run_action(:run) expect(resource).not_to be_updated_by_last_action @@ -122,7 +122,7 @@ describe Chef::Resource::Execute do it "guard overwrites value with its :environment and runs" do resource.only_if %{ruby -e 'exit 1 if ENV["SAWS_SECRET"] != "regularsecret"'}, { - :environment => { 'SAWS_SECRET' => "regularsecret" } + :environment => { "SAWS_SECRET" => "regularsecret" } } resource.run_action(:run) expect(resource).to be_updated_by_last_action @@ -130,7 +130,7 @@ describe Chef::Resource::Execute do it "guard overwrites value with its :environment and does not runs" do resource.only_if %{ruby -e 'exit 1 if ENV["SAWS_SECRET"] == "regularsecret"'}, { - :environment => { 'SAWS_SECRET' => "regularsecret" } + :environment => { "SAWS_SECRET" => "regularsecret" } } resource.run_action(:run) expect(resource).not_to be_updated_by_last_action diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb index 861bc65363..7ddd487e2a 100644 --- a/spec/functional/resource/file_spec.rb +++ b/spec/functional/resource/file_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tmpdir' +require "spec_helper" +require "tmpdir" describe Chef::Resource::File do include_context Chef::Resource::File @@ -102,9 +102,9 @@ describe Chef::Resource::File do end it "only stores the number of requested backups" do - resource_without_content.content('foo') + resource_without_content.content("foo") resource_without_content.run_action(:create) - resource_without_content.content('bar') + resource_without_content.content("bar") resource_without_content.run_action(:create) expect(Dir.glob(backup_glob).length).to eq(1) end diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb index 9d3b82f19e..35da2506e5 100644 --- a/spec/functional/resource/git_spec.rb +++ b/spec/functional/resource/git_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/shell_out' -require 'tmpdir' -require 'shellwords' +require "spec_helper" +require "chef/mixin/shell_out" +require "tmpdir" +require "shellwords" # Deploy relies heavily on symlinks, so it doesn't work on windows. describe Chef::Resource::Git do @@ -129,10 +129,10 @@ E it "checks out the revision pointed to by the tag commit, not the tag commit itself" do basic_git_resource.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(v1_commit) # also verify the tag commit itself is what we expect as an extra sanity check - rev = shell_out!('git rev-parse v1.0.0', :cwd => deploy_directory, :returns => [0]).stdout.strip + rev = shell_out!("git rev-parse v1.0.0", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(rev).to eq(v1_tag) end @@ -140,7 +140,7 @@ E # this used to fail because we didn't resolve the annotated tag # properly to the pointed to commit. basic_git_resource.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(v1_commit) copy_git_resource.run_action(:sync) @@ -166,14 +166,14 @@ E it "checks out the expected revision ed18" do basic_git_resource.revision rev_foo basic_git_resource.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(rev_foo) end it "doesn't update if up-to-date" do basic_git_resource.revision rev_foo basic_git_resource.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(rev_foo) copy_git_resource.revision rev_foo @@ -184,7 +184,7 @@ E it "checks out the expected revision 972d" do basic_git_resource.revision rev_testing basic_git_resource.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(rev_testing) end end @@ -193,13 +193,13 @@ E let(:basic_git_resource) do Chef::Resource::Git.new(deploy_directory, run_context).tap do |r| r.repository origin_repo - r.revision 'HEAD' + r.revision "HEAD" end end it "checks out the expected revision" do basic_git_resource.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(rev_head) end end @@ -214,7 +214,7 @@ E it "checks out HEAD as the default revision" do basic_git_resource.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', :cwd => deploy_directory, :returns => [0]).stdout.strip + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(rev_head) end end @@ -228,7 +228,7 @@ E let(:basic_git_resource) do Chef::Resource::Git.new(deploy_directory, run_context).tap do |r| r.repository origin_repo - r.revision 'HEAD' + r.revision "HEAD" end end @@ -241,7 +241,7 @@ E it "checks out the (master) HEAD revision and ignores the tag" do basic_git_resource.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(rev_head) @@ -249,7 +249,7 @@ E it "checks out the (master) HEAD revision when no revision is specified (ignores tag)" do git_resource_default_rev.run_action(:sync) - head_rev = shell_out!('git rev-parse HEAD', + head_rev = shell_out!("git rev-parse HEAD", :cwd => deploy_directory, :returns => [0]).stdout.strip expect(head_rev).to eq(rev_head) diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb index 0862b8e15f..418dad431d 100644 --- a/spec/functional/resource/group_spec.rb +++ b/spec/functional/resource/group_spec.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' -require 'chef/mixin/shell_out' +require "spec_helper" +require "functional/resource/base" +require "chef/mixin/shell_out" # Chef::Resource::Group are turned off on Mac OS X 10.6 due to caching # issues around Etc.getgrnam() not picking up the group membership @@ -79,8 +79,8 @@ describe Chef::Resource::Group, :requires_root_or_running_windows, :not_supporte def windows_domain_user?(user_name) domain, user = user_name.split('\\') - if user && domain != '.' - computer_name = ENV['computername'] + if user && domain != "." + computer_name = ENV["computername"] domain.downcase != computer_name.downcase end end @@ -378,7 +378,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" } describe "when running on Windows", :windows_only do describe "when members are Active Directory domain identities", :windows_domain_joined_only do - let(:computer_domain) { ohai[:kernel]['cs_info']['domain'].split('.')[0] } + let(:computer_domain) { ohai[:kernel]["cs_info"]["domain"].split(".")[0] } let(:spec_members){ ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] } include_examples "correct group management" @@ -415,7 +415,7 @@ downthestreetalwayshadagoodsmileonhisfacetheoldmanwalkingdownthestreeQQQQQQ" } describe "running on windows", :windows_only do describe "when members are Windows domain identities", :windows_domain_joined_only do - let(:computer_domain) { ohai[:kernel]['cs_info']['domain'].split('.')[0] } + let(:computer_domain) { ohai[:kernel]["cs_info"]["domain"].split(".")[0] } let(:spec_members){ ["#{computer_domain}\\Domain Admins", "#{computer_domain}\\Domain Users", "#{computer_domain}\\Domain Computers"] } include_examples "correct group management" diff --git a/spec/functional/resource/ifconfig_spec.rb b/spec/functional/resource/ifconfig_spec.rb index 4733b05f35..6b40fbc2e2 100644 --- a/spec/functional/resource/ifconfig_spec.rb +++ b/spec/functional/resource/ifconfig_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'functional/resource/base' -require 'chef/mixin/shell_out' +require "functional/resource/base" +require "chef/mixin/shell_out" # run this test only for following platforms. -include_flag = !(['ubuntu', 'centos', 'aix'].include?(ohai[:platform])) +include_flag = !(["ubuntu", "centos", "aix"].include?(ohai[:platform])) describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => include_flag do # This test does not work in travis because there is no eth0 @@ -28,7 +28,7 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in include Chef::Mixin::ShellOut let(:new_resource) do - new_resource = Chef::Resource::Ifconfig.new('10.10.0.1', run_context) + new_resource = Chef::Resource::Ifconfig.new("10.10.0.1", run_context) new_resource end @@ -45,9 +45,9 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in # use loopback interface for tests case ohai[:platform] when "aix" - 'lo0' + "lo0" else - 'lo' + "lo" end end @@ -55,9 +55,9 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in def en0_interface_for_test case ohai[:platform] when "aix" - 'en0' + "en0" else - 'eth0' + "eth0" end end @@ -107,14 +107,14 @@ describe Chef::Resource::Ifconfig, :requires_root, :skip_travis, :external => in # Actual tests describe "#load_current_resource" do - it 'should load given interface' do + it "should load given interface" do new_resource.device lo_interface_for_test expect(current_resource.device).to eql(lo_interface_for_test) expect(current_resource.inet_addr).to match(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/) end end - exclude_test = ohai[:platform] != 'ubuntu' + exclude_test = ohai[:platform] != "ubuntu" describe "#action_add", :external => exclude_test do after do new_resource.run_action(:delete) diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb index 6b214f0b16..4840713667 100644 --- a/spec/functional/resource/link_spec.rb +++ b/spec/functional/resource/link_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" if windows? - require 'chef/win32/file' #probably need this in spec_helper + require "chef/win32/file" #probably need this in spec_helper end describe Chef::Resource::Link do @@ -31,7 +31,7 @@ describe Chef::Resource::Link do # different file deployment strategies more completely. let(:test_file_dir) do if windows? - File.join(ENV['systemdrive'], "test-dir") + File.join(ENV["systemdrive"], "test-dir") else File.join(CHEF_SPEC_DATA, "test-dir") end @@ -73,7 +73,7 @@ describe Chef::Resource::Link do end def canonicalize(path) - windows? ? path.gsub('/', '\\') : path + windows? ? path.gsub("/", '\\') : path end def symlink(a, b) @@ -121,142 +121,142 @@ describe Chef::Resource::Link do end describe "when supported on platform", :not_supported_on_win2k3 do - shared_examples_for 'delete errors out' do - it 'delete errors out' do + shared_examples_for "delete errors out" do + it "delete errors out" do expect { resource.run_action(:delete) }.to raise_error(Chef::Exceptions::Link) expect(File.exist?(target_file) || symlink?(target_file)).to be_truthy end end - shared_context 'delete is noop' do - describe 'the :delete action' do + shared_context "delete is noop" do + describe "the :delete action" do before(:each) do @info = [] allow(Chef::Log).to receive(:info) { |msg| @info << msg } resource.run_action(:delete) end - it 'leaves the file deleted' do + it "leaves the file deleted" do expect(File.exist?(target_file)).to be_falsey expect(symlink?(target_file)).to be_falsey end - it 'does not mark the resource updated' do + it "does not mark the resource updated" do expect(resource).not_to be_updated end - it 'does not log that it deleted' do + it "does not log that it deleted" do expect(@info.include?("link[#{target_file}] deleted")).to be_falsey end end end - shared_context 'delete succeeds' do - describe 'the :delete action' do + shared_context "delete succeeds" do + describe "the :delete action" do before(:each) do @info = [] allow(Chef::Log).to receive(:info) { |msg| @info << msg } resource.run_action(:delete) end - it 'deletes the file' do + it "deletes the file" do expect(File.exist?(target_file)).to be_falsey expect(symlink?(target_file)).to be_falsey end - it 'marks the resource updated' do + it "marks the resource updated" do expect(resource).to be_updated end - it 'logs that it deleted' do + it "logs that it deleted" do expect(@info.include?("link[#{target_file}] deleted")).to be_truthy end end end - shared_context 'create symbolic link succeeds' do - describe 'the :create action' do + shared_context "create symbolic link succeeds" do + describe "the :create action" do before(:each) do @info = [] allow(Chef::Log).to receive(:info) { |msg| @info << msg } resource.run_action(:create) end - it 'links to the target file' do + it "links to the target file" do expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(to)) end - it 'marks the resource updated' do + it "marks the resource updated" do expect(resource).to be_updated end - it 'logs that it created' do + it "logs that it created" do expect(@info.include?("link[#{target_file}] created")).to be_truthy end end end - shared_context 'create symbolic link is noop' do - describe 'the :create action' do + shared_context "create symbolic link is noop" do + describe "the :create action" do before(:each) do @info = [] allow(Chef::Log).to receive(:info) { |msg| @info << msg } resource.run_action(:create) end - it 'leaves the file linked' do + it "leaves the file linked" do expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(to)) end - it 'does not mark the resource updated' do + it "does not mark the resource updated" do expect(resource).not_to be_updated end - it 'does not log that it created' do + it "does not log that it created" do expect(@info.include?("link[#{target_file}] created")).to be_falsey end end end - shared_context 'create hard link succeeds' do - describe 'the :create action' do + shared_context "create hard link succeeds" do + describe "the :create action" do before(:each) do @info = [] allow(Chef::Log).to receive(:info) { |msg| @info << msg } resource.run_action(:create) end - it 'preserves the hard link' do + it "preserves the hard link" do expect(File.exists?(target_file)).to be_truthy expect(symlink?(target_file)).to be_falsey # Writing to one hardlinked file should cause both # to have the new value. expect(IO.read(to)).to eq(IO.read(target_file)) - File.open(to, "w") { |file| file.write('wowzers') } - expect(IO.read(target_file)).to eq('wowzers') + File.open(to, "w") { |file| file.write("wowzers") } + expect(IO.read(target_file)).to eq("wowzers") end - it 'marks the resource updated' do + it "marks the resource updated" do expect(resource).to be_updated end - it 'logs that it created' do + it "logs that it created" do expect(@info.include?("link[#{target_file}] created")).to be_truthy end end end - shared_context 'create hard link is noop' do - describe 'the :create action' do + shared_context "create hard link is noop" do + describe "the :create action" do before(:each) do @info = [] allow(Chef::Log).to receive(:info) { |msg| @info << msg } resource.run_action(:create) end - it 'links to the target file' do + it "links to the target file" do expect(File.exists?(target_file)).to be_truthy expect(symlink?(target_file)).to be_falsey # Writing to one hardlinked file should cause both # to have the new value. expect(IO.read(to)).to eq(IO.read(target_file)) - File.open(to, "w") { |file| file.write('wowzers') } - expect(IO.read(target_file)).to eq('wowzers') + File.open(to, "w") { |file| file.write("wowzers") } + expect(IO.read(target_file)).to eq("wowzers") end - it 'does not mark the resource updated' do + it "does not mark the resource updated" do expect(resource).not_to be_updated end - it 'does not log that it created' do + it "does not log that it created" do expect(@info.include?("link[#{target_file}] created")).to be_falsey end end @@ -264,34 +264,34 @@ describe Chef::Resource::Link do context "is symbolic" do - context 'when the link destination is a file' do + context "when the link destination is a file" do before(:each) do File.open(to, "w") do |file| - file.write('woohoo') + file.write("woohoo") end end - context 'and the link does not yet exist' do - include_context 'create symbolic link succeeds' - include_context 'delete is noop' + context "and the link does not yet exist" do + include_context "create symbolic link succeeds" + include_context "delete is noop" end - context 'and the link already exists and is a symbolic link' do - context 'pointing at the target' do + context "and the link already exists and is a symbolic link" do + context "pointing at the target" do before(:each) do symlink(to, target_file) expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(to)) end - include_context 'create symbolic link is noop' - include_context 'delete succeeds' - it 'the :delete action does not delete the target file' do + include_context "create symbolic link is noop" + include_context "delete succeeds" + it "the :delete action does not delete the target file" do resource.run_action(:delete) expect(File.exists?(to)).to be_truthy end end - context 'pointing somewhere else' do + context "pointing somewhere else" do before(:each) do - @other_target = File.join(test_file_dir, make_tmpname('other_spec')) - File.open(@other_target, 'w') { |file| file.write('eek') } + @other_target = File.join(test_file_dir, make_tmpname("other_spec")) + File.open(@other_target, "w") { |file| file.write("eek") } symlink(@other_target, target_file) expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(@other_target)) @@ -299,45 +299,45 @@ describe Chef::Resource::Link do after(:each) do File.delete(@other_target) end - include_context 'create symbolic link succeeds' - include_context 'delete succeeds' - it 'the :delete action does not delete the target file' do + include_context "create symbolic link succeeds" + include_context "delete succeeds" + it "the :delete action does not delete the target file" do resource.run_action(:delete) expect(File.exists?(to)).to be_truthy end end - context 'pointing nowhere' do + context "pointing nowhere" do before(:each) do - nonexistent = File.join(test_file_dir, make_tmpname('nonexistent_spec')) + nonexistent = File.join(test_file_dir, make_tmpname("nonexistent_spec")) symlink(nonexistent, target_file) expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(nonexistent)) end - include_context 'create symbolic link succeeds' - include_context 'delete succeeds' + include_context "create symbolic link succeeds" + include_context "delete succeeds" end end - context 'and the link already exists and is a hard link to the file' do + context "and the link already exists and is a hard link to the file" do before(:each) do link(to, target_file) expect(File.exists?(target_file)).to be_truthy expect(symlink?(target_file)).to be_falsey end - include_context 'create symbolic link succeeds' - it_behaves_like 'delete errors out' + include_context "create symbolic link succeeds" + it_behaves_like "delete errors out" end - context 'and the link already exists and is a file' do + context "and the link already exists and is a file" do before(:each) do - File.open(target_file, 'w') { |file| file.write('eek') } + File.open(target_file, "w") { |file| file.write("eek") } end - include_context 'create symbolic link succeeds' - it_behaves_like 'delete errors out' + include_context "create symbolic link succeeds" + it_behaves_like "delete errors out" end - context 'and the link already exists and is a directory' do + context "and the link already exists and is a directory" do before(:each) do Dir.mkdir(target_file) end - it 'create errors out' do + it "create errors out" do if windows? expect { resource.run_action(:create) }.to raise_error(Errno::EACCES) elsif os_x? or solaris? or freebsd? or aix? @@ -346,10 +346,10 @@ describe Chef::Resource::Link do expect { resource.run_action(:create) }.to raise_error(Errno::EISDIR) end end - it_behaves_like 'delete errors out' + it_behaves_like "delete errors out" end - it_behaves_like 'a securable resource without existing target' do + it_behaves_like "a securable resource without existing target" do let(:path) { target_file } def allowed_acl(sid, expected_perms) [ ACE.access_allowed(sid, expected_perms[:specific]) ] @@ -366,27 +366,27 @@ describe Chef::Resource::Link do end end end - context 'when the link destination is a directory' do + context "when the link destination is a directory" do before(:each) do Dir.mkdir(to) end # On Windows, readlink fails to open the link. FILE_FLAG_OPEN_REPARSE_POINT # might help, from http://msdn.microsoft.com/en-us/library/windows/desktop/aa363858(v=vs.85).aspx - context 'and the link does not yet exist' do - include_context 'create symbolic link succeeds' - include_context 'delete is noop' + context "and the link does not yet exist" do + include_context "create symbolic link succeeds" + include_context "delete is noop" end - context 'and the link already exists and points to a different directory' do + context "and the link already exists and points to a different directory" do before(:each) do other_dir = File.join(test_file_dir, make_tmpname("other_dir")) Dir.mkdir(other_dir) symlink(other_dir, target_file) end - include_context 'create symbolic link succeeds' + include_context "create symbolic link succeeds" end end context "when the link destination is a symbolic link" do - context 'to a file that exists' do + context "to a file that exists" do before(:each) do @other_target = File.join(test_file_dir, make_tmpname("other_spec")) File.open(@other_target, "w") { |file| file.write("eek") } @@ -397,32 +397,32 @@ describe Chef::Resource::Link do after(:each) do File.delete(@other_target) end - context 'and the link does not yet exist' do - include_context 'create symbolic link succeeds' - include_context 'delete is noop' + context "and the link does not yet exist" do + include_context "create symbolic link succeeds" + include_context "delete is noop" end end - context 'to a file that does not exist' do + context "to a file that does not exist" do before(:each) do @other_target = File.join(test_file_dir, make_tmpname("other_spec")) symlink(@other_target, to) expect(symlink?(to)).to be_truthy expect(readlink(to)).to eq(canonicalize(@other_target)) end - context 'and the link does not yet exist' do - include_context 'create symbolic link succeeds' - include_context 'delete is noop' + context "and the link does not yet exist" do + include_context "create symbolic link succeeds" + include_context "delete is noop" end end end context "when the link destination does not exist" do - include_context 'create symbolic link succeeds' - include_context 'delete is noop' + include_context "create symbolic link succeeds" + include_context "delete is noop" end { - '../' => 'with a relative link destination', - '' => 'with a bare filename for the link destination', + "../" => "with a relative link destination", + "" => "with a bare filename for the link destination", }.each do |prefix, desc| context desc do let(:to) { "#{prefix}#{File.basename(absolute_to)}" } @@ -430,27 +430,27 @@ describe Chef::Resource::Link do before(:each) do resource.to(to) end - context 'when the link does not yet exist' do - include_context 'create symbolic link succeeds' - include_context 'delete is noop' + context "when the link does not yet exist" do + include_context "create symbolic link succeeds" + include_context "delete is noop" end - context 'when the link already exists and points at the target' do + context "when the link already exists and points at the target" do before(:each) do symlink(to, target_file) expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(to)) end - include_context 'create symbolic link is noop' - include_context 'delete succeeds' + include_context "create symbolic link is noop" + include_context "delete succeeds" end - context 'when the link already exists and points at the target with an absolute path' do + context "when the link already exists and points at the target with an absolute path" do before(:each) do symlink(absolute_to, target_file) expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(absolute_to)) end - include_context 'create symbolic link succeeds' - include_context 'delete succeeds' + include_context "create symbolic link succeeds" + include_context "delete succeeds" end end end @@ -464,12 +464,12 @@ describe Chef::Resource::Link do context "when the link destination is a file" do before(:each) do File.open(to, "w") do |file| - file.write('woohoo') + file.write("woohoo") end end context "and the link does not yet exist" do - include_context 'create hard link succeeds' - include_context 'delete is noop' + include_context "create hard link succeeds" + include_context "delete is noop" end context "and the link already exists and is a symbolic link pointing at the same file" do before(:each) do @@ -477,34 +477,34 @@ describe Chef::Resource::Link do expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(to)) end - include_context 'create hard link succeeds' - it_behaves_like 'delete errors out' + include_context "create hard link succeeds" + it_behaves_like "delete errors out" end - context 'and the link already exists and is a hard link to the file' do + context "and the link already exists and is a hard link to the file" do before(:each) do link(to, target_file) expect(File.exists?(target_file)).to be_truthy expect(symlink?(target_file)).to be_falsey end - include_context 'create hard link is noop' - include_context 'delete succeeds' - it 'the :delete action does not delete the target file' do + include_context "create hard link is noop" + include_context "delete succeeds" + it "the :delete action does not delete the target file" do resource.run_action(:delete) expect(File.exists?(to)).to be_truthy end end context "and the link already exists and is a file" do before(:each) do - File.open(target_file, 'w') { |file| file.write('tomfoolery') } + File.open(target_file, "w") { |file| file.write("tomfoolery") } end - include_context 'create hard link succeeds' - it_behaves_like 'delete errors out' + include_context "create hard link succeeds" + it_behaves_like "delete errors out" end context "and the link already exists and is a directory" do before(:each) do Dir.mkdir(target_file) end - it 'errors out' do + it "errors out" do if windows? expect { resource.run_action(:create) }.to raise_error(Errno::EACCES) elsif os_x? or solaris? or freebsd? or aix? @@ -513,18 +513,18 @@ describe Chef::Resource::Link do expect { resource.run_action(:create) }.to raise_error(Errno::EISDIR) end end - it_behaves_like 'delete errors out' + it_behaves_like "delete errors out" end context "and specifies security attributes" do before(:each) do - resource.owner(windows? ? 'Guest' : 'nobody') + resource.owner(windows? ? "Guest" : "nobody") end - it 'ignores them' do + it "ignores them" do resource.run_action(:create) if windows? expect(Chef::ReservedNames::Win32::Security.get_named_security_info(target_file).owner).not_to eq(SID.Guest) else - expect(File.lstat(target_file).uid).not_to eq(Etc.getpwnam('nobody').uid) + expect(File.lstat(target_file).uid).not_to eq(Etc.getpwnam("nobody").uid) end end end @@ -533,15 +533,15 @@ describe Chef::Resource::Link do before(:each) do Dir.mkdir(to) end - context 'and the link does not yet exist' do - it 'create errors out' do + context "and the link does not yet exist" do + it "create errors out" do expect { resource.run_action(:create) }.to raise_error(windows? ? Chef::Exceptions::Win32APIError : Errno::EPERM) end - include_context 'delete is noop' + include_context "delete is noop" end end context "when the link destination is a symbolic link" do - context 'to a real file' do + context "to a real file" do before(:each) do @other_target = File.join(test_file_dir, make_tmpname("other_spec")) File.open(@other_target, "w") { |file| file.write("eek") } @@ -552,28 +552,28 @@ describe Chef::Resource::Link do after(:each) do File.delete(@other_target) end - context 'and the link does not yet exist' do - it 'links to the target file' do - skip('OS X/FreeBSD/AIX symlink? and readlink working on hard links to symlinks') if (os_x? or freebsd? or aix?) + context "and the link does not yet exist" do + it "links to the target file" do + skip("OS X/FreeBSD/AIX symlink? and readlink working on hard links to symlinks") if (os_x? or freebsd? or aix?) resource.run_action(:create) expect(File.exists?(target_file)).to be_truthy # OS X gets angry about this sort of link. Bug in OS X, IMO. expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(@other_target)) end - include_context 'delete is noop' + include_context "delete is noop" end end - context 'to a nonexistent file' do + context "to a nonexistent file" do before(:each) do @other_target = File.join(test_file_dir, make_tmpname("other_spec")) symlink(@other_target, to) expect(symlink?(to)).to be_truthy expect(readlink(to)).to eq(canonicalize(@other_target)) end - context 'and the link does not yet exist' do - it 'links to the target file' do - skip('OS X/FreeBSD/AIX fails to create hardlinks to broken symlinks') if (os_x? or freebsd? or aix?) + context "and the link does not yet exist" do + it "links to the target file" do + skip("OS X/FreeBSD/AIX fails to create hardlinks to broken symlinks") if (os_x? or freebsd? or aix?) resource.run_action(:create) # Windows and Unix have different definitions of exists? here, and that's OK. if windows? @@ -584,17 +584,17 @@ describe Chef::Resource::Link do expect(symlink?(target_file)).to be_truthy expect(readlink(target_file)).to eq(canonicalize(@other_target)) end - include_context 'delete is noop' + include_context "delete is noop" end end end context "when the link destination does not exist" do - context 'and the link does not yet exist' do - it 'create errors out' do + context "and the link does not yet exist" do + it "create errors out" do expect { resource.run_action(:create) }.to raise_error(Errno::ENOENT) end - include_context 'delete is noop' + include_context "delete is noop" end end end diff --git a/spec/functional/resource/mount_spec.rb b/spec/functional/resource/mount_spec.rb index 4e9e8c3bdc..7f919439c9 100644 --- a/spec/functional/resource/mount_spec.rb +++ b/spec/functional/resource/mount_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' -require 'chef/mixin/shell_out' -require 'tmpdir' +require "spec_helper" +require "functional/resource/base" +require "chef/mixin/shell_out" +require "tmpdir" # run this test only for following platforms. -include_flag = !(['ubuntu', 'centos', 'aix', 'solaris2'].include?(ohai[:platform])) +include_flag = !(["ubuntu", "centos", "aix", "solaris2"].include?(ohai[:platform])) describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => include_flag do # Disabled in travis because it refuses to let us mount a ramdisk. /dev/ramX does not @@ -79,9 +79,9 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => inclu def unix_mount_config_file case ohai[:platform] - when 'aix' + when "aix" mount_config = "/etc/filesystems" - when 'solaris2' + when "solaris2" mount_config = "/etc/vfstab" else mount_config = "/etc/fstab" @@ -90,7 +90,7 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => inclu def mount_should_be_enabled(mount_point, device) case ohai[:platform] - when 'aix' + when "aix" expect(shell_out("cat #{unix_mount_config_file} | grep \"#{mount_point}:\" ").exitstatus).to eq(0) else expect(shell_out("cat #{unix_mount_config_file} | grep \"#{mount_point}\" | grep \"#{device}\" ").exitstatus).to eq(0) @@ -106,7 +106,7 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => inclu new_resource.device @device new_resource.name @mount_point new_resource.fstype @fstype - new_resource.options "log=NULL" if ohai[:platform] == 'aix' + new_resource.options "log=NULL" if ohai[:platform] == "aix" new_resource end @@ -163,10 +163,10 @@ describe Chef::Resource::Mount, :requires_root, :skip_travis, :external => inclu mount_should_exist(new_resource.mount_point, new_resource.device) new_resource.supports[:remount] = true - new_resource.options "rw" if ohai[:platform] == 'aix' + new_resource.options "rw" if ohai[:platform] == "aix" new_resource.run_action(:remount) - mount_should_exist(new_resource.mount_point, new_resource.device, nil, (ohai[:platform] == 'aix') ? new_resource.options : nil) + mount_should_exist(new_resource.mount_point, new_resource.device, nil, (ohai[:platform] == "aix") ? new_resource.options : nil) end end diff --git a/spec/functional/resource/ohai_spec.rb b/spec/functional/resource/ohai_spec.rb index da47b9e140..8b93f22613 100644 --- a/spec/functional/resource/ohai_spec.rb +++ b/spec/functional/resource/ohai_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Ohai do let(:ohai) { diff --git a/spec/functional/resource/package_spec.rb b/spec/functional/resource/package_spec.rb index 00120afc29..459e21586e 100644 --- a/spec/functional/resource/package_spec.rb +++ b/spec/functional/resource/package_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'webrick' +require "spec_helper" +require "webrick" module AptServer def enable_testing_apt_source @@ -239,7 +239,7 @@ describe Chef::Resource::Package, metadata do it "does not update the package configuration" do package_resource.run_action(:install) cmd = shell_out!("debconf-show chef-integration-test") - expect(cmd.stdout).to include('chef-integration-test/sample-var: INVALID') + expect(cmd.stdout).to include("chef-integration-test/sample-var: INVALID") expect(package_resource).to be_updated_by_last_action end @@ -276,7 +276,7 @@ describe Chef::Resource::Package, metadata do r = base_resource r.cookbook_name = "preseed" r.response_file("preseed-template-variables.seed") - r.response_file_variables({ :template_variable => 'SUPPORTS VARIABLES' }) + r.response_file_variables({ :template_variable => "SUPPORTS VARIABLES" }) r end diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb index d7e5b9888b..ac4660e1cc 100644 --- a/spec/functional/resource/powershell_script_spec.rb +++ b/spec/functional/resource/powershell_script_spec.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'chef/platform/query_helpers' -require 'spec_helper' +require "chef/platform/query_helpers" +require "spec_helper" describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do include_context Chef::Resource::WindowsScript - let (:architecture_command) { 'echo $env:PROCESSOR_ARCHITECTURE' } - let (:output_command) { ' | out-file -encoding ASCII ' } + let (:architecture_command) { "echo $env:PROCESSOR_ARCHITECTURE" } + let (:output_command) { " | out-file -encoding ASCII " } it_behaves_like "a Windows script running on Windows" @@ -59,7 +59,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it "returns the exit status 27 for a powershell script that exits with 27" do pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server? - file = Tempfile.new(['foo', '.ps1']) + file = Tempfile.new(["foo", ".ps1"]) begin file.write "exit 27" file.close @@ -79,7 +79,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do # Versions of PowerShell prior to 4.0 return a 16-bit unsigned value -- # PowerShell 4.0 and later versions return a 32-bit signed value. - file = Tempfile.new(['foo', '.ps1']) + file = Tempfile.new(["foo", ".ps1"]) begin file.write "exit #{negative_exit_status}" file.close @@ -114,7 +114,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do end it "returns 0 if the last command was a cmdlet that succeeded and was preceded by a non-cmdlet Windows binary that failed" do - resource.code([windows_process_exit_code_not_found_content, cmdlet_exit_code_success_content].join(';')) + resource.code([windows_process_exit_code_not_found_content, cmdlet_exit_code_success_content].join(";")) resource.returns(0) resource.run_action(:run) end @@ -130,7 +130,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it "returns 1 if the last command was a cmdlet that failed and was preceded by a successfully executed non-cmdlet Windows binary" do pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server? - resource.code([windows_process_exit_code_success_content, cmdlet_exit_code_not_found_content].join(';')) + resource.code([windows_process_exit_code_success_content, cmdlet_exit_code_not_found_content].join(";")) resource.returns(1) expect { resource.run_action(:run) }.not_to raise_error end @@ -138,7 +138,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it "raises a Mixlib::ShellOut::ShellCommandFailed error if the script is not syntactically correct" do pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server? - resource.code('if({)') + resource.code("if({)") resource.returns(0) expect { resource.run_action(:run) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) end @@ -148,7 +148,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do # The error is a false-positive. skip "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server? - resource.code('if({)') + resource.code("if({)") resource.returns(1) expect { resource.run_action(:run) }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) end @@ -164,7 +164,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it "returns 1 if the last command was a cmdlet that failed and was preceded by an unsuccessfully executed non-cmdlet Windows binary" do pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server? - resource.code([arbitrary_nonzero_process_exit_code_content,cmdlet_exit_code_not_found_content].join(';')) + resource.code([arbitrary_nonzero_process_exit_code_content,cmdlet_exit_code_not_found_content].join(";")) resource.returns(arbitrary_nonzero_process_exit_code) resource.run_action(:run) end @@ -172,7 +172,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it "returns 0 if the last command was a non-cmdlet Windows binary that succeeded and was preceded by a failed cmdlet" do pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server? - resource.code([cmdlet_exit_code_success_content, arbitrary_nonzero_process_exit_code_content].join(';')) + resource.code([cmdlet_exit_code_success_content, arbitrary_nonzero_process_exit_code_content].join(";")) resource.returns(arbitrary_nonzero_process_exit_code) resource.run_action(:run) end @@ -180,7 +180,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it "returns a specific error code if the last command was a non-cmdlet Windows binary that failed and was preceded by cmdlet that succeeded" do pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server? - resource.code([cmdlet_exit_code_success_content, arbitrary_nonzero_process_exit_code_content].join(';')) + resource.code([cmdlet_exit_code_success_content, arbitrary_nonzero_process_exit_code_content].join(";")) resource.returns(arbitrary_nonzero_process_exit_code) resource.run_action(:run) end @@ -188,7 +188,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it "returns a specific error code if the last command was a non-cmdlet Windows binary that failed and was preceded by cmdlet that failed" do pending "powershell.exe always exits with 0 on nano" if Chef::Platform.windows_nano_server? - resource.code([cmdlet_exit_code_not_found_content, arbitrary_nonzero_process_exit_code_content].join(';')) + resource.code([cmdlet_exit_code_not_found_content, arbitrary_nonzero_process_exit_code_content].join(";")) resource.returns(arbitrary_nonzero_process_exit_code) resource.run_action(:run) end @@ -226,9 +226,9 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do resource.returns(0) resource.run_action(:run) - is_64_bit = (ENV['PROCESSOR_ARCHITECTURE'] == 'AMD64') || (ENV['PROCESSOR_ARCHITEW6432'] == 'AMD64') + is_64_bit = (ENV["PROCESSOR_ARCHITECTURE"] == "AMD64") || (ENV["PROCESSOR_ARCHITEW6432"] == "AMD64") - detected_64_bit = source_contains_case_insensitive_content?( get_script_output, 'AMD64' ) + detected_64_bit = source_contains_case_insensitive_content?( get_script_output, "AMD64" ) expect(is_64_bit).to eq(detected_64_bit) end @@ -280,7 +280,7 @@ configuration LCM resource.returns(0) resource.run_action(:run) - expect(source_contains_case_insensitive_content?( get_script_output, 'x86' )).to eq(true) + expect(source_contains_case_insensitive_content?( get_script_output, "x86" )).to eq(true) end context "when running on a 64-bit version of Windows", :windows64_only do @@ -290,7 +290,7 @@ configuration LCM resource.returns(0) resource.run_action(:run) - expect(source_contains_case_insensitive_content?( get_script_output, 'AMD64' )).to eq(true) + expect(source_contains_case_insensitive_content?( get_script_output, "AMD64" )).to eq(true) end end @@ -311,7 +311,7 @@ configuration LCM resource.returns(0) resource.run_action(:run) - expect(source_contains_case_insensitive_content?( get_script_output, 'AMD64' )).to eq(true) + expect(source_contains_case_insensitive_content?( get_script_output, "AMD64" )).to eq(true) end it "executes a script with a 32-bit process if :i386 arch is specified", :not_supported_on_nano do @@ -320,7 +320,7 @@ configuration LCM resource.returns(0) resource.run_action(:run) - expect(source_contains_case_insensitive_content?( get_script_output, 'x86' )).to eq(true) + expect(source_contains_case_insensitive_content?( get_script_output, "x86" )).to eq(true) end it "raises an error when executing a script with a 32-bit process on Windows Nano Server", :windows_nano_only do diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb index da3775ef20..8647ae23a4 100644 --- a/spec/functional/resource/reboot_spec.rb +++ b/spec/functional/resource/reboot_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Reboot do @@ -42,7 +42,7 @@ describe Chef::Resource::Reboot do create_resource end - shared_context 'testing run context modification' do + shared_context "testing run context modification" do def test_reboot_action(resource) reboot_info = resource.run_context.reboot_info expect(reboot_info.keys.sort).to eq([:delay_mins, :reason, :requested_by, :timestamp]) @@ -55,8 +55,8 @@ describe Chef::Resource::Reboot do end # the currently defined behavior for multiple calls to this resource is "last one wins." - describe 'the request_reboot_on_successful_run action' do - include_context 'testing run context modification' + describe "the request_reboot_on_successful_run action" do + include_context "testing run context modification" before do resource.run_action(:request_reboot) @@ -66,19 +66,19 @@ describe Chef::Resource::Reboot do resource.run_context.cancel_reboot end - it 'should have modified the run context correctly' do + it "should have modified the run context correctly" do test_reboot_action(resource) end end - describe 'the reboot_interrupt_run action' do - include_context 'testing run context modification' + describe "the reboot_interrupt_run action" do + include_context "testing run context modification" after do resource.run_context.cancel_reboot end - it 'should have modified the run context correctly' do + it "should have modified the run context correctly" do # this doesn't actually test the flow of Chef::Client#do_run, unfortunately. expect { resource.run_action(:reboot_now) @@ -94,7 +94,7 @@ describe Chef::Resource::Reboot do resource.run_action(:cancel) end - it 'should have cleared the reboot request' do + it "should have cleared the reboot request" do # arguably we shouldn't be querying RunContext's internal data directly. expect(resource.run_context.reboot_info).to eq({}) expect(resource.run_context.reboot_requested?).to be_falsey diff --git a/spec/functional/resource/registry_spec.rb b/spec/functional/resource/registry_spec.rb index c0682fefc8..ec54e8253a 100644 --- a/spec/functional/resource/registry_spec.rb +++ b/spec/functional/resource/registry_spec.rb @@ -43,8 +43,8 @@ end describe Chef::Resource::RegistryKey, :windows_only, :broken => true do # parent and key must be single keys, not paths - let(:parent) { 'Opscode' } - let(:child) { 'Whatever' } + let(:parent) { "Opscode" } + let(:child) { "Whatever" } let(:key_parent) { "SOFTWARE\\" + parent } let(:key_child) { "SOFTWARE\\" + parent + "\\" + child } # must be under HKLM\SOFTWARE for WOW64 redirection to work diff --git a/spec/functional/resource/remote_directory_spec.rb b/spec/functional/resource/remote_directory_spec.rb index 669ee60831..3537432203 100644 --- a/spec/functional/resource/remote_directory_spec.rb +++ b/spec/functional/resource/remote_directory_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::RemoteDirectory do include_context Chef::Resource::Directory @@ -36,14 +36,14 @@ describe Chef::Resource::RemoteDirectory do resource = Chef::Resource::RemoteDirectory.new(path, run_context) resource.source "remotedir" - resource.cookbook('openldap') + resource.cookbook("openldap") resource end def create_extraneous_files - FileUtils.mkdir_p(File.join(path, 'remotesubdir')) - @existing1 = File.join(path, 'marked_for_death.txt') - @existing2 = File.join(path, 'remotesubdir', 'marked_for_death_again.txt') + FileUtils.mkdir_p(File.join(path, "remotesubdir")) + @existing1 = File.join(path, "marked_for_death.txt") + @existing2 = File.join(path, "remotesubdir", "marked_for_death_again.txt") FileUtils.touch(@existing1) FileUtils.touch(@existing2) end @@ -59,12 +59,12 @@ describe Chef::Resource::RemoteDirectory do # See spec/data/cookbooks/openldap/files/default let(:expected_files) do [ - File.join(path, 'remote_dir_file1.txt'), - File.join(path, 'remote_dir_file2.txt'), - File.join(path, 'remotesubdir', 'remote_subdir_file1.txt'), - File.join(path, 'remotesubdir', 'remote_subdir_file2.txt'), - File.join(path, 'remotesubdir', '.a_dotfile'), - File.join(path, '.a_dotdir', '.a_dotfile_in_a_dotdir'), + File.join(path, "remote_dir_file1.txt"), + File.join(path, "remote_dir_file2.txt"), + File.join(path, "remotesubdir", "remote_subdir_file1.txt"), + File.join(path, "remotesubdir", "remote_subdir_file2.txt"), + File.join(path, "remotesubdir", ".a_dotfile"), + File.join(path, ".a_dotdir", ".a_dotfile_in_a_dotdir"), ] end @@ -133,11 +133,11 @@ describe Chef::Resource::RemoteDirectory do end it "leaves modifications alone" do - FileUtils.mkdir_p(File.join(path, 'remotesubdir')) - modified_file = File.join(path, 'remote_dir_file1.txt') - modified_subdir_file = File.join(path, 'remotesubdir', 'remote_subdir_file1.txt') - File.open(modified_file, 'a') {|f| f.puts "santa is real"} - File.open(modified_subdir_file, 'a') {|f| f.puts "so is rudolph"} + FileUtils.mkdir_p(File.join(path, "remotesubdir")) + modified_file = File.join(path, "remote_dir_file1.txt") + modified_subdir_file = File.join(path, "remotesubdir", "remote_subdir_file1.txt") + File.open(modified_file, "a") {|f| f.puts "santa is real"} + File.open(modified_subdir_file, "a") {|f| f.puts "so is rudolph"} modified_file_checksum = sha256_checksum(modified_file) modified_subdir_file_checksum = sha256_checksum(modified_subdir_file) @@ -190,11 +190,11 @@ describe Chef::Resource::RemoteDirectory do context "and there are deeply nested extraneous files in the directory" do before do - FileUtils.mkdir_p(File.join(path, 'a', 'multiply', 'nested', 'directory')) - @existing1 = File.join(path, 'a', 'foo.txt') - @existing2 = File.join(path, 'a', 'multiply', 'bar.txt') - @existing3 = File.join(path, 'a', 'multiply', 'nested', 'baz.txt') - @existing4 = File.join(path, 'a', 'multiply', 'nested', 'directory', 'qux.txt') + FileUtils.mkdir_p(File.join(path, "a", "multiply", "nested", "directory")) + @existing1 = File.join(path, "a", "foo.txt") + @existing2 = File.join(path, "a", "multiply", "bar.txt") + @existing3 = File.join(path, "a", "multiply", "nested", "baz.txt") + @existing4 = File.join(path, "a", "multiply", "nested", "directory", "qux.txt") FileUtils.touch(@existing1) FileUtils.touch(@existing2) FileUtils.touch(@existing3) diff --git a/spec/functional/resource/remote_file_spec.rb b/spec/functional/resource/remote_file_spec.rb index 4fbcd2d24b..7bf95e7a7d 100644 --- a/spec/functional/resource/remote_file_spec.rb +++ b/spec/functional/resource/remote_file_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'tiny_server' -require 'support/shared/functional/http' +require "spec_helper" +require "tiny_server" +require "support/shared/functional/http" describe Chef::Resource::RemoteFile do include ChefHTTPShared @@ -64,10 +64,10 @@ describe Chef::Resource::RemoteFile do end describe "when redownload isn't necessary" do - let(:source) { 'http://localhost:9000/seattle_capo.png' } + let(:source) { "http://localhost:9000/seattle_capo.png" } before do - @api.get("/seattle_capo.png", 304, "", { 'Etag' => 'abcdef' } ) + @api.get("/seattle_capo.png", 304, "", { "Etag" => "abcdef" } ) end it "does not fetch the file" do @@ -76,7 +76,7 @@ describe Chef::Resource::RemoteFile do end context "when using normal encoding" do - let(:source) { 'http://localhost:9000/nyan_cat.png' } + let(:source) { "http://localhost:9000/nyan_cat.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "a file resource" @@ -85,7 +85,7 @@ describe Chef::Resource::RemoteFile do end context "when using gzip encoding" do - let(:source) { 'http://localhost:9000/nyan_cat.png.gz' } + let(:source) { "http://localhost:9000/nyan_cat.png.gz" } let(:expected_content) { binread(nyan_compressed_filename) } it_behaves_like "a file resource" @@ -115,7 +115,7 @@ describe Chef::Resource::RemoteFile do stop_tiny_server end - let(:source) { 'https://localhost:9000/nyan_cat.png' } + let(:source) { "https://localhost:9000/nyan_cat.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } @@ -134,7 +134,7 @@ describe Chef::Resource::RemoteFile do context "when downloading compressed data" do let(:expected_content) { binread(nyan_uncompressed_filename) } - let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_content_length_compressed.png" } before do expect(File).not_to exist(path) @@ -156,7 +156,7 @@ describe Chef::Resource::RemoteFile do context "when downloding uncompressed data" do let(:expected_content) { binread(nyan_uncompressed_filename) } - let(:source) { 'http://localhost:9000/nyan_cat_content_length.png' } + let(:source) { "http://localhost:9000/nyan_cat_content_length.png" } before do expect(File).not_to exist(path) @@ -177,7 +177,7 @@ describe Chef::Resource::RemoteFile do end context "when downloading truncated compressed data" do - let(:source) { 'http://localhost:9000/nyan_cat_truncated_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_truncated_compressed.png" } before do expect(File).not_to exist(path) @@ -190,7 +190,7 @@ describe Chef::Resource::RemoteFile do end context "when downloding truncated uncompressed data" do - let(:source) { 'http://localhost:9000/nyan_cat_truncated.png' } + let(:source) { "http://localhost:9000/nyan_cat_truncated.png" } before do expect(File).not_to exist(path) @@ -204,7 +204,7 @@ describe Chef::Resource::RemoteFile do context "when downloding data with transfer-encoding set" do let(:expected_content) { binread(nyan_uncompressed_filename) } - let(:source) { 'http://localhost:9000/nyan_cat_transfer_encoding.png' } + let(:source) { "http://localhost:9000/nyan_cat_transfer_encoding.png" } before do expect(File).not_to exist(path) @@ -225,7 +225,7 @@ describe Chef::Resource::RemoteFile do end describe "when the download of the source raises an exception" do - let(:source) { 'http://localhost:0000/seattle_capo.png' } + let(:source) { "http://localhost:0000/seattle_capo.png" } before do expect(File).not_to exist(path) diff --git a/spec/functional/resource/rpm_spec.rb b/spec/functional/resource/rpm_spec.rb index b37ee781f1..f0e57dc58b 100644 --- a/spec/functional/resource/rpm_spec.rb +++ b/spec/functional/resource/rpm_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' -require 'chef/mixin/shell_out' +require "spec_helper" +require "functional/resource/base" +require "chef/mixin/shell_out" # run this test only for following platforms. -exclude_test = !['aix', 'centos', 'redhat', 'suse'].include?(ohai[:platform]) +exclude_test = !["aix", "centos", "redhat", "suse"].include?(ohai[:platform]) describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test do include Chef::Mixin::ShellOut @@ -61,12 +61,12 @@ describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test d @pkg_name = "dummy" @pkg_version = "1-0" @pkg_path = "/tmp/dummy-1-0.aix6.1.noarch.rpm" - FileUtils.cp(File.join(CHEF_SPEC_ASSETS, 'dummy-1-0.aix6.1.noarch.rpm') , @pkg_path) + FileUtils.cp(File.join(CHEF_SPEC_ASSETS, "dummy-1-0.aix6.1.noarch.rpm") , @pkg_path) when "centos", "redhat", "suse" @pkg_name = "mytest" @pkg_version = "1.0-1" @pkg_path = "/tmp/mytest-1.0-1.noarch.rpm" - FileUtils.cp(File.join(CHEF_SPEC_ASSETS, 'mytest-1.0-1.noarch.rpm') , @pkg_path) + FileUtils.cp(File.join(CHEF_SPEC_ASSETS, "mytest-1.0-1.noarch.rpm") , @pkg_path) end end @@ -99,14 +99,14 @@ describe Chef::Resource::RpmPackage, :requires_root, :external => exclude_test d context "package upgrade action" do before(:each) do shell_out("rpm -i #{@pkg_path}") - if ohai[:platform] == 'aix' + if ohai[:platform] == "aix" @pkg_version = "2-0" @pkg_path = "/tmp/dummy-2-0.aix6.1.noarch.rpm" - FileUtils.cp(File.join(CHEF_SPEC_ASSETS, 'dummy-2-0.aix6.1.noarch.rpm') , @pkg_path) + FileUtils.cp(File.join(CHEF_SPEC_ASSETS, "dummy-2-0.aix6.1.noarch.rpm") , @pkg_path) else @pkg_version = "2.0-1" @pkg_path = "/tmp/mytest-2.0-1.noarch.rpm" - FileUtils.cp(File.join(CHEF_SPEC_ASSETS, 'mytest-2.0-1.noarch.rpm') , @pkg_path) + FileUtils.cp(File.join(CHEF_SPEC_ASSETS, "mytest-2.0-1.noarch.rpm") , @pkg_path) end end diff --git a/spec/functional/resource/template_spec.rb b/spec/functional/resource/template_spec.rb index 35c5166e31..b0099e02c0 100644 --- a/spec/functional/resource/template_spec.rb +++ b/spec/functional/resource/template_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Template do @@ -44,8 +44,8 @@ describe Chef::Resource::Template do events = Chef::EventDispatch::Dispatcher.new run_context = Chef::RunContext.new(node, cookbook_collection, events) resource = Chef::Resource::Template.new(path, run_context) - resource.source('openldap_stuff.conf.erb') - resource.cookbook('openldap') + resource.source("openldap_stuff.conf.erb") + resource.cookbook("openldap") # NOTE: partials rely on `cookbook_name` getting set by chef internals and # ignore the user-set `cookbook` attribute. @@ -66,14 +66,14 @@ describe Chef::Resource::Template do context "when the target file does not exist" do it "creates the template with the rendered content using the variable attribute when the :create action is run" do - resource.source('openldap_variable_stuff.conf.erb') + resource.source("openldap_variable_stuff.conf.erb") resource.variables(:secret => "nutella") resource.run_action(:create) expect(IO.read(path)).to eq("super secret is nutella") end it "creates the template with the rendered content using a local erb file when the :create action is run" do - resource.source(File.expand_path(File.join(CHEF_SPEC_DATA,'cookbooks','openldap','templates','default','openldap_stuff.conf.erb'))) + resource.source(File.expand_path(File.join(CHEF_SPEC_DATA,"cookbooks","openldap","templates","default","openldap_stuff.conf.erb"))) resource.cookbook(nil) resource.local(true) resource.run_action(:create) diff --git a/spec/functional/resource/user/dscl_spec.rb b/spec/functional/resource/user/dscl_spec.rb index 5d960daf11..db2e67e714 100644 --- a/spec/functional/resource/user/dscl_spec.rb +++ b/spec/functional/resource/user/dscl_spec.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/shell_out' +require "spec_helper" +require "chef/mixin/shell_out" metadata = { :mac_osx_only => true, diff --git a/spec/functional/resource/user/useradd_spec.rb b/spec/functional/resource/user/useradd_spec.rb index 2750d33fd1..5ab6a403da 100644 --- a/spec/functional/resource/user/useradd_spec.rb +++ b/spec/functional/resource/user/useradd_spec.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' -require 'chef/mixin/shell_out' +require "spec_helper" +require "functional/resource/base" +require "chef/mixin/shell_out" def user_provider_for_platform case ohai[:platform] @@ -50,7 +50,7 @@ describe Chef::Provider::User::Useradd, metadata do passwd_file = File.open("/etc/passwd", "rb") {|f| f.read} matcher = /^#{Regexp.escape(username)}.+$/ if passwd_entry = passwd_file.scan(matcher).first - PwEntry.new(*passwd_entry.split(':')) + PwEntry.new(*passwd_entry.split(":")) else raise UserNotFound, "no entry matching #{matcher.inspect} found in /etc/passwd" end @@ -82,13 +82,13 @@ describe Chef::Provider::User::Useradd, metadata do end def try_cleanup - ['/home/cheftestfoo', '/home/cheftestbar'].each do |f| + ["/home/cheftestfoo", "/home/cheftestbar"].each do |f| FileUtils.rm_rf(f) if File.exists? f end - ['cf-test'].each do |u| + ["cf-test"].each do |u| r = Chef::Resource::User.new("DELETE USER", run_context) - r.username('cf-test') + r.username("cf-test") r.run_action(:remove) end end @@ -522,7 +522,7 @@ describe Chef::Provider::User::Useradd, metadata do end def shadow_password - shadow_entry.split(':')[1] + shadow_entry.split(":")[1] end def aix_user_lock_status @@ -665,10 +665,10 @@ describe Chef::Provider::User::Useradd, metadata do # DEBUG: Ran usermod -U chef-functional-test returned 0 expect(@error).to be_nil if ohai[:platform] == "aix" - expect(pw_entry.passwd).to eq('*') + expect(pw_entry.passwd).to eq("*") user_account_should_be_unlocked else - expect(pw_entry.passwd).to eq('x') + expect(pw_entry.passwd).to eq("x") expect(shadow_password).to include("!") end end diff --git a/spec/functional/resource/user/windows_spec.rb b/spec/functional/resource/user/windows_spec.rb index 5e3a9090d4..aefe8ba676 100644 --- a/spec/functional/resource/user/windows_spec.rb +++ b/spec/functional/resource/user/windows_spec.rb @@ -15,13 +15,13 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/shell_out' +require "spec_helper" +require "chef/mixin/shell_out" describe Chef::Provider::User::Windows, :windows_only do include Chef::Mixin::ShellOut - let(:username) { 'ChefFunctionalTest' } + let(:username) { "ChefFunctionalTest" } let(:password) { SecureRandom.uuid } let(:node) do @@ -47,84 +47,84 @@ describe Chef::Provider::User::Windows, :windows_only do delete_user(username) end - describe 'action :create' do - it 'creates a user when a username and password are given' do + describe "action :create" do + it "creates a user when a username and password are given" do new_resource.run_action(:create) expect(new_resource).to be_updated_by_last_action expect(shell_out("net user #{username}").exitstatus).to eq(0) end - it 'reports no changes if there are no changes needed' do + it "reports no changes if there are no changes needed" do new_resource.run_action(:create) new_resource.run_action(:create) expect(new_resource).not_to be_updated_by_last_action end - it 'allows chaning the password' do + it "allows chaning the password" do new_resource.run_action(:create) new_resource.password(SecureRandom.uuid) new_resource.run_action(:create) expect(new_resource).to be_updated_by_last_action end - context 'with a gid specified' do - it 'warns unsupported' do + context "with a gid specified" do + it "warns unsupported" do expect(Chef::Log).to receive(:warn).with(/not implemented/) - new_resource.gid('agroup') + new_resource.gid("agroup") new_resource.run_action(:create) end end end - describe 'action :remove' do + describe "action :remove" do before do new_resource.run_action(:create) end - it 'deletes the user' do + it "deletes the user" do new_resource.run_action(:remove) expect(new_resource).to be_updated_by_last_action expect(shell_out("net user #{username}").exitstatus).to eq(2) end - it 'is idempotent' do + it "is idempotent" do new_resource.run_action(:remove) new_resource.run_action(:remove) expect(new_resource).not_to be_updated_by_last_action end end - describe 'action :lock' do + describe "action :lock" do before do new_resource.run_action(:create) end - it 'locks the user account' do + it "locks the user account" do new_resource.run_action(:lock) expect(new_resource).to be_updated_by_last_action expect(shell_out("net user #{username}").stdout).to match(/Account active\s*No/) end - it 'is idempotent' do + it "is idempotent" do new_resource.run_action(:lock) new_resource.run_action(:lock) expect(new_resource).not_to be_updated_by_last_action end end - describe 'action :unlock' do + describe "action :unlock" do before do new_resource.run_action(:create) new_resource.run_action(:lock) end - it 'unlocks the user account' do + it "unlocks the user account" do new_resource.run_action(:unlock) expect(new_resource).to be_updated_by_last_action expect(shell_out("net user #{username}").stdout).to match(/Account active\s*Yes/) end - it 'is idempotent' do + it "is idempotent" do new_resource.run_action(:unlock) new_resource.run_action(:unlock) expect(new_resource).not_to be_updated_by_last_action diff --git a/spec/functional/resource/windows_package_spec.rb b/spec/functional/resource/windows_package_spec.rb index 957f357846..684f2542c2 100644 --- a/spec/functional/resource/windows_package_spec.rb +++ b/spec/functional/resource/windows_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'functional/resource/base' +require "spec_helper" +require "functional/resource/base" describe Chef::Resource::WindowsPackage, :windows_only, :volatile do let(:pkg_name) { nil } @@ -38,9 +38,9 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do end describe "install package" do - let(:pkg_name) { 'Microsoft Visual C++ 2005 Redistributable' } - let(:pkg_checksum) { 'd6832398e3bc9156a660745f427dc1c2392ce4e9a872e04f41f62d0c6bae07a8' } - let(:pkg_path) { 'https://download.microsoft.com/download/6/B/B/6BB661D6-A8AE-4819-B79F-236472F6070C/vcredist_x86.exe' } + let(:pkg_name) { "Microsoft Visual C++ 2005 Redistributable" } + let(:pkg_checksum) { "d6832398e3bc9156a660745f427dc1c2392ce4e9a872e04f41f62d0c6bae07a8" } + let(:pkg_path) { "https://download.microsoft.com/download/6/B/B/6BB661D6-A8AE-4819-B79F-236472F6070C/vcredist_x86.exe" } let(:pkg_checksum) { nil } let(:pkg_type) { :custom } let(:pkg_options) { "/Q" } @@ -56,9 +56,9 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do end context "installing additional version" do - let(:pkg_path) { 'https://download.microsoft.com/download/e/1/c/e1c773de-73ba-494a-a5ba-f24906ecf088/vcredist_x86.exe' } - let(:pkg_checksum) { 'eb00f891919d4f894ab725b158459db8834470c382dc60cd3c3ee2c6de6da92c' } - let(:pkg_version) { '8.0.56336' } + let(:pkg_path) { "https://download.microsoft.com/download/e/1/c/e1c773de-73ba-494a-a5ba-f24906ecf088/vcredist_x86.exe" } + let(:pkg_checksum) { "eb00f891919d4f894ab725b158459db8834470c382dc60cd3c3ee2c6de6da92c" } + let(:pkg_version) { "8.0.56336" } it "installs older version" do subject.run_action(:install) @@ -70,14 +70,14 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do subject { Chef::Resource::WindowsPackage.new(pkg_name, run_context) } context "multiple versions and a version given to remove" do - before { subject.version('8.0.56336')} + before { subject.version("8.0.56336")} it "removes specified version" do subject.run_action(:remove) expect(subject).to be_updated_by_last_action prov = subject.provider_for_action(:remove) prov.load_current_resource - expect(prov.current_version_array).to eq([['8.0.59193']]) + expect(prov.current_version_array).to eq([["8.0.59193"]]) end end @@ -102,8 +102,8 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do install1.run_action(:install) install2 = Chef::Resource::WindowsPackage.new(pkg_name, run_context) - install2.source 'https://download.microsoft.com/download/e/1/c/e1c773de-73ba-494a-a5ba-f24906ecf088/vcredist_x86.exe' - install2.version '8.0.56336' + install2.source "https://download.microsoft.com/download/e/1/c/e1c773de-73ba-494a-a5ba-f24906ecf088/vcredist_x86.exe" + install2.version "8.0.56336" install2.installer_type pkg_type install2.options pkg_options install2.run_action(:install) @@ -124,9 +124,9 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do after { subject.run_action(:remove) } context "null soft" do - let(:pkg_name) { 'Ultra Defragmenter' } - let(:pkg_path) { 'http://iweb.dl.sourceforge.net/project/ultradefrag/stable-release/6.1.1/ultradefrag-6.1.1.bin.amd64.exe' } - let(:pkg_checksum) { '11d53ed4c426c8c867ad43f142b7904226ffd9938c02e37086913620d79e3c09' } + let(:pkg_name) { "Ultra Defragmenter" } + let(:pkg_path) { "http://iweb.dl.sourceforge.net/project/ultradefrag/stable-release/6.1.1/ultradefrag-6.1.1.bin.amd64.exe" } + let(:pkg_checksum) { "11d53ed4c426c8c867ad43f142b7904226ffd9938c02e37086913620d79e3c09" } it "finds the correct installer type" do subject.run_action(:install) @@ -135,9 +135,9 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do end context "inno" do - let(:pkg_name) { 'Mercurial 3.6.1 (64-bit)' } - let(:pkg_path) { 'http://mercurial.selenic.com/release/windows/Mercurial-3.6.1-x64.exe' } - let(:pkg_checksum) { 'febd29578cb6736163d232708b834a2ddd119aa40abc536b2c313fc5e1b5831d' } + let(:pkg_name) { "Mercurial 3.6.1 (64-bit)" } + let(:pkg_path) { "http://mercurial.selenic.com/release/windows/Mercurial-3.6.1-x64.exe" } + let(:pkg_checksum) { "febd29578cb6736163d232708b834a2ddd119aa40abc536b2c313fc5e1b5831d" } it "finds the correct installer type" do subject.run_action(:install) @@ -147,9 +147,9 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do end describe "install from local file" do - let(:pkg_name) { 'Mercurial 3.6.1 (64-bit)' } + let(:pkg_name) { "Mercurial 3.6.1 (64-bit)" } let(:pkg_path) { ::File.join(Chef::Config[:file_cache_path], "package", "Mercurial-3.6.1-x64.exe") } - let(:pkg_checksum) { 'febd29578cb6736163d232708b834a2ddd119aa40abc536b2c313fc5e1b5831d' } + let(:pkg_checksum) { "febd29578cb6736163d232708b834a2ddd119aa40abc536b2c313fc5e1b5831d" } it "installs the app" do subject.run_action(:install) @@ -158,7 +158,7 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do end describe "uninstall exe without source" do - let(:pkg_name) { 'Mercurial 3.6.1 (64-bit)' } + let(:pkg_name) { "Mercurial 3.6.1 (64-bit)" } it "uninstalls the app" do subject.run_action(:remove) diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb index bbefb49623..56d81845e8 100644 --- a/spec/functional/resource/windows_service_spec.rb +++ b/spec/functional/resource/windows_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_gem_only, :appveyor_only do diff --git a/spec/functional/rest_spec.rb b/spec/functional/rest_spec.rb index 7c6b1872ef..e2d472c1d5 100644 --- a/spec/functional/rest_spec.rb +++ b/spec/functional/rest_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'tiny_server' -require 'support/shared/functional/http' +require "spec_helper" +require "tiny_server" +require "support/shared/functional/http" describe Chef::REST do include ChefHTTPShared diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb index f3156ff770..acd63960f6 100644 --- a/spec/functional/run_lock_spec.rb +++ b/spec/functional/run_lock_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path('../../spec_helper', __FILE__) -require 'chef/client' +require File.expand_path("../../spec_helper", __FILE__) +require "chef/client" describe Chef::RunLock do @@ -59,8 +59,8 @@ describe Chef::RunLock do BREATHING_ROOM = 1 # ClientProcess is defined below - let!(:p1) { ClientProcess.new(self, 'p1') } - let!(:p2) { ClientProcess.new(self, 'p2') } + let!(:p1) { ClientProcess.new(self, "p1") } + let!(:p2) { ClientProcess.new(self, "p2") } after(:each) do |example| begin p1.stop @@ -103,7 +103,7 @@ describe Chef::RunLock do end it "the lockfile is empty" do - expect(IO.read(lockfile)).to eq('') + expect(IO.read(lockfile)).to eq("") end context "and a second client gets the lock" do @@ -157,7 +157,7 @@ describe Chef::RunLock do end it "the lockfile is empty" do - expect(IO.read(lockfile)).to eq('') + expect(IO.read(lockfile)).to eq("") end it "and a second client tries to acquire the lock, it doesn't get the lock until *after* the first client exits" do diff --git a/spec/functional/shell_spec.rb b/spec/functional/shell_spec.rb index a753948c7f..c43f7bca01 100644 --- a/spec/functional/shell_spec.rb +++ b/spec/functional/shell_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'functional/resource/base' -require 'chef/version' -require 'chef/shell' -require 'chef/mixin/command/unix' +require "functional/resource/base" +require "chef/version" +require "chef/shell" +require "chef/mixin/command/unix" describe Shell do @@ -82,7 +82,7 @@ describe Shell do when "aix" config = File.expand_path("shef-config.rb", CHEF_SPEC_DATA) path_to_chef_shell = File.expand_path("../../../bin/chef-shell", __FILE__) - output = '' + output = "" status = popen4("#{path_to_chef_shell} -c #{config} #{options}", :waitlast => true) do |pid, stdin, stdout, stderr| read_until(stdout, "chef (#{Chef::VERSION})>") yield stdout, stdin if block_given? @@ -97,7 +97,7 @@ describe Shell do # Windows ruby installs don't (always?) have PTY, # so hide the require here begin - require 'pty' + require "pty" config = File.expand_path("shef-config.rb", CHEF_SPEC_DATA) path_to_chef_shell = File.expand_path("../../../bin/chef-shell", __FILE__) reader, writer, pid = PTY.spawn("#{path_to_chef_shell} -c #{config} #{options}") diff --git a/spec/functional/tiny_server_spec.rb b/spec/functional/tiny_server_spec.rb index d21248062a..ebbf9a92dd 100644 --- a/spec/functional/tiny_server_spec.rb +++ b/spec/functional/tiny_server_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tiny_server' +require "spec_helper" +require "tiny_server" describe TinyServer::API do before do @@ -30,30 +30,30 @@ describe TinyServer::API do end it "clears the router" do - @api.get('/blargh', 200, "blargh") + @api.get("/blargh", 200, "blargh") @api.clear expect(@api.routes["GET"]).to be_empty end it "creates a route for a GET request" do - @api.get('/foo/bar', 200, 'hello foobar') + @api.get("/foo/bar", 200, "hello foobar") # WEBrick gives you the full URI with host, Thin only gave the part after scheme+host+port - response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => 'http://localhost:1974/foo/bar') - expect(response).to eq([200, {'Content-Type' => 'application/json'}, [ 'hello foobar' ]]) + response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => "http://localhost:1974/foo/bar") + expect(response).to eq([200, {"Content-Type" => "application/json"}, [ "hello foobar" ]]) end it "creates a route for a request with a block" do block_called = false - @api.get('/bar/baz', 200) { block_called = true; 'hello barbaz' } - response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => 'http://localhost:1974/bar/baz') - expect(response).to eq([200, {'Content-Type' => 'application/json'}, [ 'hello barbaz' ]]) + @api.get("/bar/baz", 200) { block_called = true; "hello barbaz" } + response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => "http://localhost:1974/bar/baz") + expect(response).to eq([200, {"Content-Type" => "application/json"}, [ "hello barbaz" ]]) expect(block_called).to be_truthy end it "returns debugging info for 404s" do - response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => '/no_such_thing') + response = @api.call("REQUEST_METHOD" => "GET", "REQUEST_URI" => "/no_such_thing") expect(response[0]).to eq(404) - expect(response[1]).to eq({'Content-Type' => 'application/json'}) + expect(response[1]).to eq({"Content-Type" => "application/json"}) expect(response[2]).to be_a_kind_of(Array) response_obj = Chef::JSONCompat.from_json(response[2].first) expect(response_obj["message"]).to eq("no data matches the request for /no_such_thing") @@ -70,7 +70,7 @@ describe TinyServer::Manager do TinyServer::API.instance.get("/index", 200, "[\"hello\"]") - rest = Chef::HTTP.new('http://localhost:9000') + rest = Chef::HTTP.new("http://localhost:9000") expect(rest.get("index")).to eq("[\"hello\"]") @server.stop diff --git a/spec/functional/util/path_helper_spec.rb b/spec/functional/util/path_helper_spec.rb index 0321702bb8..edd9f2e224 100644 --- a/spec/functional/util/path_helper_spec.rb +++ b/spec/functional/util/path_helper_spec.rb @@ -14,9 +14,9 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'tmpdir' -require 'chef/util/path_helper' -require 'spec_helper' +require "tmpdir" +require "chef/util/path_helper" +require "spec_helper" describe Chef::Util::PathHelper, "escape_glob" do PathHelper = Chef::Util::PathHelper @@ -27,7 +27,7 @@ describe Chef::Util::PathHelper, "escape_glob" do # add some files files = ["some.rb", "file.txt", "names.csv"] files.each do |file| - File.new(File.join(dir, file), 'w').close + File.new(File.join(dir, file), "w").close end pattern = File.join(PathHelper.escape_glob(dir), "*") diff --git a/spec/functional/util/powershell/cmdlet_spec.rb b/spec/functional/util/powershell/cmdlet_spec.rb index 201fb95af8..fe9438f467 100644 --- a/spec/functional/util/powershell/cmdlet_spec.rb +++ b/spec/functional/util/powershell/cmdlet_spec.rb @@ -16,22 +16,22 @@ # limitations under the License. # -require 'chef/json_compat' -require File.expand_path('../../../../spec_helper', __FILE__) +require "chef/json_compat" +require File.expand_path("../../../../spec_helper", __FILE__) describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do before(:all) do ohai = Ohai::System.new ohai.load_plugins - ohai.run_plugins(true, ['platform', 'kernel']) + ohai.run_plugins(true, ["platform", "kernel"]) @node = Chef::Node.new @node.consume_external_attrs(ohai.data, {}) end let(:cmd_output_format) { :text } - let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-childitem', cmd_output_format, {:depth => 2}) } - let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-idontexist', cmd_output_format) } - let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, 'get-item', cmd_output_format, {:depth => 2}) } - let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, 'alias', cmd_output_format, {:depth => 2}) } + let(:simple_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-childitem", cmd_output_format, {:depth => 2}) } + let(:invalid_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "get-idontexist", cmd_output_format) } + let(:cmdlet_get_item_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "get-item", cmd_output_format, {:depth => 2}) } + let(:cmdlet_alias_requires_switch_or_argument) { Chef::Util::Powershell::Cmdlet.new(@node, "alias", cmd_output_format, {:depth => 2}) } let(:etc_directory) { "#{ENV['systemroot']}\\system32\\drivers\\etc" } let(:architecture_cmdlet) { Chef::Util::Powershell::Cmdlet.new(@node, "$env:PROCESSOR_ARCHITECTURE")} @@ -49,9 +49,9 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do end it "executes a 64-bit command on a 64-bit OS, 32-bit otherwise" do - os_arch = ENV['PROCESSOR_ARCHITEW6432'] + os_arch = ENV["PROCESSOR_ARCHITEW6432"] if os_arch.nil? - os_arch = ENV['PROCESSOR_ARCHITECTURE'] + os_arch = ENV["PROCESSOR_ARCHITECTURE"] end result = architecture_cmdlet.run @@ -61,17 +61,17 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do end it "passes command line switches to the command" do - result = cmdlet_alias_requires_switch_or_argument.run({:name => 'ls'}) + result = cmdlet_alias_requires_switch_or_argument.run({:name => "ls"}) expect(result.succeeded?).to eq(true) end it "passes command line arguments to the command" do - result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls') + result = cmdlet_alias_requires_switch_or_argument.run({},{},"ls") expect(result.succeeded?).to eq(true) end it "passes command line arguments and switches to the command" do - result = cmdlet_get_item_requires_switch_or_argument.run({:path => etc_directory},{},' | select-object -property fullname | format-table -hidetableheaders') + result = cmdlet_get_item_requires_switch_or_argument.run({:path => etc_directory},{}," | select-object -property fullname | format-table -hidetableheaders") expect(result.succeeded?).to eq(true) returned_directory = result.return_value returned_directory.strip! @@ -79,7 +79,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do end it "passes execution options to the command" do - result = cmdlet_get_item_requires_switch_or_argument.run({},{:cwd => etc_directory},'. | select-object -property fullname | format-table -hidetableheaders') + result = cmdlet_get_item_requires_switch_or_argument.run({},{:cwd => etc_directory},". | select-object -property fullname | format-table -hidetableheaders") expect(result.succeeded?).to eq(true) returned_directory = result.return_value returned_directory.strip! @@ -89,7 +89,7 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do context "when returning json" do let(:cmd_output_format) { :json } it "returns json format data" do - result = cmdlet_alias_requires_switch_or_argument.run({},{},'ls') + result = cmdlet_alias_requires_switch_or_argument.run({},{},"ls") expect(result.succeeded?).to eq(true) expect(lambda{Chef::JSONCompat.parse(result.return_value)}).not_to raise_error end @@ -98,10 +98,10 @@ describe Chef::Util::Powershell::Cmdlet, :windows_powershell_dsc_only do context "when returning Ruby objects" do let(:cmd_output_format) { :object } it "returns object format data" do - result = simple_cmdlet.run({},{:cwd => etc_directory}, 'hosts') + result = simple_cmdlet.run({},{:cwd => etc_directory}, "hosts") expect(result.succeeded?).to eq(true) data = result.return_value - expect(data['Name']).to eq('hosts') + expect(data["Name"]).to eq("hosts") end end diff --git a/spec/functional/version_spec.rb b/spec/functional/version_spec.rb index cd5bbc7678..7ff31cd4ed 100644 --- a/spec/functional/version_spec.rb +++ b/spec/functional/version_spec.rb @@ -15,10 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -require File.expand_path('../../spec_helper', __FILE__) -require 'chef/mixin/shell_out' -require 'chef/version' -require 'ohai/version' +require File.expand_path("../../spec_helper", __FILE__) +require "chef/mixin/shell_out" +require "chef/version" +require "ohai/version" describe "Chef Versions" do include Chef::Mixin::ShellOut diff --git a/spec/functional/win32/crypto_spec.rb b/spec/functional/win32/crypto_spec.rb index 1492995886..185231dbdd 100644 --- a/spec/functional/win32/crypto_spec.rb +++ b/spec/functional/win32/crypto_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" if Chef::Platform.windows? - require 'chef/win32/crypto' + require "chef/win32/crypto" end -describe 'Chef::ReservedNames::Win32::Crypto', :windows_only do +describe "Chef::ReservedNames::Win32::Crypto", :windows_only do describe '#encrypt' do before(:all) do ohai_reader = Ohai::System.new @@ -35,9 +35,9 @@ describe 'Chef::ReservedNames::Win32::Crypto', :windows_only do @run_context = Chef::RunContext.new(new_node, {}, events) end - let (:plaintext) { 'p@assword' } + let (:plaintext) { "p@assword" } - it 'can be decrypted by powershell' do + it "can be decrypted by powershell" do encrypted = Chef::ReservedNames::Win32::Crypto.encrypt(plaintext) resource = Chef::Resource::WindowsScript::PowershellScript.new("Powershell resource functional test", @run_context) resource.code <<-EOF diff --git a/spec/functional/win32/registry_spec.rb b/spec/functional/win32/registry_spec.rb index dcfc49e2b3..4e18074271 100644 --- a/spec/functional/win32/registry_spec.rb +++ b/spec/functional/win32/registry_spec.rb @@ -17,10 +17,10 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/win32/registry' +require "spec_helper" +require "chef/win32/registry" -describe 'Chef::Win32::Registry', :windows_only do +describe "Chef::Win32::Registry", :windows_only do before(:all) do #Create a registry item @@ -28,14 +28,14 @@ describe 'Chef::Win32::Registry', :windows_only do ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Branch" ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Branch\\Flower" ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root', Win32::Registry::KEY_ALL_ACCESS) do |reg| - reg['RootType1', Win32::Registry::REG_SZ] = 'fibrous' - reg.write('Roots', Win32::Registry::REG_MULTI_SZ, ["strong roots", "healthy tree"]) + reg["RootType1", Win32::Registry::REG_SZ] = "fibrous" + reg.write("Roots", Win32::Registry::REG_MULTI_SZ, ["strong roots", "healthy tree"]) end ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Branch', Win32::Registry::KEY_ALL_ACCESS) do |reg| - reg['Strong', Win32::Registry::REG_SZ] = 'bird nest' + reg["Strong", Win32::Registry::REG_SZ] = "bird nest" end ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Branch\\Flower', Win32::Registry::KEY_ALL_ACCESS) do |reg| - reg['Petals', Win32::Registry::REG_MULTI_SZ] = ["Pink", "Delicate"] + reg["Petals", Win32::Registry::REG_MULTI_SZ] = ["Pink", "Delicate"] end #Create the node with ohai data @@ -305,7 +305,7 @@ describe 'Chef::Win32::Registry', :windows_only do before(:all) do ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Trunk\\Peck\\Woodpecker" ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Trunk\\Peck\\Woodpecker', Win32::Registry::KEY_ALL_ACCESS) do |reg| - reg['Peter', Win32::Registry::REG_SZ] = 'Tiny' + reg["Peter", Win32::Registry::REG_SZ] = "Tiny" end end @@ -332,11 +332,11 @@ describe 'Chef::Win32::Registry', :windows_only do before (:all) do ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Branch\\Fruit" ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Branch\\Fruit', Win32::Registry::KEY_ALL_ACCESS) do |reg| - reg['Apple', Win32::Registry::REG_MULTI_SZ] = ["Red", "Juicy"] + reg["Apple", Win32::Registry::REG_MULTI_SZ] = ["Red", "Juicy"] end ::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Trunk\\Peck\\Woodpecker" ::Win32::Registry::HKEY_CURRENT_USER.open('Software\\Root\\Trunk\\Peck\\Woodpecker', Win32::Registry::KEY_ALL_ACCESS) do |reg| - reg['Peter', Win32::Registry::REG_SZ] = 'Tiny' + reg["Peter", Win32::Registry::REG_SZ] = "Tiny" end end @@ -527,12 +527,12 @@ describe 'Chef::Win32::Registry', :windows_only do # 64-bit ::Win32::Registry::HKEY_LOCAL_MACHINE.create("Software\\Root\\Mauve", ::Win32::Registry::KEY_ALL_ACCESS | 0x0100) ::Win32::Registry::HKEY_LOCAL_MACHINE.open('Software\\Root\\Mauve', Win32::Registry::KEY_ALL_ACCESS | 0x0100) do |reg| - reg['Alert', Win32::Registry::REG_SZ] = 'Universal' + reg["Alert", Win32::Registry::REG_SZ] = "Universal" end # 32-bit ::Win32::Registry::HKEY_LOCAL_MACHINE.create("Software\\Root\\Poosh", ::Win32::Registry::KEY_ALL_ACCESS | 0x0200) ::Win32::Registry::HKEY_LOCAL_MACHINE.open('Software\\Root\\Poosh', Win32::Registry::KEY_ALL_ACCESS | 0x0200) do |reg| - reg['Status', Win32::Registry::REG_SZ] = 'Lost' + reg["Status", Win32::Registry::REG_SZ] = "Lost" end end diff --git a/spec/functional/win32/security_spec.rb b/spec/functional/win32/security_spec.rb index 27af263860..6bac2aa07b 100644 --- a/spec/functional/win32/security_spec.rb +++ b/spec/functional/win32/security_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" if Chef::Platform.windows? - require 'chef/win32/security' + require "chef/win32/security" end -describe 'Chef::Win32::Security', :windows_only do +describe "Chef::Win32::Security", :windows_only do it "has_admin_privileges? returns true when running as admin" do expect(Chef::ReservedNames::Win32::Security.has_admin_privileges?).to eq(true) end @@ -35,8 +35,8 @@ describe 'Chef::Win32::Security', :windows_only do skip "requires user support in mixlib-shellout" end - describe 'get_file_security' do - it 'should return a security descriptor when called with a path that exists' do + describe "get_file_security" do + it "should return a security descriptor when called with a path that exists" do security_descriptor = Chef::ReservedNames::Win32::Security.get_file_security( "C:\\Program Files") # Make sure the security descriptor works @@ -44,7 +44,7 @@ describe 'Chef::Win32::Security', :windows_only do end end - describe 'access_check' do + describe "access_check" do let(:security_descriptor) { Chef::ReservedNames::Win32::Security.get_file_security( "C:\\Program Files") @@ -69,30 +69,30 @@ describe 'Chef::Win32::Security', :windows_only do let(:desired_access) { Chef::ReservedNames::Win32::Security::FILE_GENERIC_READ } - it 'should check if the provided token has the desired access' do + it "should check if the provided token has the desired access" do expect(Chef::ReservedNames::Win32::Security.access_check(security_descriptor, token, desired_access, mapping)).to be true end end - describe 'Chef::Win32::Security::Token' do + describe "Chef::Win32::Security::Token" do let(:token) { Chef::ReservedNames::Win32::Security.open_process_token( Chef::ReservedNames::Win32::Process.get_current_process, token_rights) } - context 'with all rights' do + context "with all rights" do let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_ALL_ACCESS } - it 'can duplicate a token' do + it "can duplicate a token" do expect{ token.duplicate_token(:SecurityImpersonation) }.not_to raise_error end end - context 'with read only rights' do + context "with read only rights" do let(:token_rights) { Chef::ReservedNames::Win32::Security::TOKEN_READ } - it 'raises an exception when trying to duplicate' do + it "raises an exception when trying to duplicate" do expect{ token.duplicate_token(:SecurityImpersonation) }.to raise_error(Chef::Exceptions::Win32APIError) end end diff --git a/spec/functional/win32/service_manager_spec.rb b/spec/functional/win32/service_manager_spec.rb index a1ce36146f..616a83cfcf 100644 --- a/spec/functional/win32/service_manager_spec.rb +++ b/spec/functional/win32/service_manager_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" if Chef::Platform.windows? - require 'chef/application/windows_service_manager' + require "chef/application/windows_service_manager" end # diff --git a/spec/functional/win32/sid_spec.rb b/spec/functional/win32/sid_spec.rb index 1f5f66178a..f3f3adfb56 100644 --- a/spec/functional/win32/sid_spec.rb +++ b/spec/functional/win32/sid_spec.rb @@ -16,39 +16,39 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" if Chef::Platform.windows? - require 'chef/win32/security' + require "chef/win32/security" end -describe 'Chef::ReservedNames::Win32::SID', :windows_only do +describe "Chef::ReservedNames::Win32::SID", :windows_only do if Chef::Platform.windows? SID ||= Chef::ReservedNames::Win32::Security::SID end - it 'should resolve default_security_object_group as a sane user group', :windows_not_domain_joined_only do + it "should resolve default_security_object_group as a sane user group", :windows_not_domain_joined_only do # Domain accounts: domain-specific Domain Users SID # Microsoft Accounts: SID.current_user # Else: SID.None expect(SID.default_security_object_group).to eq(SID.None).or eq(SID.current_user) end - context 'running as an elevated administrator user' do - it 'should resolve default_security_object_owner as the Administrators group' do + context "running as an elevated administrator user" do + it "should resolve default_security_object_owner as the Administrators group" do expect(SID.default_security_object_owner).to eq(SID.Administrators) end end - context 'running as a non-elevated administrator user' do - it 'should resolve default_security_object_owner as the current user' do - skip 'requires user support in mixlib-shellout, see security_spec.rb' + context "running as a non-elevated administrator user" do + it "should resolve default_security_object_owner as the current user" do + skip "requires user support in mixlib-shellout, see security_spec.rb" expect(SID.default_security_object_owner).to eq(SID.Administrators) end end - context 'running as a non-elevated, non-administrator user' do - it 'should resolve default_security_object_owner as the current user' do - skip 'requires user support in mixlib-shellout, see security_spec.rb' + context "running as a non-elevated, non-administrator user" do + it "should resolve default_security_object_owner as the current user" do + skip "requires user support in mixlib-shellout, see security_spec.rb" expect(SID.default_security_object_owner).to eq(SID.current_user) end end diff --git a/spec/functional/win32/version_info_spec.rb b/spec/functional/win32/version_info_spec.rb index c7d41f9616..162033462d 100644 --- a/spec/functional/win32/version_info_spec.rb +++ b/spec/functional/win32/version_info_spec.rb @@ -16,18 +16,18 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" if Chef::Platform.windows? - require 'chef/win32/file/version_info' + require "chef/win32/file/version_info" end describe "Chef::ReservedNames::Win32::File::VersionInfo", :windows_only do - require 'wmi-lite/wmi' - let(:file_path) { ENV['ComSpec'] } + require "wmi-lite/wmi" + let(:file_path) { ENV["ComSpec"] } let(:os_version) do wmi = WmiLite::Wmi.new - os_info = wmi.first_of('Win32_OperatingSystem') - os_info['version'] + os_info = wmi.first_of("Win32_OperatingSystem") + os_info["version"] end subject { Chef::ReservedNames::Win32::File::VersionInfo.new(file_path) } diff --git a/spec/functional/win32/versions_spec.rb b/spec/functional/win32/versions_spec.rb index 38af47b0c9..8cd6c74fa3 100644 --- a/spec/functional/win32/versions_spec.rb +++ b/spec/functional/win32/versions_spec.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" if Chef::Platform.windows? - require 'chef/win32/version' + require "chef/win32/version" end describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on_win2k3 do before do wmi = WmiLite::Wmi.new - host = wmi.first_of('Win32_OperatingSystem') + host = wmi.first_of("Win32_OperatingSystem") # Use WMI to determine current OS version. # On Win2k8R2 and later, we can dynamically obtain marketing @@ -37,14 +37,14 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on # trademark on Win2k8 and Win2k3 that we're not using in our # library, so we have to set the expectation statically. if Chef::Platform::windows_server_2003? - @current_os_version = 'Windows Server 2003 R2' + @current_os_version = "Windows Server 2003 R2" elsif is_windows_server_2008?(host) - @current_os_version = 'Windows Server 2008' + @current_os_version = "Windows Server 2008" else # The name from WMI is actually what we want in Win2k8R2+. # So this expectation sould continue to hold without modification # as new versions of Windows are released. - @current_os_version = host['caption'] + @current_os_version = host["caption"] end @version = Chef::ReservedNames::Win32::Version.new @@ -98,20 +98,20 @@ describe "Chef::ReservedNames::Win32::Version", :windows_only, :not_supported_on def is_windows_server_2008?(wmi_host) is_win2k8 = false - os_version = wmi_host['version'] + os_version = wmi_host["version"] # The operating system version is a string in the following form # that can be split into components based on the '.' delimiter: # MajorVersionNumber.MinorVersionNumber.BuildNumber - os_version_components = os_version.split('.') + os_version_components = os_version.split(".") if os_version_components.length < 2 - raise 'WMI returned a Windows version from Win32_OperatingSystem.Version ' + - 'with an unexpected format. The Windows version could not be determined.' + raise "WMI returned a Windows version from Win32_OperatingSystem.Version " + + "with an unexpected format. The Windows version could not be determined." end # Windows 6.0 is Windows Server 2008, so test the major and # minor version components - is_win2k8 = os_version_components[0] == '6' && os_version_components[1] == '0' + is_win2k8 = os_version_components[0] == "6" && os_version_components[1] == "0" end end |