diff options
Diffstat (limited to 'spec')
595 files changed, 8966 insertions, 8966 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 diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb index 5e72a94065..0ca784d468 100644 --- a/spec/integration/client/client_spec.rb +++ b/spec/integration/client/client_spec.rb @@ -1,13 +1,13 @@ -require 'support/shared/integration/integration_helper' -require 'chef/mixin/shell_out' -require 'tiny_server' -require 'tmpdir' +require "support/shared/integration/integration_helper" +require "chef/mixin/shell_out" +require "tiny_server" +require "tmpdir" describe "chef-client" do def recipes_filename - File.join(CHEF_SPEC_DATA, 'recipes.tgz') + File.join(CHEF_SPEC_DATA, "recipes.tgz") end def start_tiny_server(server_opts={}) @@ -48,13 +48,13 @@ describe "chef-client" do # cf. CHEF-4914 let(:chef_client) { "ruby '#{chef_dir}/chef-client' --minimal-ohai" } - let(:critical_env_vars) { %w(PATH RUBYOPT BUNDLE_GEMFILE GEM_PATH).map {|o| "#{o}=#{ENV[o]}"} .join(' ') } + let(:critical_env_vars) { %w(PATH RUBYOPT BUNDLE_GEMFILE GEM_PATH).map {|o| "#{o}=#{ENV[o]}"} .join(" ") } when_the_repository "has a cookbook with a no-op recipe" do - before { file 'cookbooks/x/recipes/default.rb', '' } + before { file "cookbooks/x/recipes/default.rb", "" } it "should complete with success" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -63,7 +63,7 @@ EOM end it "should complete successfully with no other environment variables", :skip => (Chef::Platform.windows?) do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -79,7 +79,7 @@ EOM end it "should complete successfully with --no-listen" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -90,32 +90,32 @@ EOM it "should be able to node.save with bad utf8 characters in the node data" do file "cookbooks/x/attributes/default.rb", 'default["badutf8"] = "Elan Ruusam\xE4e"' - result = shell_out("#{chef_client} -z -r 'x::default' --disable-config", :cwd => path_to('')) + result = shell_out("#{chef_client} -z -r 'x::default' --disable-config", :cwd => path_to("")) result.error! end - context 'and no config file' do - it 'should complete with success when cwd is just above cookbooks and paths are not specified' do - result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to('')) + context "and no config file" do + it "should complete with success when cwd is just above cookbooks and paths are not specified" do + result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to("")) result.error! end - it 'should complete with success when cwd is below cookbooks and paths are not specified' do - result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to('cookbooks/x')) + it "should complete with success when cwd is below cookbooks and paths are not specified" do + result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => path_to("cookbooks/x")) result.error! end - it 'should fail when cwd is below high above and paths are not specified' do - result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => File.expand_path('..', path_to(''))) + it "should fail when cwd is below high above and paths are not specified" do + result = shell_out("#{chef_client} -z -o 'x::default' --disable-config", :cwd => File.expand_path("..", path_to(""))) expect(result.exitstatus).to eq(1) end end - context 'and a config file under .chef/knife.rb' do - before { file '.chef/knife.rb', 'xxx.xxx' } + context "and a config file under .chef/knife.rb" do + before { file ".chef/knife.rb", "xxx.xxx" } - it 'should load .chef/knife.rb when -z is specified' do - result = shell_out("#{chef_client} -z -o 'x::default'", :cwd => path_to('')) + it "should load .chef/knife.rb when -z is specified" do + result = shell_out("#{chef_client} -z -o 'x::default'", :cwd => path_to("")) # FATAL: Configuration error NoMethodError: undefined method `xxx' for nil:NilClass expect(result.stdout).to include("xxx") end @@ -123,7 +123,7 @@ EOM end it "should complete with success" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -132,9 +132,9 @@ EOM result.error! end - context 'and a private key' do + context "and a private key" do before do - file 'mykey.pem', <<EOM + file "mykey.pem", <<EOM -----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk @@ -166,7 +166,7 @@ EOM end it "should complete with success even with a client key" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true client_key #{path_to('mykey.pem').inspect} cookbook_path #{path_to('cookbooks').inspect} @@ -177,19 +177,19 @@ EOM end it "should run recipes specified directly on the command line" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true client_key #{path_to('mykey.pem').inspect} cookbook_path #{path_to('cookbooks').inspect} EOM - file 'arbitrary.rb', <<EOM + file "arbitrary.rb", <<EOM file #{path_to('tempfile.txt').inspect} do content '1' end EOM - file 'arbitrary2.rb', <<EOM + file "arbitrary2.rb", <<EOM file #{path_to('tempfile2.txt').inspect} do content '2' end @@ -198,57 +198,57 @@ EOM result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" #{path_to('arbitrary.rb')} #{path_to('arbitrary2.rb')}", :cwd => chef_dir) result.error! - expect(IO.read(path_to('tempfile.txt'))).to eq('1') - expect(IO.read(path_to('tempfile2.txt'))).to eq('2') + expect(IO.read(path_to("tempfile.txt"))).to eq("1") + expect(IO.read(path_to("tempfile2.txt"))).to eq("2") end it "should run recipes specified as relative paths directly on the command line" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true client_key #{path_to('mykey.pem').inspect} cookbook_path #{path_to('cookbooks').inspect} EOM - file 'arbitrary.rb', <<EOM + file "arbitrary.rb", <<EOM file #{path_to('tempfile.txt').inspect} do content '1' end EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" arbitrary.rb", :cwd => path_to('')) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" arbitrary.rb", :cwd => path_to("")) result.error! - expect(IO.read(path_to('tempfile.txt'))).to eq('1') + expect(IO.read(path_to("tempfile.txt"))).to eq("1") end it "should run recipes specified directly on the command line AFTER recipes in the run list" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true client_key #{path_to('mykey.pem').inspect} cookbook_path #{path_to('cookbooks').inspect} EOM - file 'cookbooks/x/recipes/constant_definition.rb', <<EOM + file "cookbooks/x/recipes/constant_definition.rb", <<EOM class ::Blah THECONSTANT = '1' end EOM - file 'arbitrary.rb', <<EOM + file "arbitrary.rb", <<EOM file #{path_to('tempfile.txt').inspect} do content ::Blah::THECONSTANT end EOM - result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", :cwd => path_to('')) + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o x::constant_definition arbitrary.rb", :cwd => path_to("")) result.error! - expect(IO.read(path_to('tempfile.txt'))).to eq('1') + expect(IO.read(path_to("tempfile.txt"))).to eq("1") end end it "should complete with success when passed the -z flag" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM @@ -258,7 +258,7 @@ EOM end it "should complete with success when passed the --local-mode flag" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM @@ -268,7 +268,7 @@ EOM end it "should not print SSL warnings when running in local-mode" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM @@ -279,7 +279,7 @@ EOM end it "should complete with success when passed -z and --chef-zero-port" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM @@ -289,7 +289,7 @@ EOM end it "should complete with success when setting the run list with -r" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM chef_server_url 'http://omg.com/blah' cookbook_path "#{path_to('cookbooks')}" EOM @@ -302,7 +302,7 @@ EOM end it "should complete with success when using --profile-ruby and output a profile file" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -311,7 +311,7 @@ EOM end it "doesn't produce a profile when --profile-ruby is not present" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -322,13 +322,13 @@ EOM when_the_repository "has a cookbook that should fail chef_version checks" do before do - file 'cookbooks/x/recipes/default.rb', '' - file 'cookbooks/x/metadata.rb', <<EOM + file "cookbooks/x/recipes/default.rb", "" + file "cookbooks/x/metadata.rb", <<EOM name 'x' version '0.0.1' chef_version '~> 999.99' EOM - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -342,7 +342,7 @@ EOM when_the_repository "has a cookbook that uses cheffish resources" do before do - file 'cookbooks/x/recipes/default.rb', <<-EOM + file "cookbooks/x/recipes/default.rb", <<-EOM raise "Cheffish was loaded before we used any cheffish things!" if defined?(Cheffish::VERSION) ran_block = false got_server = with_chef_server 'https://blah.com' do @@ -353,7 +353,7 @@ EOM raise "Cheffish was not loaded when we did cheffish things!" if !defined?(Cheffish::VERSION) raise "current_chef_server did not return its value!" if got_server[:chef_server_url] != 'https://blah.com' EOM - file 'config/client.rb', <<-EOM + file "config/client.rb", <<-EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -367,10 +367,10 @@ EOM when_the_repository "has a cookbook that uses chef-provisioning resources" do before do - file 'cookbooks/x/recipes/default.rb', <<-EOM + file "cookbooks/x/recipes/default.rb", <<-EOM with_driver 'blah' EOM - file 'config/client.rb', <<-EOM + file "config/client.rb", <<-EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM @@ -385,7 +385,7 @@ EOM when_the_repository "has a cookbook that generates deprecation warnings" do before do - file 'cookbooks/x/recipes/default.rb', <<-EOM + file "cookbooks/x/recipes/default.rb", <<-EOM class ::MyResource < Chef::Resource use_automatic_resource_name property :x, default: [] @@ -412,7 +412,7 @@ EOM end it "should output each deprecation warning only once, at the end of the run" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" # Mimick what happens when you are on the console @@ -420,7 +420,7 @@ formatters << :doc log_level :warn EOM - ENV.delete('CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS') + ENV.delete("CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS") result = shell_out!("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'x::default'", :cwd => chef_dir) expect(result.error?).to be_falsey @@ -437,7 +437,7 @@ EOM when_the_repository "has a cookbook with only an audit recipe" do before do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" audit_mode :enabled @@ -445,7 +445,7 @@ EOM end it "should exit with a zero code when there is not an audit failure" do - file 'cookbooks/audit_test/recipes/succeed.rb', <<-RECIPE + file "cookbooks/audit_test/recipes/succeed.rb", <<-RECIPE control_group "control group without top level control" do it "should succeed" do expect(2 - 2).to eq(0) @@ -459,7 +459,7 @@ end end it "should exit with a non-zero code when there is an audit failure" do - file 'cookbooks/audit_test/recipes/fail.rb', <<-RECIPE + file "cookbooks/audit_test/recipes/fail.rb", <<-RECIPE control_group "control group without top level control" do it "should fail" do expect(2 - 2).to eq(1) @@ -486,14 +486,14 @@ end let(:tmp_dir) { Dir.mktmpdir("recipe-url") } it "should complete with success when passed -z and --recipe-url" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM chef_repo_path "#{tmp_dir}" EOM result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --recipe-url=http://localhost:9000/recipes.tgz -o 'x::default' -z", :cwd => tmp_dir) result.error! end - it 'should fail when passed --recipe-url and not passed -z' do + it "should fail when passed --recipe-url and not passed -z" do result = shell_out("#{chef_client} --recipe-url=http://localhost:9000/recipes.tgz", :cwd => tmp_dir) expect(result.exitstatus).not_to eq(0) end diff --git a/spec/integration/client/ipv6_spec.rb b/spec/integration/client/ipv6_spec.rb index 493ad79e7c..e8e8753731 100644 --- a/spec/integration/client/ipv6_spec.rb +++ b/spec/integration/client/ipv6_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/mixin/shell_out' +require "support/shared/integration/integration_helper" +require "chef/mixin/shell_out" describe "chef-client" do include IntegrationSupport @@ -88,9 +88,9 @@ END_CLIENT_RB when_the_repository "has a cookbook with a no-op recipe" do before do - cookbook 'noop', '1.0.0', { }, "recipes" => {"default.rb" => "#raise 'foo'"} - file 'config/client.rb', client_rb_content - file 'config/validator.pem', validation_pem + cookbook "noop", "1.0.0", { }, "recipes" => {"default.rb" => "#raise 'foo'"} + file "config/client.rb", client_rb_content + file "config/validator.pem", validation_pem end it "should complete with success" do @@ -115,14 +115,14 @@ END_CLIENT_RB END_RECIPE - data_bag('expect_bag', { 'expect_item' => {"expect_key" => "expect_value"} }) + data_bag("expect_bag", { "expect_item" => {"expect_key" => "expect_value"} }) - cookbook 'api-smoke-test', '1.0.0', { }, "recipes" => {"default.rb" => recipe} + cookbook "api-smoke-test", "1.0.0", { }, "recipes" => {"default.rb" => recipe} end before do - file 'config/client.rb', client_rb_content - file 'config/validator.pem', validation_pem + file "config/client.rb", client_rb_content + file "config/validator.pem", validation_pem end it "should complete with success" do diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb index c1f2c7134f..b4f2d4ca71 100644 --- a/spec/integration/knife/chef_fs_data_store_spec.rb +++ b/spec/integration/knife/chef_fs_data_store_spec.rb @@ -15,14 +15,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/list' -require 'chef/knife/delete' -require 'chef/knife/show' -require 'chef/knife/raw' -require 'chef/knife/cookbook_upload' - -describe 'ChefFSDataStore tests', :workstation do +require "support/shared/integration/integration_helper" +require "chef/knife/list" +require "chef/knife/delete" +require "chef/knife/show" +require "chef/knife/raw" +require "chef/knife/cookbook_upload" + +describe "ChefFSDataStore tests", :workstation do include IntegrationSupport include KnifeSupport @@ -31,18 +31,18 @@ describe 'ChefFSDataStore tests', :workstation do when_the_repository "has one of each thing" do before do - file 'clients/x.json', {} - file 'cookbooks/x/metadata.rb', cookbook_x_100_metadata_rb - file 'data_bags/x/y.json', {} - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/x.json', {} + file "clients/x.json", {} + file "cookbooks/x/metadata.rb", cookbook_x_100_metadata_rb + file "data_bags/x/y.json", {} + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/x.json", {} end - context 'GET /TYPE' do - it 'knife list -z -R returns everything' do - knife('list -z -Rfp /').should_succeed <<EOM + context "GET /TYPE" do + it "knife list -z -R returns everything" do + knife("list -z -Rfp /").should_succeed <<EOM /clients/ /clients/x.json /cookbooks/ @@ -63,128 +63,128 @@ EOM end end - context 'DELETE /TYPE/NAME' do - it 'knife delete -z /clients/x.json works' do - knife('delete -z /clients/x.json').should_succeed "Deleted /clients/x.json\n" - knife('list -z -Rfp /clients').should_succeed '' + context "DELETE /TYPE/NAME" do + it "knife delete -z /clients/x.json works" do + knife("delete -z /clients/x.json").should_succeed "Deleted /clients/x.json\n" + knife("list -z -Rfp /clients").should_succeed "" end - it 'knife delete -z -r /cookbooks/x works' do - knife('delete -z -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -z -Rfp /cookbooks').should_succeed '' + it "knife delete -z -r /cookbooks/x works" do + knife("delete -z -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -z -Rfp /cookbooks").should_succeed "" end - it 'knife delete -z -r /data_bags/x works' do - knife('delete -z -r /data_bags/x').should_succeed "Deleted /data_bags/x\n" - knife('list -z -Rfp /data_bags').should_succeed '' + it "knife delete -z -r /data_bags/x works" do + knife("delete -z -r /data_bags/x").should_succeed "Deleted /data_bags/x\n" + knife("list -z -Rfp /data_bags").should_succeed "" end - it 'knife delete -z /data_bags/x/y.json works' do - knife('delete -z /data_bags/x/y.json').should_succeed "Deleted /data_bags/x/y.json\n" - knife('list -z -Rfp /data_bags').should_succeed "/data_bags/x/\n" + it "knife delete -z /data_bags/x/y.json works" do + knife("delete -z /data_bags/x/y.json").should_succeed "Deleted /data_bags/x/y.json\n" + knife("list -z -Rfp /data_bags").should_succeed "/data_bags/x/\n" end - it 'knife delete -z /environments/x.json works' do - knife('delete -z /environments/x.json').should_succeed "Deleted /environments/x.json\n" - knife('list -z -Rfp /environments').should_succeed '' + it "knife delete -z /environments/x.json works" do + knife("delete -z /environments/x.json").should_succeed "Deleted /environments/x.json\n" + knife("list -z -Rfp /environments").should_succeed "" end - it 'knife delete -z /nodes/x.json works' do - knife('delete -z /nodes/x.json').should_succeed "Deleted /nodes/x.json\n" - knife('list -z -Rfp /nodes').should_succeed '' + it "knife delete -z /nodes/x.json works" do + knife("delete -z /nodes/x.json").should_succeed "Deleted /nodes/x.json\n" + knife("list -z -Rfp /nodes").should_succeed "" end - it 'knife delete -z /roles/x.json works' do - knife('delete -z /roles/x.json').should_succeed "Deleted /roles/x.json\n" - knife('list -z -Rfp /roles').should_succeed '' + it "knife delete -z /roles/x.json works" do + knife("delete -z /roles/x.json").should_succeed "Deleted /roles/x.json\n" + knife("list -z -Rfp /roles").should_succeed "" end - it 'knife delete -z /users/x.json works' do - knife('delete -z /users/x.json').should_succeed "Deleted /users/x.json\n" - knife('list -z -Rfp /users').should_succeed '' + it "knife delete -z /users/x.json works" do + knife("delete -z /users/x.json").should_succeed "Deleted /users/x.json\n" + knife("list -z -Rfp /users").should_succeed "" end end - context 'GET /TYPE/NAME' do - it 'knife show -z /clients/x.json works' do - knife('show -z /clients/x.json').should_succeed( /"x"/ ) + context "GET /TYPE/NAME" do + it "knife show -z /clients/x.json works" do + knife("show -z /clients/x.json").should_succeed( /"x"/ ) end - it 'knife show -z /cookbooks/x/metadata.rb works' do - knife('show -z /cookbooks/x/metadata.rb').should_succeed "/cookbooks/x/metadata.rb:\n#{cookbook_x_100_metadata_rb}\n" + it "knife show -z /cookbooks/x/metadata.rb works" do + knife("show -z /cookbooks/x/metadata.rb").should_succeed "/cookbooks/x/metadata.rb:\n#{cookbook_x_100_metadata_rb}\n" end - it 'knife show -z /data_bags/x/y.json works' do - knife('show -z /data_bags/x/y.json').should_succeed( /"y"/ ) + it "knife show -z /data_bags/x/y.json works" do + knife("show -z /data_bags/x/y.json").should_succeed( /"y"/ ) end - it 'knife show -z /environments/x.json works' do - knife('show -z /environments/x.json').should_succeed( /"x"/ ) + it "knife show -z /environments/x.json works" do + knife("show -z /environments/x.json").should_succeed( /"x"/ ) end - it 'knife show -z /nodes/x.json works' do - knife('show -z /nodes/x.json').should_succeed( /"x"/ ) + it "knife show -z /nodes/x.json works" do + knife("show -z /nodes/x.json").should_succeed( /"x"/ ) end - it 'knife show -z /roles/x.json works' do - knife('show -z /roles/x.json').should_succeed( /"x"/ ) + it "knife show -z /roles/x.json works" do + knife("show -z /roles/x.json").should_succeed( /"x"/ ) end - it 'knife show -z /users/x.json works' do - knife('show -z /users/x.json').should_succeed( /"x"/ ) + it "knife show -z /users/x.json works" do + knife("show -z /users/x.json").should_succeed( /"x"/ ) end end - context 'PUT /TYPE/NAME' do + context "PUT /TYPE/NAME" do before do - file 'empty.json', {} - file 'dummynode.json', { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} - file 'rolestuff.json', '{"description":"hi there","name":"x"}' - file 'cookbooks_to_upload/x/metadata.rb', cookbook_x_100_metadata_rb + file "empty.json", {} + file "dummynode.json", { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} + file "rolestuff.json", '{"description":"hi there","name":"x"}' + file "cookbooks_to_upload/x/metadata.rb", cookbook_x_100_metadata_rb end - it 'knife raw -z -i empty.json -m PUT /clients/x' do + it "knife raw -z -i empty.json -m PUT /clients/x" do knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_succeed( /"x"/ ) - knife('list --local /clients').should_succeed "/clients/x.json\n" + knife("list --local /clients").should_succeed "/clients/x.json\n" end - it 'knife cookbook upload works' do + it "knife cookbook upload works" do knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed :stderr => <<EOM Uploading x [1.0.0] Uploaded 1 cookbook. EOM - knife('list --local -Rfp /cookbooks').should_succeed "/cookbooks/x/\n/cookbooks/x/metadata.rb\n" + knife("list --local -Rfp /cookbooks").should_succeed "/cookbooks/x/\n/cookbooks/x/metadata.rb\n" end - it 'knife raw -z -i empty.json -m PUT /data/x/y' do + it "knife raw -z -i empty.json -m PUT /data/x/y" do knife("raw -z -i #{path_to('empty.json')} -m PUT /data/x/y").should_succeed( /"y"/ ) - knife('list --local -Rfp /data_bags').should_succeed "/data_bags/x/\n/data_bags/x/y.json\n" + knife("list --local -Rfp /data_bags").should_succeed "/data_bags/x/\n/data_bags/x/y.json\n" end - it 'knife raw -z -i empty.json -m PUT /environments/x' do + it "knife raw -z -i empty.json -m PUT /environments/x" do knife("raw -z -i #{path_to('empty.json')} -m PUT /environments/x").should_succeed( /"x"/ ) - knife('list --local /environments').should_succeed "/environments/x.json\n" + knife("list --local /environments").should_succeed "/environments/x.json\n" end - it 'knife raw -z -i dummynode.json -m PUT /nodes/x' do + it "knife raw -z -i dummynode.json -m PUT /nodes/x" do knife("raw -z -i #{path_to('dummynode.json')} -m PUT /nodes/x").should_succeed( /"x"/ ) - knife('list --local /nodes').should_succeed "/nodes/x.json\n" - knife('show -z /nodes/x.json --verbose').should_succeed /"bar"/ + knife("list --local /nodes").should_succeed "/nodes/x.json\n" + knife("show -z /nodes/x.json --verbose").should_succeed /"bar"/ end - it 'knife raw -z -i empty.json -m PUT /roles/x' do + it "knife raw -z -i empty.json -m PUT /roles/x" do knife("raw -z -i #{path_to('empty.json')} -m PUT /roles/x").should_succeed( /"x"/ ) - knife('list --local /roles').should_succeed "/roles/x.json\n" + knife("list --local /roles").should_succeed "/roles/x.json\n" end - it 'knife raw -z -i empty.json -m PUT /users/x' do + it "knife raw -z -i empty.json -m PUT /users/x" do knife("raw -z -i #{path_to('empty.json')} -m PUT /users/x").should_succeed( /"x"/ ) - knife('list --local /users').should_succeed "/users/x.json\n" + knife("list --local /users").should_succeed "/users/x.json\n" end - it 'After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty', :skip => (RUBY_VERSION < "1.9") do + it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", :skip => (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ ) - expect(IO.read(path_to('roles/x.json'))).to eq <<EOM.strip + expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip { "name": "x", "description": "hi there" @@ -194,65 +194,65 @@ EOM end end - when_the_repository 'is empty' do - context 'POST /TYPE/NAME' do + when_the_repository "is empty" do + context "POST /TYPE/NAME" do before do - file 'empty.json', { 'name' => 'z' } - file 'dummynode.json', { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} - file 'empty_x.json', { 'name' => 'x' } - file 'empty_id.json', { 'id' => 'z' } - file 'rolestuff.json', '{"description":"hi there","name":"x"}' - file 'cookbooks_to_upload/z/metadata.rb', cookbook_z_100_metadata_rb + file "empty.json", { "name" => "z" } + file "dummynode.json", { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} + file "empty_x.json", { "name" => "x" } + file "empty_id.json", { "id" => "z" } + file "rolestuff.json", '{"description":"hi there","name":"x"}' + file "cookbooks_to_upload/z/metadata.rb", cookbook_z_100_metadata_rb end - it 'knife raw -z -i empty.json -m POST /clients' do + it "knife raw -z -i empty.json -m POST /clients" do knife("raw -z -i #{path_to('empty.json')} -m POST /clients").should_succeed( /uri/ ) - knife('list --local /clients').should_succeed "/clients/z.json\n" + knife("list --local /clients").should_succeed "/clients/z.json\n" end - it 'knife cookbook upload works' do + it "knife cookbook upload works" do knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed :stderr => <<EOM Uploading z [1.0.0] Uploaded 1 cookbook. EOM - knife('list --local -Rfp /cookbooks').should_succeed "/cookbooks/z/\n/cookbooks/z/metadata.rb\n" + knife("list --local -Rfp /cookbooks").should_succeed "/cookbooks/z/\n/cookbooks/z/metadata.rb\n" end - it 'knife raw -z -i empty.json -m POST /data' do + it "knife raw -z -i empty.json -m POST /data" do knife("raw -z -i #{path_to('empty.json')} -m POST /data").should_succeed( /uri/ ) - knife('list --local -Rfp /data_bags').should_succeed "/data_bags/z/\n" + knife("list --local -Rfp /data_bags").should_succeed "/data_bags/z/\n" end - it 'knife raw -z -i empty.json -m POST /data/x' do + it "knife raw -z -i empty.json -m POST /data/x" do knife("raw -z -i #{path_to('empty_x.json')} -m POST /data").should_succeed( /uri/ ) knife("raw -z -i #{path_to('empty_id.json')} -m POST /data/x").should_succeed( /"z"/ ) - knife('list --local -Rfp /data_bags').should_succeed "/data_bags/x/\n/data_bags/x/z.json\n" + knife("list --local -Rfp /data_bags").should_succeed "/data_bags/x/\n/data_bags/x/z.json\n" end - it 'knife raw -z -i empty.json -m POST /environments' do + it "knife raw -z -i empty.json -m POST /environments" do knife("raw -z -i #{path_to('empty.json')} -m POST /environments").should_succeed( /uri/ ) - knife('list --local /environments').should_succeed "/environments/z.json\n" + knife("list --local /environments").should_succeed "/environments/z.json\n" end - it 'knife raw -z -i dummynode.json -m POST /nodes' do + it "knife raw -z -i dummynode.json -m POST /nodes" do knife("raw -z -i #{path_to('dummynode.json')} -m POST /nodes").should_succeed( /uri/ ) - knife('list --local /nodes').should_succeed "/nodes/z.json\n" - knife('show -z /nodes/z.json').should_succeed /"bar"/ + knife("list --local /nodes").should_succeed "/nodes/z.json\n" + knife("show -z /nodes/z.json").should_succeed /"bar"/ end - it 'knife raw -z -i empty.json -m POST /roles' do + it "knife raw -z -i empty.json -m POST /roles" do knife("raw -z -i #{path_to('empty.json')} -m POST /roles").should_succeed( /uri/ ) - knife('list --local /roles').should_succeed "/roles/z.json\n" + knife("list --local /roles").should_succeed "/roles/z.json\n" end - it 'knife raw -z -i empty.json -m POST /users' do + it "knife raw -z -i empty.json -m POST /users" do knife("raw -z -i #{path_to('empty.json')} -m POST /users").should_succeed( /uri/ ) - knife('list --local /users').should_succeed "/users/z.json\n" + knife("list --local /users").should_succeed "/users/z.json\n" end - it 'After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty', :skip => (RUBY_VERSION < "1.9") do + it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty", :skip => (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m POST /roles").should_succeed( /uri/ ) - expect(IO.read(path_to('roles/x.json'))).to eq <<EOM.strip + expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip { "name": "x", "description": "hi there" @@ -261,8 +261,8 @@ EOM end end - it 'knife list -z -R returns nothing' do - knife('list -z -Rfp /').should_succeed <<EOM + it "knife list -z -R returns nothing" do + knife("list -z -Rfp /").should_succeed <<EOM /clients/ /cookbooks/ /data_bags/ @@ -273,96 +273,96 @@ EOM EOM end - context 'DELETE /TYPE/NAME' do - it 'knife delete -z /clients/x.json fails with an error' do - knife('delete -z /clients/x.json').should_fail "ERROR: /clients/x.json: No such file or directory\n" + context "DELETE /TYPE/NAME" do + it "knife delete -z /clients/x.json fails with an error" do + knife("delete -z /clients/x.json").should_fail "ERROR: /clients/x.json: No such file or directory\n" end - it 'knife delete -z -r /cookbooks/x fails with an error' do - knife('delete -z -r /cookbooks/x').should_fail "ERROR: /cookbooks/x: No such file or directory\n" + it "knife delete -z -r /cookbooks/x fails with an error" do + knife("delete -z -r /cookbooks/x").should_fail "ERROR: /cookbooks/x: No such file or directory\n" end - it 'knife delete -z -r /data_bags/x fails with an error' do - knife('delete -z -r /data_bags/x').should_fail "ERROR: /data_bags/x: No such file or directory\n" + it "knife delete -z -r /data_bags/x fails with an error" do + knife("delete -z -r /data_bags/x").should_fail "ERROR: /data_bags/x: No such file or directory\n" end - it 'knife delete -z /data_bags/x/y.json fails with an error' do - knife('delete -z /data_bags/x/y.json').should_fail "ERROR: /data_bags/x/y.json: No such file or directory\n" + it "knife delete -z /data_bags/x/y.json fails with an error" do + knife("delete -z /data_bags/x/y.json").should_fail "ERROR: /data_bags/x/y.json: No such file or directory\n" end - it 'knife delete -z /environments/x.json fails with an error' do - knife('delete -z /environments/x.json').should_fail "ERROR: /environments/x.json: No such file or directory\n" + it "knife delete -z /environments/x.json fails with an error" do + knife("delete -z /environments/x.json").should_fail "ERROR: /environments/x.json: No such file or directory\n" end - it 'knife delete -z /nodes/x.json fails with an error' do - knife('delete -z /nodes/x.json').should_fail "ERROR: /nodes/x.json: No such file or directory\n" + it "knife delete -z /nodes/x.json fails with an error" do + knife("delete -z /nodes/x.json").should_fail "ERROR: /nodes/x.json: No such file or directory\n" end - it 'knife delete -z /roles/x.json fails with an error' do - knife('delete -z /roles/x.json').should_fail "ERROR: /roles/x.json: No such file or directory\n" + it "knife delete -z /roles/x.json fails with an error" do + knife("delete -z /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n" end - it 'knife delete -z /users/x.json fails with an error' do - knife('delete -z /users/x.json').should_fail "ERROR: /users/x.json: No such file or directory\n" + it "knife delete -z /users/x.json fails with an error" do + knife("delete -z /users/x.json").should_fail "ERROR: /users/x.json: No such file or directory\n" end end - context 'GET /TYPE/NAME' do - it 'knife show -z /clients/x.json fails with an error' do - knife('show -z /clients/x.json').should_fail "ERROR: /clients/x.json: No such file or directory\n" + context "GET /TYPE/NAME" do + it "knife show -z /clients/x.json fails with an error" do + knife("show -z /clients/x.json").should_fail "ERROR: /clients/x.json: No such file or directory\n" end - it 'knife show -z /cookbooks/x/metadata.rb fails with an error' do - knife('show -z /cookbooks/x/metadata.rb').should_fail "ERROR: /cookbooks/x/metadata.rb: No such file or directory\n" + it "knife show -z /cookbooks/x/metadata.rb fails with an error" do + knife("show -z /cookbooks/x/metadata.rb").should_fail "ERROR: /cookbooks/x/metadata.rb: No such file or directory\n" end - it 'knife show -z /data_bags/x/y.json fails with an error' do - knife('show -z /data_bags/x/y.json').should_fail "ERROR: /data_bags/x/y.json: No such file or directory\n" + it "knife show -z /data_bags/x/y.json fails with an error" do + knife("show -z /data_bags/x/y.json").should_fail "ERROR: /data_bags/x/y.json: No such file or directory\n" end - it 'knife show -z /environments/x.json fails with an error' do - knife('show -z /environments/x.json').should_fail "ERROR: /environments/x.json: No such file or directory\n" + it "knife show -z /environments/x.json fails with an error" do + knife("show -z /environments/x.json").should_fail "ERROR: /environments/x.json: No such file or directory\n" end - it 'knife show -z /nodes/x.json fails with an error' do - knife('show -z /nodes/x.json').should_fail "ERROR: /nodes/x.json: No such file or directory\n" + it "knife show -z /nodes/x.json fails with an error" do + knife("show -z /nodes/x.json").should_fail "ERROR: /nodes/x.json: No such file or directory\n" end - it 'knife show -z /roles/x.json fails with an error' do - knife('show -z /roles/x.json').should_fail "ERROR: /roles/x.json: No such file or directory\n" + it "knife show -z /roles/x.json fails with an error" do + knife("show -z /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n" end - it 'knife show -z /users/x.json fails with an error' do - knife('show -z /users/x.json').should_fail "ERROR: /users/x.json: No such file or directory\n" + it "knife show -z /users/x.json fails with an error" do + knife("show -z /users/x.json").should_fail "ERROR: /users/x.json: No such file or directory\n" end end - context 'PUT /TYPE/NAME' do + context "PUT /TYPE/NAME" do before do - file 'empty.json', {} + file "empty.json", {} end - it 'knife raw -z -i empty.json -m PUT /clients/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /clients/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /data/x/y fails with 404' do + it "knife raw -z -i empty.json -m PUT /data/x/y fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /data/x/y").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /environments/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /environments/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /environments/x").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /nodes/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /nodes/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /nodes/x").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /roles/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /roles/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /roles/x").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /users/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /users/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /users/x").should_fail( /404/ ) end end diff --git a/spec/integration/knife/chef_repo_path_spec.rb b/spec/integration/knife/chef_repo_path_spec.rb index 31525cdf25..b5c86d7a00 100644 --- a/spec/integration/knife/chef_repo_path_spec.rb +++ b/spec/integration/knife/chef_repo_path_spec.rb @@ -15,49 +15,49 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/list' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/list" +require "chef/knife/show" -describe 'chef_repo_path tests', :workstation do +describe "chef_repo_path tests", :workstation do include IntegrationSupport include KnifeSupport let(:error_rel_path_outside_repo) { /^ERROR: Attempt to use relative path '' when current directory is outside the repository path/ } # TODO alternate repo_path / *_path - context 'alternate *_path' do - when_the_repository 'has clients and clients2, cookbooks and cookbooks2, etc.' do + context "alternate *_path" do + when_the_repository "has clients and clients2, cookbooks and cookbooks2, etc." do before do - file 'clients/client1.json', {} - file 'cookbooks/cookbook1/metadata.rb', '' - file 'data_bags/bag/item.json', {} - file 'environments/env1.json', {} - file 'nodes/node1.json', {} - file 'roles/role1.json', {} - file 'users/user1.json', {} - - file 'clients2/client2.json', {} - file 'cookbooks2/cookbook2/metadata.rb', '' - file 'data_bags2/bag2/item2.json', {} - file 'environments2/env2.json', {} - file 'nodes2/node2.json', {} - file 'roles2/role2.json', {} - file 'users2/user2.json', {} - - directory 'chef_repo2' do - file 'clients/client3.json', {} - file 'cookbooks/cookbook3/metadata.rb', '' - file 'data_bags/bag3/item3.json', {} - file 'environments/env3.json', {} - file 'nodes/node3.json', {} - file 'roles/role3.json', {} - file 'users/user3.json', {} + file "clients/client1.json", {} + file "cookbooks/cookbook1/metadata.rb", "" + file "data_bags/bag/item.json", {} + file "environments/env1.json", {} + file "nodes/node1.json", {} + file "roles/role1.json", {} + file "users/user1.json", {} + + file "clients2/client2.json", {} + file "cookbooks2/cookbook2/metadata.rb", "" + file "data_bags2/bag2/item2.json", {} + file "environments2/env2.json", {} + file "nodes2/node2.json", {} + file "roles2/role2.json", {} + file "users2/user2.json", {} + + directory "chef_repo2" do + file "clients/client3.json", {} + file "cookbooks/cookbook3/metadata.rb", "" + file "data_bags/bag3/item3.json", {} + file "environments/env3.json", {} + file "nodes/node3.json", {} + file "roles/role3.json", {} + file "users/user3.json", {} end end - it 'knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff' do + it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do Chef::Config.delete(:chef_repo_path) knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<EOM /clients/ @@ -79,15 +79,15 @@ describe 'chef_repo_path tests', :workstation do EOM end - context 'when all _paths are set to alternates' do + context "when all _paths are set to alternates" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, "#{object_name}s2") end - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2') + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "chef_repo2") end - it 'knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff' do + it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<EOM /clients/ /clients/client3.json @@ -108,24 +108,24 @@ EOM EOM end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client2.json cookbooks/ @@ -146,31 +146,31 @@ EOM end end - context 'when cwd is inside data_bags2' do - before { cwd 'data_bags2' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside data_bags2" do + before { cwd "data_bags2" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag2/ bag2/item2.json EOM end - it 'knife list --local -Rfp ../roles lists roles' do - knife('list --local -Rfp ../roles').should_succeed "/roles/role2.json\n" + it "knife list --local -Rfp ../roles lists roles" do + knife("list --local -Rfp ../roles").should_succeed "/roles/role2.json\n" end end end - context 'when all _paths except chef_repo_path are set to alternates' do + context "when all _paths except chef_repo_path are set to alternates" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, "#{object_name}s2") end end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client2.json cookbooks/ @@ -191,24 +191,24 @@ EOM end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside data_bags2' do - before { cwd 'data_bags2' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside data_bags2" do + before { cwd "data_bags2" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag2/ bag2/item2.json EOM @@ -216,32 +216,32 @@ EOM end end - context 'when only chef_repo_path is set to its alternate' do + context "when only chef_repo_path is set to its alternate" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2') + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "chef_repo2") end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client3.json cookbooks/ @@ -262,10 +262,10 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag3/ bag3/item3.json EOM @@ -273,7 +273,7 @@ EOM end end - context 'when paths are set to point to both versions of each' do + context "when paths are set to point to both versions of each" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config["#{object_name}_path".to_sym] = [ @@ -281,16 +281,16 @@ EOM File.join(Chef::Config.chef_repo_path, "#{object_name}s2"), ] end - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2') + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "chef_repo2") end - context 'when there is a directory in clients1 and file in clients2 with the same name' do + context "when there is a directory in clients1 and file in clients2 with the same name" do before do - directory 'clients/blah.json' - file 'clients2/blah.json', {} + directory "clients/blah.json" + file "clients2/blah.json", {} end - it 'knife show /clients/blah.json succeeds' do - knife('show --local /clients/blah.json').should_succeed <<EOM + it "knife show /clients/blah.json succeeds" do + knife("show --local /clients/blah.json").should_succeed <<EOM /clients/blah.json: { @@ -299,13 +299,13 @@ EOM end end - context 'when there is a file in cookbooks1 and directory in cookbooks2 with the same name' do + context "when there is a file in cookbooks1 and directory in cookbooks2 with the same name" do before do - file 'cookbooks/blah', '' - file 'cookbooks2/blah/metadata.rb', '' + file "cookbooks/blah", "" + file "cookbooks2/blah/metadata.rb", "" end - it 'knife list -Rfp cookbooks shows files in blah' do - knife('list --local -Rfp /cookbooks').should_succeed <<EOM + it "knife list -Rfp cookbooks shows files in blah" do + knife("list --local -Rfp /cookbooks").should_succeed <<EOM /cookbooks/blah/ /cookbooks/blah/metadata.rb /cookbooks/cookbook1/ @@ -316,13 +316,13 @@ EOM end end - context 'when there is an empty directory in cookbooks1 and a real cookbook in cookbooks2 with the same name' do + context "when there is an empty directory in cookbooks1 and a real cookbook in cookbooks2 with the same name" do before do - directory 'cookbooks/blah' - file 'cookbooks2/blah/metadata.rb', '' + directory "cookbooks/blah" + file "cookbooks2/blah/metadata.rb", "" end - it 'knife list -Rfp cookbooks shows files in blah' do - knife('list --local -Rfp /cookbooks').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'blah' is empty or entirely chefignored at #{Chef::Config.cookbook_path[0]}/blah\n") + it "knife list -Rfp cookbooks shows files in blah" do + knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'blah' is empty or entirely chefignored at #{Chef::Config.cookbook_path[0]}/blah\n") /cookbooks/blah/ /cookbooks/blah/metadata.rb /cookbooks/cookbook1/ @@ -333,13 +333,13 @@ EOM end end - context 'when there is a cookbook in cookbooks1 and a cookbook in cookbooks2 with the same name' do + context "when there is a cookbook in cookbooks1 and a cookbook in cookbooks2 with the same name" do before do - file 'cookbooks/blah/metadata.json', {} - file 'cookbooks2/blah/metadata.rb', '' + file "cookbooks/blah/metadata.json", {} + file "cookbooks2/blah/metadata.rb", "" end - it 'knife list -Rfp cookbooks shows files in the first cookbook and not the second' do - knife('list --local -Rfp /cookbooks').should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.cookbook_path[0]}/blah and #{Chef::Config.cookbook_path[1]}/blah\n") + it "knife list -Rfp cookbooks shows files in the first cookbook and not the second" do + knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.cookbook_path[0]}/blah and #{Chef::Config.cookbook_path[1]}/blah\n") /cookbooks/blah/ /cookbooks/blah/metadata.json /cookbooks/cookbook1/ @@ -350,13 +350,13 @@ EOM end end - context 'when there is a file in data_bags1 and a directory in data_bags2 with the same name' do + context "when there is a file in data_bags1 and a directory in data_bags2 with the same name" do before do - file 'data_bags/blah', '' - file 'data_bags2/blah/item.json', '' + file "data_bags/blah", "" + file "data_bags2/blah/item.json", "" end - it 'knife list -Rfp data_bags shows files in blah' do - knife('list --local -Rfp /data_bags').should_succeed <<EOM + it "knife list -Rfp data_bags shows files in blah" do + knife("list --local -Rfp /data_bags").should_succeed <<EOM /data_bags/bag/ /data_bags/bag/item.json /data_bags/bag2/ @@ -367,13 +367,13 @@ EOM end end - context 'when there is a data bag in data_bags1 and a data bag in data_bags2 with the same name' do + context "when there is a data bag in data_bags1 and a data bag in data_bags2 with the same name" do before do - file 'data_bags/blah/item1.json', '' - file 'data_bags2/blah/item2.json', '' + file "data_bags/blah/item1.json", "" + file "data_bags2/blah/item2.json", "" end - it 'knife list -Rfp data_bags shows only items in data_bags1' do - knife('list --local -Rfp /data_bags').should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.data_bag_path[0]}/blah and #{Chef::Config.data_bag_path[1]}/blah\n") + it "knife list -Rfp data_bags shows only items in data_bags1" do + knife("list --local -Rfp /data_bags").should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.data_bag_path[0]}/blah and #{Chef::Config.data_bag_path[1]}/blah\n") /data_bags/bag/ /data_bags/bag/item.json /data_bags/bag2/ @@ -384,13 +384,13 @@ EOM end end - context 'when there is a directory in environments1 and file in environments2 with the same name' do + context "when there is a directory in environments1 and file in environments2 with the same name" do before do - directory 'environments/blah.json' - file 'environments2/blah.json', {} + directory "environments/blah.json" + file "environments2/blah.json", {} end - it 'knife show /environments/blah.json succeeds' do - knife('show --local /environments/blah.json').should_succeed <<EOM + it "knife show /environments/blah.json succeeds" do + knife("show --local /environments/blah.json").should_succeed <<EOM /environments/blah.json: { @@ -399,13 +399,13 @@ EOM end end - context 'when there is a directory in nodes1 and file in nodes2 with the same name' do + context "when there is a directory in nodes1 and file in nodes2 with the same name" do before do - directory 'nodes/blah.json' - file 'nodes2/blah.json', {} + directory "nodes/blah.json" + file "nodes2/blah.json", {} end - it 'knife show /nodes/blah.json succeeds' do - knife('show --local /nodes/blah.json').should_succeed <<EOM + it "knife show /nodes/blah.json succeeds" do + knife("show --local /nodes/blah.json").should_succeed <<EOM /nodes/blah.json: { @@ -414,13 +414,13 @@ EOM end end - context 'when there is a directory in roles1 and file in roles2 with the same name' do + context "when there is a directory in roles1 and file in roles2 with the same name" do before do - directory 'roles/blah.json' - file 'roles2/blah.json', {} + directory "roles/blah.json" + file "roles2/blah.json", {} end - it 'knife show /roles/blah.json succeeds' do - knife('show --local /roles/blah.json').should_succeed <<EOM + it "knife show /roles/blah.json succeeds" do + knife("show --local /roles/blah.json").should_succeed <<EOM /roles/blah.json: { @@ -429,13 +429,13 @@ EOM end end - context 'when there is a directory in users1 and file in users2 with the same name' do + context "when there is a directory in users1 and file in users2 with the same name" do before do - directory 'users/blah.json' - file 'users2/blah.json', {} + directory "users/blah.json" + file "users2/blah.json", {} end - it 'knife show /users/blah.json succeeds' do - knife('show --local /users/blah.json').should_succeed <<EOM + it "knife show /users/blah.json succeeds" do + knife("show --local /users/blah.json").should_succeed <<EOM /users/blah.json: { @@ -444,17 +444,17 @@ EOM end end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag2/ @@ -463,10 +463,10 @@ EOM end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client2.json @@ -496,10 +496,10 @@ EOM end end - context 'when cwd is inside data_bags2' do - before { cwd 'data_bags2' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside data_bags2" do + before { cwd "data_bags2" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag2/ @@ -509,21 +509,21 @@ EOM end end - context 'when when chef_repo_path is set to both places and no other _path is set' do + context "when when chef_repo_path is set to both places and no other _path is set" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end Chef::Config.chef_repo_path = [ Chef::Config.chef_repo_path, - File.join(Chef::Config.chef_repo_path, 'chef_repo2'), + File.join(Chef::Config.chef_repo_path, "chef_repo2"), ] end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client3.json @@ -553,10 +553,10 @@ EOM end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag3/ @@ -565,10 +565,10 @@ EOM end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client3.json @@ -598,10 +598,10 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag3/ @@ -611,33 +611,33 @@ EOM end end - context 'when cookbook_path is set and nothing else' do + context "when cookbook_path is set and nothing else" do before :each do %w(client data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end Chef::Config.delete(:chef_repo_path) - Chef::Config.cookbook_path = File.join(@repository_dir, 'chef_repo2', 'cookbooks') + Chef::Config.cookbook_path = File.join(@repository_dir, "chef_repo2", "cookbooks") end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client3.json cookbooks/ @@ -658,10 +658,10 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag3/ bag3/item3.json EOM @@ -669,22 +669,22 @@ EOM end end - context 'when cookbook_path is set to multiple places and nothing else is set' do + context "when cookbook_path is set to multiple places and nothing else is set" do before :each do %w(client data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end Chef::Config.delete(:chef_repo_path) Chef::Config.cookbook_path = [ - File.join(@repository_dir, 'cookbooks'), - File.join(@repository_dir, 'chef_repo2', 'cookbooks'), + File.join(@repository_dir, "cookbooks"), + File.join(@repository_dir, "chef_repo2", "cookbooks"), ] end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client3.json @@ -714,10 +714,10 @@ EOM end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag3/ @@ -726,10 +726,10 @@ EOM end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client3.json @@ -759,10 +759,10 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag3/ @@ -772,36 +772,36 @@ EOM end end - context 'when data_bag_path and chef_repo_path are set, and nothing else' do + context "when data_bag_path and chef_repo_path are set, and nothing else" do before :each do %w(client cookbook environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end - Chef::Config.data_bag_path = File.join(Chef::Config.chef_repo_path, 'data_bags') - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2') + Chef::Config.data_bag_path = File.join(Chef::Config.chef_repo_path, "data_bags") + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "chef_repo2") end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json EOM end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client3.json cookbooks/ @@ -822,15 +822,15 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end end - context 'when data_bag_path is set and nothing else' do + context "when data_bag_path is set and nothing else" do include_context "default config options" before :each do @@ -838,28 +838,28 @@ EOM Chef::Config.delete("#{object_name}_path".to_sym) end Chef::Config.delete(:chef_repo_path) - Chef::Config.data_bag_path = File.join(@repository_dir, 'data_bags') + Chef::Config.data_bag_path = File.join(@repository_dir, "data_bags") end - it 'knife list --local -Rfp / lists data bags' do - knife('list --local -Rfp /').should_succeed <<EOM + it "knife list --local -Rfp / lists data bags" do + knife("list --local -Rfp /").should_succeed <<EOM /data_bags/ /data_bags/bag/ /data_bags/bag/item.json EOM end - it 'knife list --local -Rfp /data_bags lists data bags' do - knife('list --local -Rfp /data_bags').should_succeed <<EOM + it "knife list --local -Rfp /data_bags lists data bags" do + knife("list --local -Rfp /data_bags").should_succeed <<EOM /data_bags/bag/ /data_bags/bag/item.json EOM end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json EOM @@ -868,21 +868,21 @@ EOM end end - when_the_repository 'is empty' do - context 'when the repository _paths point to places that do not exist' do + when_the_repository "is empty" do + context "when the repository _paths point to places that do not exist" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| - Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, 'nowhere', object_name) + Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, "nowhere", object_name) end - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'nowhere') + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "nowhere") end - it 'knife list --local -Rfp / fails' do - knife('list --local -Rfp /').should_succeed '' + it "knife list --local -Rfp / fails" do + knife("list --local -Rfp /").should_succeed "" end - it 'knife list --local -Rfp /data_bags fails' do - knife('list --local -Rfp /data_bags').should_fail("ERROR: /data_bags: No such file or directory\n") + it "knife list --local -Rfp /data_bags fails" do + knife("list --local -Rfp /data_bags").should_fail("ERROR: /data_bags: No such file or directory\n") end end end diff --git a/spec/integration/knife/chef_repository_file_system_spec.rb b/spec/integration/knife/chef_repository_file_system_spec.rb index 34afd228f3..dc33d299e1 100644 --- a/spec/integration/knife/chef_repository_file_system_spec.rb +++ b/spec/integration/knife/chef_repository_file_system_spec.rb @@ -15,15 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/list' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "chef/knife/list" +require "chef/knife/show" -describe 'General chef_repo file system checks', :workstation do +describe "General chef_repo file system checks", :workstation do include IntegrationSupport include KnifeSupport - context 'directories and files that should/should not be ignored' do + context "directories and files that should/should not be ignored" do when_the_repository "has empty roles, environments and data bag item directories" do before do directory "roles" @@ -32,7 +32,7 @@ describe 'General chef_repo file system checks', :workstation do end it "knife list --local -Rfp / returns them" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /data_bags/ /data_bags/bag1/ /environments/ @@ -45,25 +45,25 @@ EOM before { directory "data_bags" } it "knife list --local / returns it" do - knife('list --local /').should_succeed "/data_bags\n" + knife("list --local /").should_succeed "/data_bags\n" end end when_the_repository "has an empty cookbook directory" do - before { directory 'cookbooks/cookbook1' } + before { directory "cookbooks/cookbook1" } it "knife list --local -Rfp / does not return it" do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end end when_the_repository "has only empty cookbook subdirectories" do - before { directory 'cookbooks/cookbook1/recipes' } + before { directory "cookbooks/cookbook1/recipes" } it "knife list --local -Rfp / does not return it" do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -71,12 +71,12 @@ EOM when_the_repository "has empty and non-empty cookbook subdirectories" do before do - directory 'cookbooks/cookbook1/recipes' - file 'cookbooks/cookbook1/templates/default/x.txt', '' + directory "cookbooks/cookbook1/recipes" + file "cookbooks/cookbook1/templates/default/x.txt", "" end it "knife list --local -Rfp / does not return the empty ones" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/templates/ @@ -87,10 +87,10 @@ EOM end when_the_repository "has only empty cookbook sub-sub-directories" do - before { directory 'cookbooks/cookbook1/templates/default' } + before { directory "cookbooks/cookbook1/templates/default" } it "knife list --local -Rfp / does not return it" do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -98,13 +98,13 @@ EOM when_the_repository "has empty cookbook sub-sub-directories alongside non-empty ones" do before do - file 'cookbooks/cookbook1/templates/default/x.txt', '' - directory 'cookbooks/cookbook1/templates/rhel' - directory 'cookbooks/cookbook1/files/default' + file "cookbooks/cookbook1/templates/default/x.txt", "" + directory "cookbooks/cookbook1/templates/rhel" + directory "cookbooks/cookbook1/files/default" end it "knife list --local -Rfp / does not return the empty ones" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/templates/ @@ -122,7 +122,7 @@ EOM end it "knife list --local -Rfp / should NOT return it" do - knife('list --local -Rfp /').should_succeed "" + knife("list --local -Rfp /").should_succeed "" end end @@ -146,7 +146,7 @@ EOM end it "knife list --local -Rfp / should NOT return them" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /data_bags/ /data_bags/bag1/ /data_bags/bag1/item1.json @@ -160,62 +160,62 @@ EOM when_the_repository "has extraneous subdirectories and files under a cookbook" do before do - directory 'cookbooks/cookbook1' do - file 'a.rb', '' - file 'blarghle/blah.rb', '' - directory 'attributes' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "cookbooks/cookbook1" do + file "a.rb", "" + file "blarghle/blah.rb", "" + directory "attributes" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'definitions' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "definitions" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'recipes' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "recipes" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'libraries' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "libraries" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'templates' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "templates" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'files' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "files" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'resources' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "resources" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'providers' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "providers" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end end end it "knife list --local -Rfp / should NOT return them" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/a.rb @@ -252,41 +252,41 @@ EOM end when_the_repository "has a file in cookbooks/" do - before { file 'cookbooks/file', '' } - it 'does not show up in list -Rfp' do - knife('list --local -Rfp /').should_succeed <<EOM + before { file "cookbooks/file", "" } + it "does not show up in list -Rfp" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ EOM end end when_the_repository "has a file in data_bags/" do - before { file 'data_bags/file', '' } - it 'does not show up in list -Rfp' do - knife('list --local -Rfp /').should_succeed <<EOM + before { file "data_bags/file", "" } + it "does not show up in list -Rfp" do + knife("list --local -Rfp /").should_succeed <<EOM /data_bags/ EOM end end end - when_the_repository 'has a cookbook starting with .' do + when_the_repository "has a cookbook starting with ." do before do - file 'cookbooks/.svn/metadata.rb', '' - file 'cookbooks/a.b/metadata.rb', '' + file "cookbooks/.svn/metadata.rb", "" + file "cookbooks/a.b/metadata.rb", "" end - it 'knife list does not show it' do - knife('list --local -fp /cookbooks').should_succeed "/cookbooks/a.b/\n" + it "knife list does not show it" do + knife("list --local -fp /cookbooks").should_succeed "/cookbooks/a.b/\n" end end - when_the_repository 'has a data bag starting with .' do + when_the_repository "has a data bag starting with ." do before do - file 'data_bags/.svn/x.json', {} - file 'data_bags/a.b/x.json', {} + file "data_bags/.svn/x.json", {} + file "data_bags/a.b/x.json", {} end - it 'knife list does not show it' do - knife('list --local -fp /data_bags').should_succeed "/data_bags/a.b/\n" + it "knife list does not show it" do + knife("list --local -fp /data_bags").should_succeed "/data_bags/a.b/\n" end end end diff --git a/spec/integration/knife/chefignore_spec.rb b/spec/integration/knife/chefignore_spec.rb index 10cfbbf557..3ffd0453e8 100644 --- a/spec/integration/knife/chefignore_spec.rb +++ b/spec/integration/knife/chefignore_spec.rb @@ -15,37 +15,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/list' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "chef/knife/list" +require "chef/knife/show" -describe 'chefignore tests', :workstation do +describe "chefignore tests", :workstation do include IntegrationSupport include KnifeSupport when_the_repository "has lots of stuff in it" do before do - file 'roles/x.json', {} - file 'environments/x.json', {} - file 'data_bags/bag1/x.json', {} - file 'cookbooks/cookbook1/x.json', {} + file "roles/x.json", {} + file "environments/x.json", {} + file "data_bags/bag1/x.json", {} + file "cookbooks/cookbook1/x.json", {} end context "and has a chefignore everywhere except cookbooks" do before do chefignore = "x.json\nroles/x.json\nenvironments/x.json\ndata_bags/bag1/x.json\nbag1/x.json\ncookbooks/cookbook1/x.json\ncookbook1/x.json\n" - file 'chefignore', chefignore - file 'roles/chefignore', chefignore - file 'environments/chefignore', chefignore - file 'data_bags/chefignore', chefignore - file 'data_bags/bag1/chefignore', chefignore - file 'cookbooks/cookbook1/chefignore', chefignore + file "chefignore", chefignore + file "roles/chefignore", chefignore + file "environments/chefignore", chefignore + file "data_bags/chefignore", chefignore + file "data_bags/bag1/chefignore", chefignore + file "cookbooks/cookbook1/chefignore", chefignore end - it 'matching files and directories get ignored' do + it "matching files and directories get ignored" do # NOTE: many of the "chefignore" files should probably not show up # themselves, but we have other tests that talk about that - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/chefignore @@ -61,15 +61,15 @@ EOM end end - when_the_repository 'has a cookbook with only chefignored files' do + when_the_repository "has a cookbook with only chefignored files" do before do - file 'cookbooks/cookbook1/templates/default/x.rb', '' - file 'cookbooks/cookbook1/libraries/x.rb', '' - file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n" + file "cookbooks/cookbook1/templates/default/x.rb", "" + file "cookbooks/cookbook1/libraries/x.rb", "" + file "cookbooks/chefignore", "libraries/x.rb\ntemplates/default/x.rb\n" end - it 'the cookbook is not listed' do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + it "the cookbook is not listed" do + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -77,17 +77,17 @@ EOM when_the_repository "has multiple cookbooks" do before do - file 'cookbooks/cookbook1/x.json', {} - file 'cookbooks/cookbook1/y.json', {} - file 'cookbooks/cookbook2/x.json', {} - file 'cookbooks/cookbook2/y.json', {} + file "cookbooks/cookbook1/x.json", {} + file "cookbooks/cookbook1/y.json", {} + file "cookbooks/cookbook2/x.json", {} + file "cookbooks/cookbook2/y.json", {} end - context 'and has a chefignore with filenames' do - before { file 'cookbooks/chefignore', "x.json\n" } + context "and has a chefignore with filenames" do + before { file "cookbooks/chefignore", "x.json\n" } - it 'matching files and directories get ignored in all cookbooks' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching files and directories get ignored in all cookbooks" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/y.json @@ -99,12 +99,12 @@ EOM context "and has a chefignore with wildcards" do before do - file 'cookbooks/chefignore', "x.*\n" - file 'cookbooks/cookbook1/x.rb', '' + file "cookbooks/chefignore", "x.*\n" + file "cookbooks/cookbook1/x.rb", "" end - it 'matching files and directories get ignored in all cookbooks' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching files and directories get ignored in all cookbooks" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/y.json @@ -116,13 +116,13 @@ EOM context "and has a chefignore with relative paths" do before do - file 'cookbooks/cookbook1/recipes/x.rb', '' - file 'cookbooks/cookbook2/recipes/y.rb', '' - file 'cookbooks/chefignore', "recipes/x.rb\n" + file "cookbooks/cookbook1/recipes/x.rb", "" + file "cookbooks/cookbook2/recipes/y.rb", "" + file "cookbooks/chefignore", "recipes/x.rb\n" end - it 'matching directories get ignored' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching directories get ignored" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/x.json @@ -138,12 +138,12 @@ EOM context "and has a chefignore with subdirectories" do before do - file 'cookbooks/cookbook1/recipes/y.rb', '' - file 'cookbooks/chefignore', "recipes\nrecipes/\n" + file "cookbooks/cookbook1/recipes/y.rb", "" + file "cookbooks/chefignore", "recipes\nrecipes/\n" end - it 'matching directories do NOT get ignored' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching directories do NOT get ignored" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/recipes/ @@ -159,13 +159,13 @@ EOM context "and has a chefignore that ignores all files in a subdirectory" do before do - file 'cookbooks/cookbook1/templates/default/x.rb', '' - file 'cookbooks/cookbook1/libraries/x.rb', '' - file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n" + file "cookbooks/cookbook1/templates/default/x.rb", "" + file "cookbooks/cookbook1/libraries/x.rb", "" + file "cookbooks/chefignore", "libraries/x.rb\ntemplates/default/x.rb\n" end - it 'ignores the subdirectory entirely' do - knife('list --local -Rfp /').should_succeed <<EOM + it "ignores the subdirectory entirely" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/x.json @@ -179,11 +179,11 @@ EOM context "and has an empty chefignore" do before do - file 'cookbooks/chefignore', "\n" + file "cookbooks/chefignore", "\n" end - it 'nothing is ignored' do - knife('list --local -Rfp /').should_succeed <<EOM + it "nothing is ignored" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/x.json @@ -197,11 +197,11 @@ EOM context "and has a chefignore with comments and empty lines" do before do - file 'cookbooks/chefignore', "\n\n # blah\n#\nx.json\n\n" + file "cookbooks/chefignore", "\n\n # blah\n#\nx.json\n\n" end - it 'matching files and directories get ignored in all cookbooks' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching files and directories get ignored in all cookbooks" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/y.json @@ -215,25 +215,25 @@ EOM when_the_repository "has multiple cookbook paths" do before :each do Chef::Config.cookbook_path = [ - File.join(Chef::Config.chef_repo_path, 'cookbooks1'), - File.join(Chef::Config.chef_repo_path, 'cookbooks2'), + File.join(Chef::Config.chef_repo_path, "cookbooks1"), + File.join(Chef::Config.chef_repo_path, "cookbooks2"), ] end before do - file 'cookbooks1/mycookbook/metadata.rb', '' - file 'cookbooks1/mycookbook/x.json', {} - file 'cookbooks2/yourcookbook/metadata.rb', '' - file 'cookbooks2/yourcookbook/x.json', '' + file "cookbooks1/mycookbook/metadata.rb", "" + file "cookbooks1/mycookbook/x.json", {} + file "cookbooks2/yourcookbook/metadata.rb", "" + file "cookbooks2/yourcookbook/x.json", "" end context "and multiple chefignores" do before do - file 'cookbooks1/chefignore', "metadata.rb\n" - file 'cookbooks2/chefignore', "x.json\n" + file "cookbooks1/chefignore", "metadata.rb\n" + file "cookbooks2/chefignore", "x.json\n" end it "chefignores apply only to the directories they are in" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/mycookbook/ /cookbooks/mycookbook/x.json @@ -244,14 +244,14 @@ EOM context "and conflicting cookbooks" do before do - file 'cookbooks1/yourcookbook/metadata.rb', '' - file 'cookbooks1/yourcookbook/x.json', '' - file 'cookbooks1/yourcookbook/onlyincookbooks1.rb', '' - file 'cookbooks2/yourcookbook/onlyincookbooks2.rb', '' + file "cookbooks1/yourcookbook/metadata.rb", "" + file "cookbooks1/yourcookbook/x.json", "" + file "cookbooks1/yourcookbook/onlyincookbooks1.rb", "" + file "cookbooks2/yourcookbook/onlyincookbooks2.rb", "" end it "chefignores apply only to the winning cookbook" do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n") + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n") /cookbooks/ /cookbooks/mycookbook/ /cookbooks/mycookbook/x.json @@ -264,32 +264,32 @@ EOM end end - when_the_repository 'has a cookbook named chefignore' do + when_the_repository "has a cookbook named chefignore" do before do - file 'cookbooks/chefignore/metadata.rb', {} + file "cookbooks/chefignore/metadata.rb", {} end - it 'knife list -Rfp /cookbooks shows it' do - knife('list --local -Rfp /cookbooks').should_succeed <<EOM + it "knife list -Rfp /cookbooks shows it" do + knife("list --local -Rfp /cookbooks").should_succeed <<EOM /cookbooks/chefignore/ /cookbooks/chefignore/metadata.rb EOM end end - when_the_repository 'has multiple cookbook paths, one with a chefignore file and the other with a cookbook named chefignore' do + when_the_repository "has multiple cookbook paths, one with a chefignore file and the other with a cookbook named chefignore" do before do - file 'cookbooks1/chefignore', '' - file 'cookbooks1/blah/metadata.rb', '' - file 'cookbooks2/chefignore/metadata.rb', '' + file "cookbooks1/chefignore", "" + file "cookbooks1/blah/metadata.rb", "" + file "cookbooks2/chefignore/metadata.rb", "" end before :each do Chef::Config.cookbook_path = [ - File.join(Chef::Config.chef_repo_path, 'cookbooks1'), - File.join(Chef::Config.chef_repo_path, 'cookbooks2'), + File.join(Chef::Config.chef_repo_path, "cookbooks1"), + File.join(Chef::Config.chef_repo_path, "cookbooks2"), ] end - it 'knife list -Rfp /cookbooks shows the chefignore cookbook' do - knife('list --local -Rfp /cookbooks').should_succeed <<EOM + it "knife list -Rfp /cookbooks shows the chefignore cookbook" do + knife("list --local -Rfp /cookbooks").should_succeed <<EOM /cookbooks/blah/ /cookbooks/blah/metadata.rb /cookbooks/chefignore/ diff --git a/spec/integration/knife/common_options_spec.rb b/spec/integration/knife/common_options_spec.rb index b2e2e3fc2a..0c287580db 100644 --- a/spec/integration/knife/common_options_spec.rb +++ b/spec/integration/knife/common_options_spec.rb @@ -15,46 +15,46 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/raw' +require "support/shared/integration/integration_helper" +require "chef/knife/raw" -describe 'knife common options', :workstation do +describe "knife common options", :workstation do include IntegrationSupport include KnifeSupport when_the_repository "has a node" do - before { file 'nodes/x.json', {} } + before { file "nodes/x.json", {} } - context 'When chef_zero.enabled is true' do + context "When chef_zero.enabled is true" do before(:each) do Chef::Config.chef_zero.enabled = true end - it 'knife raw /nodes/x should retrieve the node' do - knife('raw /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw /nodes/x should retrieve the node" do + knife("raw /nodes/x").should_succeed( /"name": "x"/ ) end - context 'And chef_zero.port is 9999' do + context "And chef_zero.port is 9999" do before(:each) { Chef::Config.chef_zero.port = 9999 } - it 'knife raw /nodes/x should retrieve the node' do - knife('raw /nodes/x').should_succeed( /"name": "x"/ ) - expect(Chef::Config.chef_server_url).to eq('chefzero://localhost:9999') + it "knife raw /nodes/x should retrieve the node" do + knife("raw /nodes/x").should_succeed( /"name": "x"/ ) + expect(Chef::Config.chef_server_url).to eq("chefzero://localhost:9999") end end # 0.0.0.0 is not a valid address to bind to on windows. - context 'And chef_zero.host is 0.0.0.0', :unix_only do - before(:each) { Chef::Config.chef_zero.host = '0.0.0.0' } + context "And chef_zero.host is 0.0.0.0", :unix_only do + before(:each) { Chef::Config.chef_zero.host = "0.0.0.0" } - it 'knife raw /nodes/x should retrieve the role' do - knife('raw /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw /nodes/x should retrieve the role" do + knife("raw /nodes/x").should_succeed( /"name": "x"/ ) end end - context 'and there is a private key' do + context "and there is a private key" do before do - file 'mykey.pem', <<EOM + file "mykey.pem", <<EOM -----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk @@ -85,29 +85,29 @@ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T EOM end - it 'knife raw /nodes/x should retrieve the node' do - knife('raw /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw /nodes/x should retrieve the node" do + knife("raw /nodes/x").should_succeed( /"name": "x"/ ) end end end - it 'knife raw -z /nodes/x retrieves the node' do - knife('raw -z /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw -z /nodes/x retrieves the node" do + knife("raw -z /nodes/x").should_succeed( /"name": "x"/ ) end - it 'knife raw --local-mode /nodes/x retrieves the node' do - knife('raw --local-mode /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw --local-mode /nodes/x retrieves the node" do + knife("raw --local-mode /nodes/x").should_succeed( /"name": "x"/ ) end - it 'knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node' do - knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed( /"name": "x"/ ) - expect(Chef::Config.chef_server_url).to eq('chefzero://localhost:9999') + it "knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node" do + knife("raw -z --chef-zero-port=9999 /nodes/x").should_succeed( /"name": "x"/ ) + expect(Chef::Config.chef_server_url).to eq("chefzero://localhost:9999") end - context 'when the default port (8889) is already bound' do + context "when the default port (8889) is already bound" do before :each do begin - @server = ChefZero::Server.new(:host => 'localhost', :port => 8889) + @server = ChefZero::Server.new(:host => "localhost", :port => 8889) @server.start_background rescue Errno::EADDRINUSE # OK. Don't care who has it in use, as long as *someone* does. @@ -117,16 +117,16 @@ EOM @server.stop if @server end - it 'knife raw -z /nodes/x retrieves the node' do - knife('raw -z /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw -z /nodes/x retrieves the node" do + knife("raw -z /nodes/x").should_succeed( /"name": "x"/ ) expect(URI(Chef::Config.chef_server_url).port).to be > 8889 end end - context 'when port 9999 is already bound' do + context "when port 9999 is already bound" do before :each do begin - @server = ChefZero::Server.new(:host => 'localhost', :port => 9999) + @server = ChefZero::Server.new(:host => "localhost", :port => 9999) @server.start_background rescue Errno::EADDRINUSE # OK. Don't care who has it in use, as long as *someone* does. @@ -136,20 +136,20 @@ EOM @server.stop if @server end - it 'knife raw -z --chef-zero-port=9999-20000 /nodes/x' do - knife('raw -z --chef-zero-port=9999-20000 /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw -z --chef-zero-port=9999-20000 /nodes/x" do + knife("raw -z --chef-zero-port=9999-20000 /nodes/x").should_succeed( /"name": "x"/ ) expect(URI(Chef::Config.chef_server_url).port).to be > 9999 end - it 'knife raw -z --chef-zero-port=9999-9999,19423' do - knife('raw -z --chef-zero-port=9999-9999,19423 /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw -z --chef-zero-port=9999-9999,19423" do + knife("raw -z --chef-zero-port=9999-9999,19423 /nodes/x").should_succeed( /"name": "x"/ ) expect(URI(Chef::Config.chef_server_url).port).to be == 19423 end end - it 'knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node' do - knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed( /"name": "x"/ ) - expect(Chef::Config.chef_server_url).to eq('chefzero://localhost:9999') + it "knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node" do + knife("raw -z --chef-zero-port=9999 /nodes/x").should_succeed( /"name": "x"/ ) + expect(Chef::Config.chef_server_url).to eq("chefzero://localhost:9999") end end end diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb index 4b44c87fc1..3033c4cf4a 100644 --- a/spec/integration/knife/cookbook_api_ipv6_spec.rb +++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/mixin/shell_out' +require "support/shared/integration/integration_helper" +require "chef/mixin/shell_out" describe "Knife cookbook API integration with IPv6", :workstation, :not_supported_on_gce do include IntegrationSupport @@ -84,8 +84,8 @@ END_CLIENT_RB end before do - file 'config/knife.rb', knife_rb_content - file 'config/knifeuser.pem', client_key + file "config/knife.rb", knife_rb_content + file "config/knifeuser.pem", client_key end it "successfully uploads a cookbook" do diff --git a/spec/integration/knife/delete_spec.rb b/spec/integration/knife/delete_spec.rb index 384f06cf83..3a1a93fb51 100644 --- a/spec/integration/knife/delete_spec.rb +++ b/spec/integration/knife/delete_spec.rb @@ -15,12 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/delete' -require 'chef/knife/list' -require 'chef/knife/raw' +require "support/shared/integration/integration_helper" +require "chef/knife/delete" +require "chef/knife/list" +require "chef/knife/raw" -describe 'knife delete', :workstation do +describe "knife delete", :workstation do include IntegrationSupport include KnifeSupport @@ -100,39 +100,39 @@ EOM when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - when_the_repository 'also has one of each thing' do + when_the_repository "also has one of each thing" do before do - file 'clients/x.json', {} - file 'cookbooks/x/metadata.rb', '' - file 'data_bags/x/y.json', {} - file 'environments/_default.json', {} - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/x.json', {} - end - - it 'knife delete --both /cookbooks/x fails' do - knife('delete --both /cookbooks/x').should_fail <<EOM + file "clients/x.json", {} + file "cookbooks/x/metadata.rb", "" + file "data_bags/x/y.json", {} + file "environments/_default.json", {} + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/x.json", {} + end + + it "knife delete --both /cookbooks/x fails" do + knife("delete --both /cookbooks/x").should_fail <<EOM ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /cookbooks/x deletes x' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both -r /cookbooks/x deletes x" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -152,7 +152,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -171,10 +171,10 @@ EOM EOM end - it 'knife delete -r --local /cookbooks/x deletes x locally but not remotely' do - knife('delete -r --local /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete -r --local /cookbooks/x deletes x locally but not remotely" do + knife("delete -r --local /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -193,9 +193,9 @@ EOM EOM end - it 'knife delete -r /cookbooks/x deletes x remotely but not locally' do - knife('delete -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete -r /cookbooks/x deletes x remotely but not locally" do + knife("delete -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -215,22 +215,22 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed everything + knife("list -Rf --local /").should_succeed everything end # TODO delete empty data bag (particularly different on local side) - context 'with an empty data bag on both' do + context "with an empty data bag on both" do before do - data_bag 'empty', {} - directory 'data_bags/empty' + data_bag "empty", {} + directory "data_bags/empty" end - it 'knife delete --both /data_bags/empty fails but deletes local version' do - knife('delete --both /data_bags/empty').should_fail <<EOM + it "knife delete --both /data_bags/empty fails but deletes local version" do + knife("delete --both /data_bags/empty").should_fail <<EOM ERROR: /data_bags/empty (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /data_bags/empty (local) must be deleted recursively! Pass -r to knife delete. EOM - knife('list -Rf /').should_succeed <<EOM + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -253,7 +253,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -276,18 +276,18 @@ EOM end end - it 'knife delete --both /data_bags/x fails' do - knife('delete --both /data_bags/x').should_fail <<EOM + it "knife delete --both /data_bags/x fails" do + knife("delete --both /data_bags/x").should_fail <<EOM ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /data_bags/x deletes x' do - knife('delete --both -r /data_bags/x').should_succeed "Deleted /data_bags/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both -r /data_bags/x deletes x" do + knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -307,7 +307,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -326,9 +326,9 @@ EOM EOM end - it 'knife delete --both /environments/x.json deletes x' do - knife('delete --both /environments/x.json').should_succeed "Deleted /environments/x.json\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both /environments/x.json deletes x" do + knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -349,7 +349,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -369,9 +369,9 @@ EOM EOM end - it 'knife delete --both /roles/x.json deletes x' do - knife('delete --both /roles/x.json').should_succeed "Deleted /roles/x.json\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both /roles/x.json deletes x" do + knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -392,7 +392,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -412,10 +412,10 @@ EOM EOM end - it 'knife delete --both /environments/_default.json fails but still deletes the local copy' do - knife('delete --both /environments/_default.json').should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both /environments/_default.json fails but still deletes the local copy" do + knife("delete --both /environments/_default.json").should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -435,23 +435,23 @@ EOM EOM end - it 'knife delete --both /environments/nonexistent.json fails' do - knife('delete --both /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + it "knife delete --both /environments/nonexistent.json fails" do + knife("delete --both /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both / fails' do - knife('delete --both /').should_fail <<EOM + it "knife delete --both / fails" do + knife("delete --both /").should_fail <<EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /* fails' do - knife('delete --both -r /*').should_fail <<EOM + it "knife delete --both -r /* fails" do + knife("delete --both -r /*").should_fail <<EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. ERROR: /clients (remote) cannot be deleted. @@ -469,31 +469,31 @@ ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife delete --both /cookbooks/x fails' do - knife('delete --both /cookbooks/x').should_fail "ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete.\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both /cookbooks/x fails" do + knife("delete --both /cookbooks/x").should_fail "ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete.\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both -r /cookbooks/x deletes x' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both -r /cookbooks/x deletes x" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -513,18 +513,18 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /data_bags/x fails' do - knife('delete --both /data_bags/x').should_fail "ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete.\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both /data_bags/x fails" do + knife("delete --both /data_bags/x").should_fail "ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete.\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both -r /data_bags/x deletes x' do - knife('delete --both -r /data_bags/x').should_succeed "Deleted /data_bags/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both -r /data_bags/x deletes x" do + knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -544,12 +544,12 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /environments/x.json deletes x' do - knife('delete --both /environments/x.json').should_succeed "Deleted /environments/x.json\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both /environments/x.json deletes x" do + knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -570,12 +570,12 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /roles/x.json deletes x' do - knife('delete --both /roles/x.json').should_succeed "Deleted /roles/x.json\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both /roles/x.json deletes x" do + knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -596,23 +596,23 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /environments/_default.json fails' do - knife('delete --both /environments/_default.json').should_fail "", :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both /environments/_default.json fails" do + knife("delete --both /environments/_default.json").should_fail "", :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both / fails' do - knife('delete --both /').should_fail "ERROR: / (remote) cannot be deleted.\nERROR: / (local) cannot be deleted.\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both / fails" do + knife("delete --both /").should_fail "ERROR: / (remote) cannot be deleted.\nERROR: / (local) cannot be deleted.\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both -r /* fails' do - knife('delete --both -r /*').should_fail <<EOM + it "knife delete --both -r /* fails" do + knife("delete --both -r /*").should_fail <<EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. ERROR: /clients (remote) cannot be deleted. @@ -630,21 +630,21 @@ ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /environments/nonexistent.json fails' do - knife('delete --both /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both /environments/nonexistent.json fails" do + knife("delete --both /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - context 'and cwd is at the top level' do - before { cwd '.' } - it 'knife delete fails' do - knife('delete').should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/ - knife('list -Rf /').should_succeed <<EOM + context "and cwd is at the top level" do + before { cwd "." } + it "knife delete fails" do + knife("delete").should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/ + knife("list -Rf /").should_succeed <<EOM clients clients/chef-validator.json clients/chef-webui.json @@ -666,7 +666,7 @@ users users/admin.json users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM clients cookbooks data_bags @@ -680,29 +680,29 @@ EOM end end - when_the_chef_server 'is empty' do - when_the_repository 'has one of each thing' do + when_the_chef_server "is empty" do + when_the_repository "has one of each thing" do before do - file 'clients/x.json', {} - file 'cookbooks/x/metadata.rb', '' - file 'data_bags/x/y.json', {} - file 'environments/_default.json', {} - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/x.json', {} - end - - it 'knife delete --both /cookbooks/x fails' do - knife('delete --both /cookbooks/x').should_fail "ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete.\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything - end - - it 'knife delete --both -r /cookbooks/x deletes x' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + file "clients/x.json", {} + file "cookbooks/x/metadata.rb", "" + file "data_bags/x/y.json", {} + file "environments/_default.json", {} + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/x.json", {} + end + + it "knife delete --both /cookbooks/x fails" do + knife("delete --both /cookbooks/x").should_fail "ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete.\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything + end + + it "knife delete --both -r /cookbooks/x deletes x" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -721,16 +721,16 @@ EOM EOM end - it 'knife delete --both /data_bags/x fails' do - knife('delete --both /data_bags/x').should_fail "ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete.\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything + it "knife delete --both /data_bags/x fails" do + knife("delete --both /data_bags/x").should_fail "ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete.\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /data_bags/x deletes x' do - knife('delete --both -r /data_bags/x').should_succeed "Deleted /data_bags/x\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both -r /data_bags/x deletes x" do + knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -749,10 +749,10 @@ EOM EOM end - it 'knife delete --both /environments/x.json deletes x' do - knife('delete --both /environments/x.json').should_succeed "Deleted /environments/x.json\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both /environments/x.json deletes x" do + knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -772,10 +772,10 @@ EOM EOM end - it 'knife delete --both /roles/x.json deletes x' do - knife('delete --both /roles/x.json').should_succeed "Deleted /roles/x.json\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both /roles/x.json deletes x" do + knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -795,10 +795,10 @@ EOM EOM end - it 'knife delete --both /environments/_default.json fails but still deletes the local copy' do - knife('delete --both /environments/_default.json').should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both /environments/_default.json fails but still deletes the local copy" do + knife("delete --both /environments/_default.json").should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -818,14 +818,14 @@ EOM EOM end - it 'knife delete --both / fails' do - knife('delete --both /').should_fail "ERROR: / (remote) cannot be deleted.\nERROR: / (local) cannot be deleted.\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything + it "knife delete --both / fails" do + knife("delete --both /").should_fail "ERROR: / (remote) cannot be deleted.\nERROR: / (local) cannot be deleted.\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /* fails' do - knife('delete --both -r /*').should_fail <<EOM + it "knife delete --both -r /* fails" do + knife("delete --both -r /*").should_fail <<EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. ERROR: /clients (remote) cannot be deleted. @@ -843,21 +843,21 @@ ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. EOM - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both /environments/nonexistent.json fails' do - knife('delete --both /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything + it "knife delete --both /environments/nonexistent.json fails" do + knife("delete --both /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything end - context 'and cwd is at the top level' do - before { cwd '.' } - it 'knife delete fails' do - knife('delete').should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/ - knife('list -Rf /').should_succeed <<EOM + context "and cwd is at the top level" do + before { cwd "." } + it "knife delete fails" do + knife("delete").should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/ + knife("list -Rf /").should_succeed <<EOM clients clients/chef-validator.json clients/chef-webui.json @@ -870,7 +870,7 @@ roles users users/admin.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM clients clients/x.json cookbooks @@ -894,124 +894,124 @@ EOM end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', 'version "1.0.0"' - file 'cookbooks/x/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x/metadata.rb", 'version "1.0.0"' + file "cookbooks/x/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end # TODO this seems wrong - it 'knife delete --both -r /cookbooks/x deletes the latest version on the server and the local version' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_succeed(/1.0.0/) - knife('list --local /cookbooks').should_succeed '' + it "knife delete --both -r /cookbooks/x deletes the latest version on the server and the local version" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_succeed(/1.0.0/) + knife("list --local /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife delete --both /cookbooks/x deletes the latest version on the server and the local version' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_succeed(/0.9.9/) - knife('list --local /cookbooks').should_succeed '' + it "knife delete --both /cookbooks/x deletes the latest version on the server and the local version" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_succeed(/0.9.9/) + knife("list --local /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do - before { cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } } + when_the_chef_server "has a later version for the cookbook, and no current version" do + before { cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } } - it 'knife delete --both /cookbooks/x deletes the server and client version of the cookbook' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_fail(/404/) - knife('list --local /cookbooks').should_succeed '' + it "knife delete --both /cookbooks/x deletes the server and client version of the cookbook" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_fail(/404/) + knife("list --local /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do - before { cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } } + when_the_chef_server "has an earlier version for the cookbook, and no current version" do + before { cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } } - it 'knife delete --both /cookbooks/x deletes the server and client version of the cookbook' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_fail(/404/) - knife('list --local /cookbooks').should_succeed '' + it "knife delete --both /cookbooks/x deletes the server and client version of the cookbook" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_fail(/404/) + knife("list --local /cookbooks").should_succeed "" end end end - when_the_repository 'is empty' do - when_the_chef_server 'has two versions of a cookbook' do + when_the_repository "is empty" do + when_the_chef_server "has two versions of a cookbook" do before do - cookbook 'x', '2.0.11' - cookbook 'x', '11.0.0' + cookbook "x", "2.0.11" + cookbook "x", "11.0.0" end - it 'knife delete deletes the latest version' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_succeed( /2.0.11/ ) + it "knife delete deletes the latest version" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_succeed( /2.0.11/ ) end end end when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do before do - organization 'foo' do - container 'x', {} - group 'x', {} - policy 'x', '1.2.3', {} - policy_group 'x', { 'policies' => { 'x' => { 'revision_id' => '1.2.3' } } } + organization "foo" do + container "x", {} + group "x", {} + policy "x", "1.2.3", {} + policy_group "x", { "policies" => { "x" => { "revision_id" => "1.2.3" } } } end end before :each do - Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo') + Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo") end - it 'knife delete /acls/containers/environments.json fails with a reasonable error' do - knife('delete /acls/containers/environments.json').should_fail "ERROR: /acls/containers/environments.json (remote) ACLs cannot be deleted.\n" + it "knife delete /acls/containers/environments.json fails with a reasonable error" do + knife("delete /acls/containers/environments.json").should_fail "ERROR: /acls/containers/environments.json (remote) ACLs cannot be deleted.\n" end - it 'knife delete /containers/x.json succeeds' do - knife('delete /containers/x.json').should_succeed "Deleted /containers/x.json\n" - knife('raw /containers/x.json').should_fail(/404/) + it "knife delete /containers/x.json succeeds" do + knife("delete /containers/x.json").should_succeed "Deleted /containers/x.json\n" + knife("raw /containers/x.json").should_fail(/404/) end - it 'knife delete /groups/x.json succeeds' do - knife('delete /groups/x.json').should_succeed "Deleted /groups/x.json\n" - knife('raw /groups/x.json').should_fail(/404/) + it "knife delete /groups/x.json succeeds" do + knife("delete /groups/x.json").should_succeed "Deleted /groups/x.json\n" + knife("raw /groups/x.json").should_fail(/404/) end - it 'knife delete /policies/x-1.2.3.json succeeds' do - knife('raw /policies/x/revisions/1.2.3').should_succeed "{\n \"name\": \"x\",\n \"revision_id\": \"1.2.3\",\n \"run_list\": [\n\n ],\n \"cookbook_locks\": {\n\n }\n}\n" - knife('delete /policies/x-1.2.3.json').should_succeed "Deleted /policies/x-1.2.3.json\n" - knife('raw /policies/x/revisions/1.2.3').should_fail(/404/) + it "knife delete /policies/x-1.2.3.json succeeds" do + knife("raw /policies/x/revisions/1.2.3").should_succeed "{\n \"name\": \"x\",\n \"revision_id\": \"1.2.3\",\n \"run_list\": [\n\n ],\n \"cookbook_locks\": {\n\n }\n}\n" + knife("delete /policies/x-1.2.3.json").should_succeed "Deleted /policies/x-1.2.3.json\n" + knife("raw /policies/x/revisions/1.2.3").should_fail(/404/) end - it 'knife delete /policy_groups/x.json succeeds' do - knife('raw /policy_groups/x').should_succeed "{\n \"uri\": \"http://127.0.0.1:8900/organizations/foo/policy_groups/x\",\n \"policies\": {\n \"x\": {\n \"revision_id\": \"1.2.3\"\n }\n }\n}\n" - knife('delete /policy_groups/x.json').should_succeed "Deleted /policy_groups/x.json\n" - knife('raw /policy_groups/x').should_fail(/404/) + it "knife delete /policy_groups/x.json succeeds" do + knife("raw /policy_groups/x").should_succeed "{\n \"uri\": \"http://127.0.0.1:8900/organizations/foo/policy_groups/x\",\n \"policies\": {\n \"x\": {\n \"revision_id\": \"1.2.3\"\n }\n }\n}\n" + knife("delete /policy_groups/x.json").should_succeed "Deleted /policy_groups/x.json\n" + knife("raw /policy_groups/x").should_fail(/404/) end - it 'knife delete /org.json fails with a reasonable error' do - knife('delete /org.json').should_fail "ERROR: /org.json (remote) cannot be deleted.\n" + it "knife delete /org.json fails with a reasonable error" do + knife("delete /org.json").should_fail "ERROR: /org.json (remote) cannot be deleted.\n" end - it 'knife delete /invitations.json fails with a reasonable error' do - knife('delete /invitations.json').should_fail "ERROR: /invitations.json (remote) cannot be deleted.\n" + it "knife delete /invitations.json fails with a reasonable error" do + knife("delete /invitations.json").should_fail "ERROR: /invitations.json (remote) cannot be deleted.\n" end - it 'knife delete /members.json fails with a reasonable error' do - knife('delete /members.json').should_fail "ERROR: /members.json (remote) cannot be deleted.\n" + it "knife delete /members.json fails with a reasonable error" do + knife("delete /members.json").should_fail "ERROR: /members.json (remote) cannot be deleted.\n" end end end diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb index 6861913d59..8348c601aa 100644 --- a/spec/integration/knife/deps_spec.rb +++ b/spec/integration/knife/deps_spec.rb @@ -15,33 +15,33 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/deps' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/deps" -describe 'knife deps', :workstation do +describe "knife deps", :workstation do include IntegrationSupport include KnifeSupport - context 'local' do - when_the_repository 'has a role with no run_list' do - before { file 'roles/starring.json', {} } - it 'knife deps reports no dependencies' do - knife('deps /roles/starring.json').should_succeed "/roles/starring.json\n" + context "local" do + when_the_repository "has a role with no run_list" do + before { file "roles/starring.json", {} } + it "knife deps reports no dependencies" do + knife("deps /roles/starring.json").should_succeed "/roles/starring.json\n" end end - when_the_repository 'has a role with a default run_list' do + when_the_repository "has a role with a default run_list" do before do - file 'roles/starring.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - file 'roles/minor.json', {} - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' - file 'cookbooks/soup/metadata.rb', 'name "soup"' - file 'cookbooks/soup/recipes/chicken.rb', '' - end - it 'knife deps reports all dependencies' do - knife('deps /roles/starring.json').should_succeed <<EOM + file "roles/starring.json", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + file "roles/minor.json", {} + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" + file "cookbooks/soup/metadata.rb", 'name "soup"' + file "cookbooks/soup/recipes/chicken.rb", "" + end + it "knife deps reports all dependencies" do + knife("deps /roles/starring.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -50,17 +50,17 @@ EOM end end - when_the_repository 'has a role with an env_run_list' do + when_the_repository "has a role with an env_run_list" do before do - file 'roles/starring.json', { 'env_run_lists' => { 'desert' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } } - file 'roles/minor.json', {} - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' - file 'cookbooks/soup/metadata.rb', 'name "soup"' - file 'cookbooks/soup/recipes/chicken.rb', '' - end - it 'knife deps reports all dependencies' do - knife('deps /roles/starring.json').should_succeed <<EOM + file "roles/starring.json", { "env_run_lists" => { "desert" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } } + file "roles/minor.json", {} + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" + file "cookbooks/soup/metadata.rb", 'name "soup"' + file "cookbooks/soup/recipes/chicken.rb", "" + end + it "knife deps reports all dependencies" do + knife("deps /roles/starring.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -69,32 +69,32 @@ EOM end end - when_the_repository 'has a node with no environment or run_list' do - before { file 'nodes/mort.json', {} } - it 'knife deps reports just the node' do - knife('deps /nodes/mort.json').should_succeed "/nodes/mort.json\n" + when_the_repository "has a node with no environment or run_list" do + before { file "nodes/mort.json", {} } + it "knife deps reports just the node" do + knife("deps /nodes/mort.json").should_succeed "/nodes/mort.json\n" end end - when_the_repository 'has a node with an environment' do + when_the_repository "has a node with an environment" do before do - file 'environments/desert.json', {} - file 'nodes/mort.json', { 'chef_environment' => 'desert' } + file "environments/desert.json", {} + file "nodes/mort.json", { "chef_environment" => "desert" } end - it 'knife deps reports just the node' do - knife('deps /nodes/mort.json').should_succeed "/environments/desert.json\n/nodes/mort.json\n" + it "knife deps reports just the node" do + knife("deps /nodes/mort.json").should_succeed "/environments/desert.json\n/nodes/mort.json\n" end end - when_the_repository 'has a node with roles and recipes in its run_list' do + when_the_repository "has a node with roles and recipes in its run_list" do before do - file 'roles/minor.json', {} - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' - file 'cookbooks/soup/metadata.rb', 'name "soup"' - file 'cookbooks/soup/recipes/chicken.rb', '' - file 'nodes/mort.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - end - it 'knife deps reports just the node' do - knife('deps /nodes/mort.json').should_succeed <<EOM + file "roles/minor.json", {} + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" + file "cookbooks/soup/metadata.rb", 'name "soup"' + file "cookbooks/soup/recipes/chicken.rb", "" + file "nodes/mort.json", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + end + it "knife deps reports just the node" do + knife("deps /nodes/mort.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -102,53 +102,53 @@ EOM EOM end end - when_the_repository 'has a cookbook with no dependencies' do + when_the_repository "has a cookbook with no dependencies" do before do - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" end - it 'knife deps reports just the cookbook' do - knife('deps /cookbooks/quiche').should_succeed "/cookbooks/quiche\n" + it "knife deps reports just the cookbook" do + knife("deps /cookbooks/quiche").should_succeed "/cookbooks/quiche\n" end end - when_the_repository 'has a cookbook with dependencies' do + when_the_repository "has a cookbook with dependencies" do before do - file 'cookbooks/kettle/metadata.rb', 'name "kettle"' - file 'cookbooks/quiche/metadata.rb', 'name "quiche" + file "cookbooks/kettle/metadata.rb", 'name "kettle"' + file "cookbooks/quiche/metadata.rb", 'name "quiche" depends "kettle"' - file 'cookbooks/quiche/recipes/default.rb', '' + file "cookbooks/quiche/recipes/default.rb", "" end - it 'knife deps reports just the cookbook' do - knife('deps /cookbooks/quiche').should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n" + it "knife deps reports just the cookbook" do + knife("deps /cookbooks/quiche").should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n" end end - when_the_repository 'has a data bag' do - before { file 'data_bags/bag/item.json', {} } - it 'knife deps reports just the data bag' do - knife('deps /data_bags/bag/item.json').should_succeed "/data_bags/bag/item.json\n" + when_the_repository "has a data bag" do + before { file "data_bags/bag/item.json", {} } + it "knife deps reports just the data bag" do + knife("deps /data_bags/bag/item.json").should_succeed "/data_bags/bag/item.json\n" end end - when_the_repository 'has an environment' do - before { file 'environments/desert.json', {} } - it 'knife deps reports just the environment' do - knife('deps /environments/desert.json').should_succeed "/environments/desert.json\n" + when_the_repository "has an environment" do + before { file "environments/desert.json", {} } + it "knife deps reports just the environment" do + knife("deps /environments/desert.json").should_succeed "/environments/desert.json\n" end end - when_the_repository 'has a deep dependency tree' do + when_the_repository "has a deep dependency tree" do before do - file 'roles/starring.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - file 'roles/minor.json', {} - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' - file 'cookbooks/soup/metadata.rb', 'name "soup"' - file 'cookbooks/soup/recipes/chicken.rb', '' - file 'environments/desert.json', {} - file 'nodes/mort.json', { 'chef_environment' => 'desert', 'run_list' => [ 'role[starring]' ] } - file 'nodes/bart.json', { 'run_list' => [ 'role[minor]' ] } + file "roles/starring.json", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + file "roles/minor.json", {} + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" + file "cookbooks/soup/metadata.rb", 'name "soup"' + file "cookbooks/soup/recipes/chicken.rb", "" + file "environments/desert.json", {} + file "nodes/mort.json", { "chef_environment" => "desert", "run_list" => [ "role[starring]" ] } + file "nodes/bart.json", { "run_list" => [ "role[minor]" ] } end - it 'knife deps reports all dependencies' do - knife('deps /nodes/mort.json').should_succeed <<EOM + it "knife deps reports all dependencies" do + knife("deps /nodes/mort.json").should_succeed <<EOM /environments/desert.json /roles/minor.json /cookbooks/quiche @@ -157,8 +157,8 @@ depends "kettle"' /nodes/mort.json EOM end - it 'knife deps * reports all dependencies of all things' do - knife('deps /nodes/*').should_succeed <<EOM + it "knife deps * reports all dependencies of all things" do + knife("deps /nodes/*").should_succeed <<EOM /roles/minor.json /nodes/bart.json /environments/desert.json @@ -168,8 +168,8 @@ EOM /nodes/mort.json EOM end - it 'knife deps a b reports all dependencies of a and b' do - knife('deps /nodes/bart.json /nodes/mort.json').should_succeed <<EOM + it "knife deps a b reports all dependencies of a and b" do + knife("deps /nodes/bart.json /nodes/mort.json").should_succeed <<EOM /roles/minor.json /nodes/bart.json /environments/desert.json @@ -179,8 +179,8 @@ EOM /nodes/mort.json EOM end - it 'knife deps --tree /* shows dependencies in a tree' do - knife('deps --tree /nodes/*').should_succeed <<EOM + it "knife deps --tree /* shows dependencies in a tree" do + knife("deps --tree /nodes/*").should_succeed <<EOM /nodes/bart.json /roles/minor.json /nodes/mort.json @@ -191,8 +191,8 @@ EOM /cookbooks/soup EOM end - it 'knife deps --tree --no-recurse shows only the first level of dependencies' do - knife('deps --tree --no-recurse /nodes/*').should_succeed <<EOM + it "knife deps --tree --no-recurse shows only the first level of dependencies" do + knife("deps --tree --no-recurse /nodes/*").should_succeed <<EOM /nodes/bart.json /roles/minor.json /nodes/mort.json @@ -202,49 +202,49 @@ EOM end end - context 'circular dependencies' do - when_the_repository 'has cookbooks with circular dependencies' do + context "circular dependencies" do + when_the_repository "has cookbooks with circular dependencies" do before do - file 'cookbooks/foo/metadata.rb', 'name "foo" + file "cookbooks/foo/metadata.rb", 'name "foo" depends "bar"' - file 'cookbooks/bar/metadata.rb', 'name "bar" + file "cookbooks/bar/metadata.rb", 'name "bar" depends "baz"' - file 'cookbooks/baz/metadata.rb', 'name "baz" + file "cookbooks/baz/metadata.rb", 'name "baz" depends "foo"' - file 'cookbooks/self/metadata.rb', 'name "self" + file "cookbooks/self/metadata.rb", 'name "self" depends "self"' end - it 'knife deps prints each once' do - knife('deps /cookbooks/foo /cookbooks/self').should_succeed( + it "knife deps prints each once" do + knife("deps /cookbooks/foo /cookbooks/self").should_succeed( stdout: "/cookbooks/baz\n/cookbooks/bar\n/cookbooks/foo\n/cookbooks/self\n", stderr: "WARN: Ignoring self-dependency in cookbook self, please remove it (in the future this will be fatal).\n", ) end - it 'knife deps --tree prints each once' do - knife('deps --tree /cookbooks/foo /cookbooks/self').should_succeed( + it "knife deps --tree prints each once" do + knife("deps --tree /cookbooks/foo /cookbooks/self").should_succeed( stdout: "/cookbooks/foo\n /cookbooks/bar\n /cookbooks/baz\n /cookbooks/foo\n/cookbooks/self\n", stderr: "WARN: Ignoring self-dependency in cookbook self, please remove it (in the future this will be fatal).\n", ) end end - when_the_repository 'has roles with circular dependencies' do + when_the_repository "has roles with circular dependencies" do before do - file 'roles/foo.json', { 'run_list' => [ 'role[bar]' ] } - file 'roles/bar.json', { 'run_list' => [ 'role[baz]' ] } - file 'roles/baz.json', { 'run_list' => [ 'role[foo]' ] } - file 'roles/self.json', { 'run_list' => [ 'role[self]' ] } + file "roles/foo.json", { "run_list" => [ "role[bar]" ] } + file "roles/bar.json", { "run_list" => [ "role[baz]" ] } + file "roles/baz.json", { "run_list" => [ "role[foo]" ] } + file "roles/self.json", { "run_list" => [ "role[self]" ] } end - it 'knife deps prints each once' do - knife('deps /roles/foo.json /roles/self.json').should_succeed <<EOM + it "knife deps prints each once" do + knife("deps /roles/foo.json /roles/self.json").should_succeed <<EOM /roles/baz.json /roles/bar.json /roles/foo.json /roles/self.json EOM end - it 'knife deps --tree prints each once' do - knife('deps --tree /roles/foo.json /roles/self.json') do + it "knife deps --tree prints each once" do + knife("deps --tree /roles/foo.json /roles/self.json") do expect(stdout).to eq("/roles/foo.json\n /roles/bar.json\n /roles/baz.json\n /roles/foo.json\n/roles/self.json\n /roles/self.json\n") expect(stderr).to eq("WARNING: No knife configuration file found\n") end @@ -252,81 +252,81 @@ EOM end end - context 'missing objects' do - when_the_repository 'is empty' do - it 'knife deps /blah reports an error' do - knife('deps /blah').should_fail( + context "missing objects" do + when_the_repository "is empty" do + it "knife deps /blah reports an error" do + knife("deps /blah").should_fail( :exit_code => 2, :stdout => "/blah\n", :stderr => "ERROR: /blah: No such file or directory\n", ) end - it 'knife deps /roles/x.json reports an error' do - knife('deps /roles/x.json').should_fail( + it "knife deps /roles/x.json reports an error" do + knife("deps /roles/x.json").should_fail( :exit_code => 2, :stdout => "/roles/x.json\n", :stderr => "ERROR: /roles/x.json: No such file or directory\n", ) end - it 'knife deps /nodes/x.json reports an error' do - knife('deps /nodes/x.json').should_fail( + it "knife deps /nodes/x.json reports an error" do + knife("deps /nodes/x.json").should_fail( :exit_code => 2, :stdout => "/nodes/x.json\n", :stderr => "ERROR: /nodes/x.json: No such file or directory\n", ) end - it 'knife deps /environments/x.json reports an error' do - knife('deps /environments/x.json').should_fail( + it "knife deps /environments/x.json reports an error" do + knife("deps /environments/x.json").should_fail( :exit_code => 2, :stdout => "/environments/x.json\n", :stderr => "ERROR: /environments/x.json: No such file or directory\n", ) end - it 'knife deps /cookbooks/x reports an error' do - knife('deps /cookbooks/x').should_fail( + it "knife deps /cookbooks/x reports an error" do + knife("deps /cookbooks/x").should_fail( :exit_code => 2, :stdout => "/cookbooks/x\n", :stderr => "ERROR: /cookbooks/x: No such file or directory\n", ) end - it 'knife deps /data_bags/bag/item reports an error' do - knife('deps /data_bags/bag/item').should_fail( + it "knife deps /data_bags/bag/item reports an error" do + knife("deps /data_bags/bag/item").should_fail( :exit_code => 2, :stdout => "/data_bags/bag/item\n", :stderr => "ERROR: /data_bags/bag/item: No such file or directory\n", ) end end - when_the_repository 'is missing a dependent cookbook' do + when_the_repository "is missing a dependent cookbook" do before do - file 'roles/starring.json', { 'run_list' => [ 'recipe[quiche]'] } + file "roles/starring.json", { "run_list" => [ "recipe[quiche]"] } end - it 'knife deps reports the cookbook, along with an error' do - knife('deps /roles/starring.json').should_fail( + it "knife deps reports the cookbook, along with an error" do + knife("deps /roles/starring.json").should_fail( :exit_code => 2, :stdout => "/cookbooks/quiche\n/roles/starring.json\n", :stderr => "ERROR: /cookbooks/quiche: No such file or directory\n", ) end end - when_the_repository 'is missing a dependent environment' do + when_the_repository "is missing a dependent environment" do before do - file 'nodes/mort.json', { 'chef_environment' => 'desert' } + file "nodes/mort.json", { "chef_environment" => "desert" } end - it 'knife deps reports the environment, along with an error' do - knife('deps /nodes/mort.json').should_fail( + it "knife deps reports the environment, along with an error" do + knife("deps /nodes/mort.json").should_fail( :exit_code => 2, :stdout => "/environments/desert.json\n/nodes/mort.json\n", :stderr => "ERROR: /environments/desert.json: No such file or directory\n", ) end end - when_the_repository 'is missing a dependent role' do + when_the_repository "is missing a dependent role" do before do - file 'roles/starring.json', { 'run_list' => [ 'role[minor]'] } + file "roles/starring.json", { "run_list" => [ "role[minor]"] } end - it 'knife deps reports the role, along with an error' do - knife('deps /roles/starring.json').should_fail( + it "knife deps reports the role, along with an error" do + knife("deps /roles/starring.json").should_fail( :exit_code => 2, :stdout => "/roles/minor.json\n/roles/starring.json\n", :stderr => "ERROR: /roles/minor.json: No such file or directory\n", @@ -334,29 +334,29 @@ EOM end end end - context 'invalid objects' do - when_the_repository 'is empty' do - it 'knife deps / reports itself only' do - knife('deps /').should_succeed("/\n") + context "invalid objects" do + when_the_repository "is empty" do + it "knife deps / reports itself only" do + knife("deps /").should_succeed("/\n") end - it 'knife deps /roles reports an error' do - knife('deps /roles').should_fail( + it "knife deps /roles reports an error" do + knife("deps /roles").should_fail( :exit_code => 2, :stderr => "ERROR: /roles: No such file or directory\n", :stdout => "/roles\n", ) end end - when_the_repository 'has a data bag' do - before { file 'data_bags/bag/item.json', '' } - it 'knife deps /data_bags/bag shows no dependencies' do - knife('deps /data_bags/bag').should_succeed("/data_bags/bag\n") + when_the_repository "has a data bag" do + before { file "data_bags/bag/item.json", "" } + it "knife deps /data_bags/bag shows no dependencies" do + knife("deps /data_bags/bag").should_succeed("/data_bags/bag\n") end end - when_the_repository 'has a cookbook' do - before { file 'cookbooks/blah/metadata.rb', 'name "blah"' } - it 'knife deps on a cookbook file shows no dependencies' do - knife('deps /cookbooks/blah/metadata.rb').should_succeed( + when_the_repository "has a cookbook" do + before { file "cookbooks/blah/metadata.rb", 'name "blah"' } + it "knife deps on a cookbook file shows no dependencies" do + knife("deps /cookbooks/blah/metadata.rb").should_succeed( "/cookbooks/blah/metadata.rb\n" ) end @@ -364,25 +364,25 @@ EOM end end - context 'remote' do + context "remote" do include_context "default config options" - when_the_chef_server 'has a role with no run_list' do - before { role 'starring', {} } - it 'knife deps reports no dependencies' do - knife('deps --remote /roles/starring.json').should_succeed "/roles/starring.json\n" + when_the_chef_server "has a role with no run_list" do + before { role "starring", {} } + it "knife deps reports no dependencies" do + knife("deps --remote /roles/starring.json").should_succeed "/roles/starring.json\n" end end - when_the_chef_server 'has a role with a default run_list' do + when_the_chef_server "has a role with a default run_list" do before do - role 'starring', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - role 'minor', {} - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } - cookbook 'soup', '1.0.0', { 'metadata.rb' => %Q{name "soup"\nversion "1.0.0"\n}, 'recipes' => { 'chicken.rb' => '' } } + role "starring", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + role "minor", {} + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } + cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } } end - it 'knife deps reports all dependencies' do - knife('deps --remote /roles/starring.json').should_succeed <<EOM + it "knife deps reports all dependencies" do + knife("deps --remote /roles/starring.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -391,15 +391,15 @@ EOM end end - when_the_chef_server 'has a role with an env_run_list' do + when_the_chef_server "has a role with an env_run_list" do before do - role 'starring', { 'env_run_lists' => { 'desert' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } } - role 'minor', {} - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } - cookbook 'soup', '1.0.0', { 'metadata.rb' => %Q{name "soup"\nversion "1.0.0"\n}, 'recipes' => { 'chicken.rb' => '' } } + role "starring", { "env_run_lists" => { "desert" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } } + role "minor", {} + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } + cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } } end - it 'knife deps reports all dependencies' do - knife('deps --remote /roles/starring.json').should_succeed <<EOM + it "knife deps reports all dependencies" do + knife("deps --remote /roles/starring.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -408,30 +408,30 @@ EOM end end - when_the_chef_server 'has a node with no environment or run_list' do - before { node 'mort', {} } - it 'knife deps reports just the node' do - knife('deps --remote /nodes/mort.json').should_succeed "/nodes/mort.json\n" + when_the_chef_server "has a node with no environment or run_list" do + before { node "mort", {} } + it "knife deps reports just the node" do + knife("deps --remote /nodes/mort.json").should_succeed "/nodes/mort.json\n" end end - when_the_chef_server 'has a node with an environment' do + when_the_chef_server "has a node with an environment" do before do - environment 'desert', {} - node 'mort', { 'chef_environment' => 'desert' } + environment "desert", {} + node "mort", { "chef_environment" => "desert" } end - it 'knife deps reports just the node' do - knife('deps --remote /nodes/mort.json').should_succeed "/environments/desert.json\n/nodes/mort.json\n" + it "knife deps reports just the node" do + knife("deps --remote /nodes/mort.json").should_succeed "/environments/desert.json\n/nodes/mort.json\n" end end - when_the_chef_server 'has a node with roles and recipes in its run_list' do + when_the_chef_server "has a node with roles and recipes in its run_list" do before do - role 'minor', {} - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } - cookbook 'soup', '1.0.0', { 'metadata.rb' => %Q{name "soup"\nversion "1.0.0"\n}, 'recipes' => { 'chicken.rb' => '' } } - node 'mort', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + role "minor", {} + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } + cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } } + node "mort", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } end - it 'knife deps reports just the node' do - knife('deps --remote /nodes/mort.json').should_succeed <<EOM + it "knife deps reports just the node" do + knife("deps --remote /nodes/mort.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -439,49 +439,49 @@ EOM EOM end end - when_the_chef_server 'has a cookbook with no dependencies' do + when_the_chef_server "has a cookbook with no dependencies" do before do - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } end - it 'knife deps reports just the cookbook' do - knife('deps --remote /cookbooks/quiche').should_succeed "/cookbooks/quiche\n" + it "knife deps reports just the cookbook" do + knife("deps --remote /cookbooks/quiche").should_succeed "/cookbooks/quiche\n" end end - when_the_chef_server 'has a cookbook with dependencies' do + when_the_chef_server "has a cookbook with dependencies" do before do - cookbook 'kettle', '1.0.0', { 'metadata.rb' => %Q{name "kettle"\nversion "1.0.0"\n} } - cookbook 'quiche', '1.0.0', { 'metadata.rb' => 'name "quiche" -depends "kettle"', 'recipes' => { 'default.rb' => '' } } + cookbook "kettle", "1.0.0", { "metadata.rb" => %Q{name "kettle"\nversion "1.0.0"\n} } + cookbook "quiche", "1.0.0", { "metadata.rb" => 'name "quiche" +depends "kettle"', "recipes" => { "default.rb" => "" } } end - it 'knife deps reports the cookbook and its dependencies' do - knife('deps --remote /cookbooks/quiche').should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n" + it "knife deps reports the cookbook and its dependencies" do + knife("deps --remote /cookbooks/quiche").should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n" end end - when_the_chef_server 'has a data bag' do - before { data_bag 'bag', { 'item' => {} } } - it 'knife deps reports just the data bag' do - knife('deps --remote /data_bags/bag/item.json').should_succeed "/data_bags/bag/item.json\n" + when_the_chef_server "has a data bag" do + before { data_bag "bag", { "item" => {} } } + it "knife deps reports just the data bag" do + knife("deps --remote /data_bags/bag/item.json").should_succeed "/data_bags/bag/item.json\n" end end - when_the_chef_server 'has an environment' do - before { environment 'desert', {} } - it 'knife deps reports just the environment' do - knife('deps --remote /environments/desert.json').should_succeed "/environments/desert.json\n" + when_the_chef_server "has an environment" do + before { environment "desert", {} } + it "knife deps reports just the environment" do + knife("deps --remote /environments/desert.json").should_succeed "/environments/desert.json\n" end end - when_the_chef_server 'has a deep dependency tree' do + when_the_chef_server "has a deep dependency tree" do before do - role 'starring', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - role 'minor', {} - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } - cookbook 'soup', '1.0.0', { 'metadata.rb' => %Q{name "soup"\nversion "1.0.0"\n}, 'recipes' => { 'chicken.rb' => '' } } - environment 'desert', {} - node 'mort', { 'chef_environment' => 'desert', 'run_list' => [ 'role[starring]' ] } - node 'bart', { 'run_list' => [ 'role[minor]' ] } + role "starring", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + role "minor", {} + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } + cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } } + environment "desert", {} + node "mort", { "chef_environment" => "desert", "run_list" => [ "role[starring]" ] } + node "bart", { "run_list" => [ "role[minor]" ] } end - it 'knife deps reports all dependencies' do - knife('deps --remote /nodes/mort.json').should_succeed <<EOM + it "knife deps reports all dependencies" do + knife("deps --remote /nodes/mort.json").should_succeed <<EOM /environments/desert.json /roles/minor.json /cookbooks/quiche @@ -490,8 +490,8 @@ depends "kettle"', 'recipes' => { 'default.rb' => '' } } /nodes/mort.json EOM end - it 'knife deps * reports all dependencies of all things' do - knife('deps --remote /nodes/*').should_succeed <<EOM + it "knife deps * reports all dependencies of all things" do + knife("deps --remote /nodes/*").should_succeed <<EOM /roles/minor.json /nodes/bart.json /environments/desert.json @@ -501,8 +501,8 @@ EOM /nodes/mort.json EOM end - it 'knife deps a b reports all dependencies of a and b' do - knife('deps --remote /nodes/bart.json /nodes/mort.json').should_succeed <<EOM + it "knife deps a b reports all dependencies of a and b" do + knife("deps --remote /nodes/bart.json /nodes/mort.json").should_succeed <<EOM /roles/minor.json /nodes/bart.json /environments/desert.json @@ -512,8 +512,8 @@ EOM /nodes/mort.json EOM end - it 'knife deps --tree /* shows dependencies in a tree' do - knife('deps --remote --tree /nodes/*').should_succeed <<EOM + it "knife deps --tree /* shows dependencies in a tree" do + knife("deps --remote --tree /nodes/*").should_succeed <<EOM /nodes/bart.json /roles/minor.json /nodes/mort.json @@ -524,8 +524,8 @@ EOM /cookbooks/soup EOM end - it 'knife deps --tree --no-recurse shows only the first level of dependencies' do - knife('deps --remote --tree --no-recurse /nodes/*').should_succeed <<EOM + it "knife deps --tree --no-recurse shows only the first level of dependencies" do + knife("deps --remote --tree --no-recurse /nodes/*").should_succeed <<EOM /nodes/bart.json /roles/minor.json /nodes/mort.json @@ -535,28 +535,28 @@ EOM end end - context 'circular dependencies' do - when_the_chef_server 'has cookbooks with circular dependencies' do + context "circular dependencies" do + when_the_chef_server "has cookbooks with circular dependencies" do before do - cookbook 'foo', '1.0.0', { 'metadata.rb' => 'name "foo" + cookbook "foo", "1.0.0", { "metadata.rb" => 'name "foo" depends "bar"' } - cookbook 'bar', '1.0.0', { 'metadata.rb' => 'name "bar" + cookbook "bar", "1.0.0", { "metadata.rb" => 'name "bar" depends "baz"' } - cookbook 'baz', '1.0.0', { 'metadata.rb' => 'name "baz" + cookbook "baz", "1.0.0", { "metadata.rb" => 'name "baz" depends "foo"' } - cookbook 'self', '1.0.0', { 'metadata.rb' => 'name "self" + cookbook "self", "1.0.0", { "metadata.rb" => 'name "self" depends "self"' } end - it 'knife deps prints each once' do - knife('deps --remote /cookbooks/foo /cookbooks/self').should_succeed <<EOM + it "knife deps prints each once" do + knife("deps --remote /cookbooks/foo /cookbooks/self").should_succeed <<EOM /cookbooks/baz /cookbooks/bar /cookbooks/foo /cookbooks/self EOM end - it 'knife deps --tree prints each once' do - knife('deps --remote --tree /cookbooks/foo /cookbooks/self').should_succeed <<EOM + it "knife deps --tree prints each once" do + knife("deps --remote --tree /cookbooks/foo /cookbooks/self").should_succeed <<EOM /cookbooks/foo /cookbooks/bar /cookbooks/baz @@ -566,23 +566,23 @@ EOM EOM end end - when_the_chef_server 'has roles with circular dependencies' do + when_the_chef_server "has roles with circular dependencies" do before do - role 'foo', { 'run_list' => [ 'role[bar]' ] } - role 'bar', { 'run_list' => [ 'role[baz]' ] } - role 'baz', { 'run_list' => [ 'role[foo]' ] } - role 'self', { 'run_list' => [ 'role[self]' ] } + role "foo", { "run_list" => [ "role[bar]" ] } + role "bar", { "run_list" => [ "role[baz]" ] } + role "baz", { "run_list" => [ "role[foo]" ] } + role "self", { "run_list" => [ "role[self]" ] } end - it 'knife deps prints each once' do - knife('deps --remote /roles/foo.json /roles/self.json').should_succeed <<EOM + it "knife deps prints each once" do + knife("deps --remote /roles/foo.json /roles/self.json").should_succeed <<EOM /roles/baz.json /roles/bar.json /roles/foo.json /roles/self.json EOM end - it 'knife deps --tree prints each once' do - knife('deps --remote --tree /roles/foo.json /roles/self.json') do + it "knife deps --tree prints each once" do + knife("deps --remote --tree /roles/foo.json /roles/self.json") do expect(stdout).to eq("/roles/foo.json\n /roles/bar.json\n /roles/baz.json\n /roles/foo.json\n/roles/self.json\n /roles/self.json\n") expect(stderr).to eq("WARNING: No knife configuration file found\n") end @@ -590,81 +590,81 @@ EOM end end - context 'missing objects' do - when_the_chef_server 'is empty' do - it 'knife deps /blah reports an error' do - knife('deps --remote /blah').should_fail( + context "missing objects" do + when_the_chef_server "is empty" do + it "knife deps /blah reports an error" do + knife("deps --remote /blah").should_fail( :exit_code => 2, :stdout => "/blah\n", :stderr => "ERROR: /blah: No such file or directory\n", ) end - it 'knife deps /roles/x.json reports an error' do - knife('deps --remote /roles/x.json').should_fail( + it "knife deps /roles/x.json reports an error" do + knife("deps --remote /roles/x.json").should_fail( :exit_code => 2, :stdout => "/roles/x.json\n", :stderr => "ERROR: /roles/x.json: No such file or directory\n", ) end - it 'knife deps /nodes/x.json reports an error' do - knife('deps --remote /nodes/x.json').should_fail( + it "knife deps /nodes/x.json reports an error" do + knife("deps --remote /nodes/x.json").should_fail( :exit_code => 2, :stdout => "/nodes/x.json\n", :stderr => "ERROR: /nodes/x.json: No such file or directory\n", ) end - it 'knife deps /environments/x.json reports an error' do - knife('deps --remote /environments/x.json').should_fail( + it "knife deps /environments/x.json reports an error" do + knife("deps --remote /environments/x.json").should_fail( :exit_code => 2, :stdout => "/environments/x.json\n", :stderr => "ERROR: /environments/x.json: No such file or directory\n", ) end - it 'knife deps /cookbooks/x reports an error' do - knife('deps --remote /cookbooks/x').should_fail( + it "knife deps /cookbooks/x reports an error" do + knife("deps --remote /cookbooks/x").should_fail( :exit_code => 2, :stdout => "/cookbooks/x\n", :stderr => "ERROR: /cookbooks/x: No such file or directory\n", ) end - it 'knife deps /data_bags/bag/item reports an error' do - knife('deps --remote /data_bags/bag/item').should_fail( + it "knife deps /data_bags/bag/item reports an error" do + knife("deps --remote /data_bags/bag/item").should_fail( :exit_code => 2, :stdout => "/data_bags/bag/item\n", :stderr => "ERROR: /data_bags/bag/item: No such file or directory\n", ) end end - when_the_chef_server 'is missing a dependent cookbook' do + when_the_chef_server "is missing a dependent cookbook" do before do - role 'starring', { 'run_list' => [ 'recipe[quiche]'] } + role "starring", { "run_list" => [ "recipe[quiche]"] } end - it 'knife deps reports the cookbook, along with an error' do - knife('deps --remote /roles/starring.json').should_fail( + it "knife deps reports the cookbook, along with an error" do + knife("deps --remote /roles/starring.json").should_fail( :exit_code => 2, :stdout => "/cookbooks/quiche\n/roles/starring.json\n", :stderr => "ERROR: /cookbooks/quiche: No such file or directory\n", ) end end - when_the_chef_server 'is missing a dependent environment' do + when_the_chef_server "is missing a dependent environment" do before do - node 'mort', { 'chef_environment' => 'desert' } + node "mort", { "chef_environment" => "desert" } end - it 'knife deps reports the environment, along with an error' do - knife('deps --remote /nodes/mort.json').should_fail( + it "knife deps reports the environment, along with an error" do + knife("deps --remote /nodes/mort.json").should_fail( :exit_code => 2, :stdout => "/environments/desert.json\n/nodes/mort.json\n", :stderr => "ERROR: /environments/desert.json: No such file or directory\n", ) end end - when_the_chef_server 'is missing a dependent role' do + when_the_chef_server "is missing a dependent role" do before do - role 'starring', { 'run_list' => [ 'role[minor]'] } + role "starring", { "run_list" => [ "role[minor]"] } end - it 'knife deps reports the role, along with an error' do - knife('deps --remote /roles/starring.json').should_fail( + it "knife deps reports the role, along with an error" do + knife("deps --remote /roles/starring.json").should_fail( :exit_code => 2, :stdout => "/roles/minor.json\n/roles/starring.json\n", :stderr => "ERROR: /roles/minor.json: No such file or directory\n", @@ -672,27 +672,27 @@ EOM end end end - context 'invalid objects' do - when_the_chef_server 'is empty' do - it 'knife deps / reports an error' do - knife('deps --remote /').should_succeed("/\n") + context "invalid objects" do + when_the_chef_server "is empty" do + it "knife deps / reports an error" do + knife("deps --remote /").should_succeed("/\n") end - it 'knife deps /roles reports an error' do - knife('deps --remote /roles').should_succeed("/roles\n") + it "knife deps /roles reports an error" do + knife("deps --remote /roles").should_succeed("/roles\n") end end - when_the_chef_server 'has a data bag' do - before { data_bag 'bag', { 'item' => {} } } - it 'knife deps /data_bags/bag shows no dependencies' do - knife('deps --remote /data_bags/bag').should_succeed("/data_bags/bag\n") + when_the_chef_server "has a data bag" do + before { data_bag "bag", { "item" => {} } } + it "knife deps /data_bags/bag shows no dependencies" do + knife("deps --remote /data_bags/bag").should_succeed("/data_bags/bag\n") end end - when_the_chef_server 'has a cookbook' do + when_the_chef_server "has a cookbook" do before do - cookbook 'blah', '1.0.0', { 'metadata.rb' => 'name "blah"' } + cookbook "blah", "1.0.0", { "metadata.rb" => 'name "blah"' } end - it 'knife deps on a cookbook file shows no dependencies' do - knife('deps --remote /cookbooks/blah/metadata.rb').should_succeed( + it "knife deps on a cookbook file shows no dependencies" do + knife("deps --remote /cookbooks/blah/metadata.rb").should_succeed( "/cookbooks/blah/metadata.rb\n" ) end @@ -700,7 +700,7 @@ EOM end end - it 'knife deps --no-recurse reports an error' do - knife('deps --no-recurse /').should_fail("ERROR: --no-recurse requires --tree\n") + it "knife deps --no-recurse reports an error" do + knife("deps --no-recurse /").should_fail("ERROR: --no-recurse requires --tree\n") end end diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb index b32a4580a1..822b07d9e1 100644 --- a/spec/integration/knife/diff_spec.rb +++ b/spec/integration/knife/diff_spec.rb @@ -15,38 +15,38 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/diff' +require "support/shared/integration/integration_helper" +require "chef/knife/diff" -describe 'knife diff', :workstation do +describe "knife diff", :workstation do include IntegrationSupport include KnifeSupport - context 'without versioned cookbooks' do + context "without versioned cookbooks" do when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife diff reports everything as deleted' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports everything as deleted" do + knife("diff --name-status /").should_succeed <<EOM D\t/clients/chef-validator.json D\t/clients/chef-webui.json D\t/clients/x.json @@ -62,65 +62,65 @@ EOM end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife diff reports no differences' do - knife('diff /').should_succeed '' + it "knife diff reports no differences" do + knife("diff /").should_succeed "" end - it 'knife diff /environments/nonexistent.json reports an error' do - knife('diff /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n" + it "knife diff /environments/nonexistent.json reports an error" do + knife("diff /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n" end - it 'knife diff /environments/*.txt reports an error' do - knife('diff /environments/*.txt').should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n" + it "knife diff /environments/*.txt reports an error" do + knife("diff /environments/*.txt").should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "foo": "bar" } EOM end - it 'knife diff reports the role as different' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports the role as different" do + knife("diff --name-status /").should_succeed <<EOM M\t/roles/x.json EOM end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/blah.rb', '' - file 'cookbooks/y/metadata.rb', cb_metadata("y", "1.0.0") - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/blah.rb", "" + file "cookbooks/y/metadata.rb", cb_metadata("y", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife diff reports the new files as added' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports the new files as added" do + knife("diff --name-status /").should_succeed <<EOM A\t/clients/y.json A\t/cookbooks/x/blah.rb A\t/cookbooks/y @@ -133,16 +133,16 @@ A\t/users/y.json EOM end - context 'when cwd is the data_bags directory' do - before { cwd 'data_bags' } - it 'knife diff reports different data bags' do - knife('diff --name-status').should_succeed <<EOM + context "when cwd is the data_bags directory" do + before { cwd "data_bags" } + it "knife diff reports different data bags" do + knife("diff --name-status").should_succeed <<EOM A\tx/z.json A\ty EOM end - it 'knife diff * reports different data bags' do - knife('diff --name-status *').should_succeed <<EOM + it "knife diff * reports different data bags" do + knife("diff --name-status *").should_succeed <<EOM A\tx/z.json A\ty EOM @@ -151,9 +151,9 @@ EOM end end - when_the_repository 'is empty' do - it 'knife diff reports everything as deleted' do - knife('diff --name-status /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife diff reports everything as deleted" do + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -166,51 +166,51 @@ EOM end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x/onlyin1.0.0.rb', '' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/onlyin1.0.0.rb", "" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" } end - it 'knife diff /cookbooks/x shows differences' do - knife('diff --name-status /cookbooks/x').should_succeed <<EOM + it "knife diff /cookbooks/x shows differences" do + knife("diff --name-status /cookbooks/x").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb EOM end - it 'knife diff --diff-filter=MAT does not show deleted files' do - knife('diff --diff-filter=MAT --name-status /cookbooks/x').should_succeed <<EOM + it "knife diff --diff-filter=MAT does not show deleted files" do + knife("diff --diff-filter=MAT --name-status /cookbooks/x").should_succeed <<EOM M\t/cookbooks/x/metadata.rb A\t/cookbooks/x/onlyin1.0.0.rb EOM end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "" } end - it 'knife diff /cookbooks/x shows no differences' do - knife('diff --name-status /cookbooks/x').should_succeed '' + it "knife diff /cookbooks/x shows no differences" do + knife("diff --name-status /cookbooks/x").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" } end - it 'knife diff /cookbooks/x shows the differences' do - knife('diff --name-status /cookbooks/x').should_succeed <<EOM + it "knife diff /cookbooks/x shows the differences" do + knife("diff --name-status /cookbooks/x").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb @@ -218,13 +218,13 @@ EOM end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "" } end - it 'knife diff /cookbooks/x shows the differences' do - knife('diff --name-status /cookbooks/x').should_succeed <<EOM + it "knife diff /cookbooks/x shows the differences" do + knife("diff --name-status /cookbooks/x").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin0.9.9.rb A\t/cookbooks/x/onlyin1.0.0.rb @@ -233,22 +233,22 @@ EOM end end - context 'json diff tests' do - when_the_repository 'has an empty environment file' do + context "json diff tests" do + when_the_repository "has an empty environment file" do before do - file 'environments/x.json', {} + file "environments/x.json", {} end - when_the_chef_server 'has an empty environment' do - before { environment 'x', {} } - it 'knife diff returns no differences' do - knife('diff /environments/x.json').should_succeed '' + when_the_chef_server "has an empty environment" do + before { environment "x", {} } + it "knife diff returns no differences" do + knife("diff /environments/x.json").should_succeed "" end end - when_the_chef_server 'has an environment with a different value' do - before { environment 'x', { 'description' => 'hi' } } - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + when_the_chef_server "has an environment with a different value" do + before { environment "x", { "description" => "hi" } } + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { - "name": "x", - "description": "hi" @@ -259,26 +259,26 @@ EOM end end - when_the_repository 'has an environment file with a value in it' do + when_the_repository "has an environment file with a value in it" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - when_the_chef_server 'has an environment with the same value' do + when_the_chef_server "has an environment with the same value" do before do - environment 'x', { 'description' => 'hi' } + environment "x", { "description" => "hi" } end - it 'knife diff returns no differences' do - knife('diff /environments/x.json').should_succeed '' + it "knife diff returns no differences" do + knife("diff /environments/x.json").should_succeed "" end end - when_the_chef_server 'has an environment with no value' do + when_the_chef_server "has an environment with no value" do before do - environment 'x', {} + environment "x", {} end - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { - "name": "x" \+ "name": "x", @@ -287,12 +287,12 @@ EOM /) end end - when_the_chef_server 'has an environment with a different value' do + when_the_chef_server "has an environment with a different value" do before do - environment 'x', { 'description' => 'lo' } + environment "x", { "description" => "lo" } end - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { "name": "x", - "description": "lo" @@ -304,14 +304,14 @@ EOM end end - when_the_chef_server 'has an environment' do - before { environment 'x', {} } - when_the_repository 'has an environment with bad JSON' do - before { file 'environments/x.json', '{' } - it 'knife diff reports an error and does a textual diff' do + when_the_chef_server "has an environment" do + before { environment "x", {} } + when_the_repository "has an environment with bad JSON" do + before { file "environments/x.json", "{" } + it "knife diff reports an error and does a textual diff" do error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" error_match = Regexp.new(Regexp.escape(error_text)) - knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => error_match) + knife("diff /environments/x.json").should_succeed(/- "name": "x"/, :stderr => error_match) end end end @@ -320,28 +320,28 @@ EOM with_versioned_cookbooks do when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife diff reports everything as deleted' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports everything as deleted" do + knife("diff --name-status /").should_succeed <<EOM D\t/clients/chef-validator.json D\t/clients/chef-webui.json D\t/clients/x.json @@ -357,65 +357,65 @@ EOM end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife diff reports no differences' do - knife('diff /').should_succeed '' + it "knife diff reports no differences" do + knife("diff /").should_succeed "" end - it 'knife diff /environments/nonexistent.json reports an error' do - knife('diff /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n" + it "knife diff /environments/nonexistent.json reports an error" do + knife("diff /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n" end - it 'knife diff /environments/*.txt reports an error' do - knife('diff /environments/*.txt').should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n" + it "knife diff /environments/*.txt reports an error" do + knife("diff /environments/*.txt").should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "foo": "bar" } EOM end - it 'knife diff reports the role as different' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports the role as different" do + knife("diff --name-status /").should_succeed <<EOM M\t/roles/x.json EOM end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', {} - file 'cookbooks/x-1.0.0/blah.rb', '' - file 'cookbooks/x-2.0.0/metadata.rb', cb_metadata("x", "2.0.0") - file 'cookbooks/y-1.0.0/metadata.rb', cb_metadata("y", "1.0.0") - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', {} + file "clients/y.json", {} + file "cookbooks/x-1.0.0/blah.rb", "" + file "cookbooks/x-2.0.0/metadata.rb", cb_metadata("x", "2.0.0") + file "cookbooks/y-1.0.0/metadata.rb", cb_metadata("y", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", {} end - it 'knife diff reports the new files as added' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports the new files as added" do + knife("diff --name-status /").should_succeed <<EOM A\t/clients/y.json A\t/cookbooks/x-1.0.0/blah.rb A\t/cookbooks/x-2.0.0 @@ -429,16 +429,16 @@ A\t/users/y.json EOM end - context 'when cwd is the data_bags directory' do - before { cwd 'data_bags' } - it 'knife diff reports different data bags' do - knife('diff --name-status').should_succeed <<EOM + context "when cwd is the data_bags directory" do + before { cwd "data_bags" } + it "knife diff reports different data bags" do + knife("diff --name-status").should_succeed <<EOM A\tx/z.json A\ty EOM end - it 'knife diff * reports different data bags' do - knife('diff --name-status *').should_succeed <<EOM + it "knife diff * reports different data bags" do + knife("diff --name-status *").should_succeed <<EOM A\tx/z.json A\ty EOM @@ -447,9 +447,9 @@ EOM end end - when_the_repository 'is empty' do - it 'knife diff reports everything as deleted' do - knife('diff --name-status /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife diff reports everything as deleted" do + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -462,59 +462,59 @@ EOM end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', '' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x-1.0.0/onlyin1.0.0.rb", "" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" } end - it 'knife diff /cookbooks shows differences' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife diff /cookbooks shows differences" do + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-1.0.1 EOM end - it 'knife diff --diff-filter=MAT does not show deleted files' do - knife('diff --diff-filter=MAT --name-status /cookbooks').should_succeed '' + it "knife diff --diff-filter=MAT does not show deleted files" do + knife("diff --diff-filter=MAT --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "" } end - it 'knife diff /cookbooks shows the differences' do - knife('diff --name-status /cookbooks').should_succeed "D\t/cookbooks/x-0.9.9\n" + it "knife diff /cookbooks shows the differences" do + knife("diff --name-status /cookbooks").should_succeed "D\t/cookbooks/x-0.9.9\n" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" } end - it 'knife diff /cookbooks shows the differences' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife diff /cookbooks shows the differences" do + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-1.0.1 A\t/cookbooks/x-1.0.0 EOM end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "" } end - it 'knife diff /cookbooks shows the differences' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife diff /cookbooks shows the differences" do + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-0.9.9 A\t/cookbooks/x-1.0.0 EOM @@ -522,19 +522,19 @@ EOM end end - context 'json diff tests' do - when_the_repository 'has an empty environment file' do - before { file 'environments/x.json', {} } - when_the_chef_server 'has an empty environment' do - before { environment 'x', {} } - it 'knife diff returns no differences' do - knife('diff /environments/x.json').should_succeed '' + context "json diff tests" do + when_the_repository "has an empty environment file" do + before { file "environments/x.json", {} } + when_the_chef_server "has an empty environment" do + before { environment "x", {} } + it "knife diff returns no differences" do + knife("diff /environments/x.json").should_succeed "" end end - when_the_chef_server 'has an environment with a different value' do - before { environment 'x', { 'description' => 'hi' } } - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + when_the_chef_server "has an environment with a different value" do + before { environment "x", { "description" => "hi" } } + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { - "name": "x", - "description": "hi" @@ -545,23 +545,23 @@ EOM end end - when_the_repository 'has an environment file with a value in it' do + when_the_repository "has an environment file with a value in it" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - when_the_chef_server 'has an environment with the same value' do + when_the_chef_server "has an environment with the same value" do before do - environment 'x', { 'description' => 'hi' } + environment "x", { "description" => "hi" } end - it 'knife diff returns no differences' do - knife('diff /environments/x.json').should_succeed '' + it "knife diff returns no differences" do + knife("diff /environments/x.json").should_succeed "" end end - when_the_chef_server 'has an environment with no value' do - before { environment 'x', {} } - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + when_the_chef_server "has an environment with no value" do + before { environment "x", {} } + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { - "name": "x" \+ "name": "x", @@ -570,12 +570,12 @@ EOM /) end end - when_the_chef_server 'has an environment with a different value' do + when_the_chef_server "has an environment with a different value" do before do - environment 'x', { 'description' => 'lo' } + environment "x", { "description" => "lo" } end - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { "name": "x", - "description": "lo" @@ -587,14 +587,14 @@ EOM end end - when_the_chef_server 'has an environment' do - before { environment 'x', {} } - when_the_repository 'has an environment with bad JSON' do - before { file 'environments/x.json', '{' } - it 'knife diff reports an error and does a textual diff' do + when_the_chef_server "has an environment" do + before { environment "x", {} } + when_the_repository "has an environment with bad JSON" do + before { file "environments/x.json", "{" } + it "knife diff reports an error and does a textual diff" do error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" error_match = Regexp.new(Regexp.escape(error_text)) - knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => error_match) + knife("diff /environments/x.json").should_succeed(/- "name": "x"/, :stderr => error_match) end end end diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb index 24618ebcae..faa640f83b 100644 --- a/spec/integration/knife/download_spec.rb +++ b/spec/integration/knife/download_spec.rb @@ -15,40 +15,40 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/download' -require 'chef/knife/diff' +require "support/shared/integration/integration_helper" +require "chef/knife/download" +require "chef/knife/diff" -describe 'knife download', :workstation do +describe "knife download", :workstation do include IntegrationSupport include KnifeSupport - context 'without versioned cookbooks' do + context "without versioned cookbooks" do when_the_chef_server "has one of each thing" do before do - client 'x', {} - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => {} } - environment 'x', {} - node 'x', {} - role 'x', {} - user 'x', {} + client "x", {} + cookbook "x", "1.0.0" + data_bag "x", { "y" => {} } + environment "x", {} + node "x", {} + role "x", {} + user "x", {} end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife download downloads everything' do - knife('download /').should_succeed <<EOM + it "knife download downloads everything" do + knife("download /").should_succeed <<EOM Created /clients/chef-validator.json Created /clients/chef-webui.json Created /clients/x.json @@ -63,38 +63,38 @@ Created /roles/x.json Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife download makes no changes' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download makes no changes" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - it 'knife download --purge makes no changes' do - knife('download --purge /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download --purge makes no changes" do + knife("download --purge /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role", "default_attributes": { @@ -113,20 +113,20 @@ EOM EOM end - it 'knife download changes the role' do - knife('download /').should_succeed "Updated /roles/x.json\n" - knife('diff --name-status /').should_succeed '' + it "knife download changes the role" do + knife("download /").should_succeed "Updated /roles/x.json\n" + knife("diff --name-status /").should_succeed "" end - it 'knife download --no-diff does not change the role' do - knife('download --no-diff /').should_succeed '' - knife('diff --name-status /').should_succeed "M\t/roles/x.json\n" + it "knife download --no-diff does not change the role" do + knife("download --no-diff /").should_succeed "" + knife("diff --name-status /").should_succeed "M\t/roles/x.json\n" end end - context 'except the role file is textually different, but not ACTUALLY different' do + context "except the role file is textually different, but not ACTUALLY different" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role", "default_attributes": { @@ -145,28 +145,28 @@ EOM EOM end - it 'knife download / does not change anything' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download / does not change anything" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed "" end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/blah.rb', '' - file 'cookbooks/y/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/blah.rb", "" + file "cookbooks/y/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife download does nothing' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + it "knife download does nothing" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM A\t/clients/y.json A\t/cookbooks/x/blah.rb A\t/cookbooks/y @@ -179,8 +179,8 @@ A\t/users/y.json EOM end - it 'knife download --purge deletes the extra files' do - knife('download --purge /').should_succeed <<EOM + it "knife download --purge deletes the extra files" do + knife("download --purge /").should_succeed <<EOM Deleted extra entry /clients/y.json (purge is on) Deleted extra entry /cookbooks/x/blah.rb (purge is on) Deleted extra entry /cookbooks/y (purge is on) @@ -191,14 +191,14 @@ Deleted extra entry /nodes/y.json (purge is on) Deleted extra entry /roles/y.json (purge is on) Deleted extra entry /users/y.json (purge is on) EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end - when_the_repository 'is empty' do - it 'knife download creates the extra files' do - knife('download /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife download creates the extra files" do + knife("download /").should_succeed <<EOM Created /clients Created /clients/chef-validator.json Created /clients/chef-webui.json @@ -220,11 +220,11 @@ Created /users Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end - it 'knife download --no-diff creates the extra files' do - knife('download --no-diff /').should_succeed <<EOM + it "knife download --no-diff creates the extra files" do + knife("download --no-diff /").should_succeed <<EOM Created /clients Created /clients/chef-validator.json Created /clients/chef-webui.json @@ -246,41 +246,41 @@ Created /users Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end - context 'when current directory is top level' do + context "when current directory is top level" do before do - cwd '.' + cwd "." end - it 'knife download with no parameters reports an error' do - knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ + it "knife download with no parameters reports an error" do + knife("download").should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ end end end end # Test download of an item when the other end doesn't even have the container - when_the_repository 'is empty' do - when_the_chef_server 'has two data bag items' do + when_the_repository "is empty" do + when_the_chef_server "has two data bag items" do before do - data_bag 'x', { 'y' => {}, 'z' => {} } + data_bag "x", { "y" => {}, "z" => {} } end - it 'knife download of one data bag item itself succeeds' do - knife('download /data_bags/x/y.json').should_succeed <<EOM + it "knife download of one data bag item itself succeeds" do + knife("download /data_bags/x/y.json").should_succeed <<EOM Created /data_bags Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/z.json EOM end - it 'knife download /data_bags/x /data_bags/x/y.json downloads x once' do - knife('download /data_bags/x /data_bags/x/y.json').should_succeed <<EOM + it "knife download /data_bags/x /data_bags/x/y.json downloads x once" do + knife("download /data_bags/x /data_bags/x/y.json").should_succeed <<EOM Created /data_bags Created /data_bags/x Created /data_bags/x/y.json @@ -290,285 +290,285 @@ EOM end end - when_the_repository 'has three data bag items' do + when_the_repository "has three data bag items" do before do - file 'data_bags/x/deleted.json', <<EOM + file "data_bags/x/deleted.json", <<EOM { "id": "deleted" } EOM - file 'data_bags/x/modified.json', <<EOM + file "data_bags/x/modified.json", <<EOM { "id": "modified" } EOM - file 'data_bags/x/unmodified.json', <<EOM + file "data_bags/x/unmodified.json", <<EOM { "id": "unmodified" } EOM end - when_the_chef_server 'has a modified, unmodified, added and deleted data bag item' do + when_the_chef_server "has a modified, unmodified, added and deleted data bag item" do before do - data_bag 'x', { - 'added' => {}, - 'modified' => { 'foo' => 'bar' }, - 'unmodified' => {}, + data_bag "x", { + "added" => {}, + "modified" => { "foo" => "bar" }, + "unmodified" => {}, } end - it 'knife download of the modified file succeeds' do - knife('download /data_bags/x/modified.json').should_succeed <<EOM + it "knife download of the modified file succeeds" do + knife("download /data_bags/x/modified.json").should_succeed <<EOM Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the unmodified file does nothing' do - knife('download /data_bags/x/unmodified.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife download of the unmodified file does nothing" do + knife("download /data_bags/x/unmodified.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the added file succeeds' do - knife('download /data_bags/x/added.json').should_succeed <<EOM + it "knife download of the added file succeeds" do + knife("download /data_bags/x/added.json").should_succeed <<EOM Created /data_bags/x/added.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the deleted file does nothing' do - knife('download /data_bags/x/deleted.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife download of the deleted file does nothing" do + knife("download /data_bags/x/deleted.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download --purge of the deleted file deletes it' do - knife('download --purge /data_bags/x/deleted.json').should_succeed <<EOM + it "knife download --purge of the deleted file deletes it" do + knife("download --purge /data_bags/x/deleted.json").should_succeed <<EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json EOM end - it 'knife download of the entire data bag downloads everything' do - knife('download /data_bags/x').should_succeed <<EOM + it "knife download of the entire data bag downloads everything" do + knife("download /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM A\t/data_bags/x/deleted.json EOM end - it 'knife download --purge of the entire data bag downloads everything' do - knife('download --purge /data_bags/x').should_succeed <<EOM + it "knife download --purge of the entire data bag downloads everything" do + knife("download --purge /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - context 'when cwd is the /data_bags directory' do + context "when cwd is the /data_bags directory" do before do - cwd 'data_bags' + cwd "data_bags" end - it 'knife download fails' do - knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ + it "knife download fails" do + knife("download").should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ end - it 'knife download --purge . downloads everything' do - knife('download --purge .').should_succeed <<EOM + it "knife download --purge . downloads everything" do + knife("download --purge .").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - it 'knife download --purge * downloads everything' do - knife('download --purge *').should_succeed <<EOM + it "knife download --purge * downloads everything" do + knife("download --purge *").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x/z.rb', '' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/z.rb", "" end - when_the_chef_server 'has a modified, added and deleted file for the cookbook' do + when_the_chef_server "has a modified, added and deleted file for the cookbook" do before do - cookbook 'x', '1.0.0', { 'metadata.rb' => cb_metadata("x", "1.0.0", "#extra content"), 'y.rb' => 'hi' } + cookbook "x", "1.0.0", { "metadata.rb" => cb_metadata("x", "1.0.0", "#extra content"), "y.rb" => "hi" } end - it 'knife download of a modified file succeeds' do - knife('download /cookbooks/x/metadata.rb').should_succeed "Updated /cookbooks/x/metadata.rb\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of a modified file succeeds" do + knife("download /cookbooks/x/metadata.rb").should_succeed "Updated /cookbooks/x/metadata.rb\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x/y.rb A\t/cookbooks/x/z.rb EOM end - it 'knife download of a deleted file does nothing' do - knife('download /cookbooks/x/z.rb').should_succeed '' - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of a deleted file does nothing" do + knife("download /cookbooks/x/z.rb").should_succeed "" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/y.rb A\t/cookbooks/x/z.rb EOM end - it 'knife download --purge of a deleted file succeeds' do - knife('download --purge /cookbooks/x/z.rb').should_succeed "Deleted extra entry /cookbooks/x/z.rb (purge is on)\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download --purge of a deleted file succeeds" do + knife("download --purge /cookbooks/x/z.rb").should_succeed "Deleted extra entry /cookbooks/x/z.rb (purge is on)\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/y.rb EOM end - it 'knife download of an added file succeeds' do - knife('download /cookbooks/x/y.rb').should_succeed "Created /cookbooks/x/y.rb\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of an added file succeeds" do + knife("download /cookbooks/x/y.rb").should_succeed "Created /cookbooks/x/y.rb\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb A\t/cookbooks/x/z.rb EOM end - it 'knife download of the cookbook itself succeeds' do - knife('download /cookbooks/x').should_succeed <<EOM + it "knife download of the cookbook itself succeeds" do + knife("download /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/y.rb EOM - knife('diff --name-status /cookbooks').should_succeed <<EOM + knife("diff --name-status /cookbooks").should_succeed <<EOM A\t/cookbooks/x/z.rb EOM end - it 'knife download --purge of the cookbook itself succeeds' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download --purge of the cookbook itself succeeds" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/y.rb Deleted extra entry /cookbooks/x/z.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the latest version' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download /cookbooks/x downloads the latest version" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin1.0.1.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the updated file' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download /cookbooks/x downloads the updated file" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/onlyin1.0.0.rb EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the latest version' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download /cookbooks/x downloads the latest version" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin1.0.1.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the old version' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download /cookbooks/x downloads the old version" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin0.9.9.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_chef_server 'has an environment' do + when_the_chef_server "has an environment" do before do - environment 'x', {} + environment "x", {} end - when_the_repository 'has an environment with bad JSON' do + when_the_repository "has an environment with bad JSON" do before do - file 'environments/x.json', '{' + file "environments/x.json", "{" end - it 'knife download succeeds' do + it "knife download succeeds" do warning = <<-EOH WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF { (right here) ------^ EOH - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => warning - knife('diff --name-status /environments/x.json').should_succeed '' + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n", :stderr => warning + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has the same environment with the wrong name in the file' do + when_the_repository "has the same environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife download succeeds" do + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has the same environment with no name in the file' do + when_the_repository "has the same environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife download succeeds" do + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end end @@ -577,28 +577,28 @@ EOH with_versioned_cookbooks do when_the_chef_server "has one of each thing" do before do - client 'x', {} - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => {} } - environment 'x', {} - node 'x', {} - role 'x', {} - user 'x', {} + client "x", {} + cookbook "x", "1.0.0" + data_bag "x", { "y" => {} } + environment "x", {} + node "x", {} + role "x", {} + user "x", {} end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife download downloads everything' do - knife('download /').should_succeed <<EOM + it "knife download downloads everything" do + knife("download /").should_succeed <<EOM Created /clients/chef-validator.json Created /clients/chef-webui.json Created /clients/x.json @@ -613,49 +613,49 @@ Created /roles/x.json Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife download makes no changes' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download makes no changes" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - it 'knife download --purge makes no changes' do - knife('download --purge /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download --purge makes no changes" do + knife("download --purge /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', { "description" => "blarghle" } + file "roles/x.json", { "description" => "blarghle" } end - it 'knife download changes the role' do - knife('download /').should_succeed "Updated /roles/x.json\n" - knife('diff --name-status /').should_succeed '' + it "knife download changes the role" do + knife("download /").should_succeed "Updated /roles/x.json\n" + knife("diff --name-status /").should_succeed "" end end - context 'except the role file is textually different, but not ACTUALLY different' do + context "except the role file is textually different, but not ACTUALLY different" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role" , "default_attributes": { @@ -674,29 +674,29 @@ EOM EOM end - it 'knife download / does not change anything' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download / does not change anything" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed "" end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/blah.rb', '' - file 'cookbooks/x-2.0.0/metadata.rb', 'version "2.0.0"' - file 'cookbooks/y-1.0.0/metadata.rb', 'version "1.0.0"' - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/blah.rb", "" + file "cookbooks/x-2.0.0/metadata.rb", 'version "2.0.0"' + file "cookbooks/y-1.0.0/metadata.rb", 'version "1.0.0"' + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife download does nothing' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + it "knife download does nothing" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM A\t/clients/y.json A\t/cookbooks/x-1.0.0/blah.rb A\t/cookbooks/x-2.0.0 @@ -710,8 +710,8 @@ A\t/users/y.json EOM end - it 'knife download --purge deletes the extra files' do - knife('download --purge /').should_succeed <<EOM + it "knife download --purge deletes the extra files" do + knife("download --purge /").should_succeed <<EOM Deleted extra entry /clients/y.json (purge is on) Deleted extra entry /cookbooks/x-1.0.0/blah.rb (purge is on) Deleted extra entry /cookbooks/x-2.0.0 (purge is on) @@ -723,14 +723,14 @@ Deleted extra entry /nodes/y.json (purge is on) Deleted extra entry /roles/y.json (purge is on) Deleted extra entry /users/y.json (purge is on) EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end - when_the_repository 'is empty' do - it 'knife download creates the extra files' do - knife('download /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife download creates the extra files" do + knife("download /").should_succeed <<EOM Created /clients Created /clients/chef-validator.json Created /clients/chef-webui.json @@ -752,324 +752,324 @@ Created /users Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end - context 'when current directory is top level' do + context "when current directory is top level" do before do - cwd '.' + cwd "." end - it 'knife download with no parameters reports an error' do - knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ + it "knife download with no parameters reports an error" do + knife("download").should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ end end end end # Test download of an item when the other end doesn't even have the container - when_the_repository 'is empty' do - when_the_chef_server 'has two data bag items' do + when_the_repository "is empty" do + when_the_chef_server "has two data bag items" do before do - data_bag 'x', { 'y' => {}, 'z' => {} } + data_bag "x", { "y" => {}, "z" => {} } end - it 'knife download of one data bag item itself succeeds' do - knife('download /data_bags/x/y.json').should_succeed <<EOM + it "knife download of one data bag item itself succeeds" do + knife("download /data_bags/x/y.json").should_succeed <<EOM Created /data_bags Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/z.json EOM end end end - when_the_repository 'has three data bag items' do + when_the_repository "has three data bag items" do before do - file 'data_bags/x/deleted.json', <<EOM + file "data_bags/x/deleted.json", <<EOM { "id": "deleted" } EOM - file 'data_bags/x/modified.json', <<EOM + file "data_bags/x/modified.json", <<EOM { "id": "modified" } EOM - file 'data_bags/x/unmodified.json', <<EOM + file "data_bags/x/unmodified.json", <<EOM { "id": "unmodified" } EOM end - when_the_chef_server 'has a modified, unmodified, added and deleted data bag item' do + when_the_chef_server "has a modified, unmodified, added and deleted data bag item" do before do - data_bag 'x', { - 'added' => {}, - 'modified' => { 'foo' => 'bar' }, - 'unmodified' => {}, + data_bag "x", { + "added" => {}, + "modified" => { "foo" => "bar" }, + "unmodified" => {}, } end - it 'knife download of the modified file succeeds' do - knife('download /data_bags/x/modified.json').should_succeed <<EOM + it "knife download of the modified file succeeds" do + knife("download /data_bags/x/modified.json").should_succeed <<EOM Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the unmodified file does nothing' do - knife('download /data_bags/x/unmodified.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife download of the unmodified file does nothing" do + knife("download /data_bags/x/unmodified.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the added file succeeds' do - knife('download /data_bags/x/added.json').should_succeed <<EOM + it "knife download of the added file succeeds" do + knife("download /data_bags/x/added.json").should_succeed <<EOM Created /data_bags/x/added.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the deleted file does nothing' do - knife('download /data_bags/x/deleted.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife download of the deleted file does nothing" do + knife("download /data_bags/x/deleted.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download --purge of the deleted file deletes it' do - knife('download --purge /data_bags/x/deleted.json').should_succeed <<EOM + it "knife download --purge of the deleted file deletes it" do + knife("download --purge /data_bags/x/deleted.json").should_succeed <<EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json EOM end - it 'knife download of the entire data bag downloads everything' do - knife('download /data_bags/x').should_succeed <<EOM + it "knife download of the entire data bag downloads everything" do + knife("download /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM A\t/data_bags/x/deleted.json EOM end - it 'knife download --purge of the entire data bag downloads everything' do - knife('download --purge /data_bags/x').should_succeed <<EOM + it "knife download --purge of the entire data bag downloads everything" do + knife("download --purge /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - context 'when cwd is the /data_bags directory' do + context "when cwd is the /data_bags directory" do before do - cwd 'data_bags' + cwd "data_bags" end - it 'knife download fails' do - knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ + it "knife download fails" do + knife("download").should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ end - it 'knife download --purge . downloads everything' do - knife('download --purge .').should_succeed <<EOM + it "knife download --purge . downloads everything" do + knife("download --purge .").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - it 'knife download --purge * downloads everything' do - knife('download --purge *').should_succeed <<EOM + it "knife download --purge * downloads everything" do + knife("download --purge *").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', 'name "x"; version "1.0.0"#unmodified' - file 'cookbooks/x-1.0.0/z.rb', '' + file "cookbooks/x-1.0.0/metadata.rb", 'name "x"; version "1.0.0"#unmodified' + file "cookbooks/x-1.0.0/z.rb", "" end - when_the_chef_server 'has a modified, added and deleted file for the cookbook' do + when_the_chef_server "has a modified, added and deleted file for the cookbook" do before do - cookbook 'x', '1.0.0', { 'y.rb' => 'hi' } + cookbook "x", "1.0.0", { "y.rb" => "hi" } end - it 'knife download of a modified file succeeds' do - knife('download /cookbooks/x-1.0.0/metadata.rb').should_succeed "Updated /cookbooks/x-1.0.0/metadata.rb\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of a modified file succeeds" do + knife("download /cookbooks/x-1.0.0/metadata.rb").should_succeed "Updated /cookbooks/x-1.0.0/metadata.rb\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-1.0.0/y.rb A\t/cookbooks/x-1.0.0/z.rb EOM end - it 'knife download of a deleted file does nothing' do - knife('download /cookbooks/x-1.0.0/z.rb').should_succeed '' - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of a deleted file does nothing" do + knife("download /cookbooks/x-1.0.0/z.rb").should_succeed "" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x-1.0.0/metadata.rb D\t/cookbooks/x-1.0.0/y.rb A\t/cookbooks/x-1.0.0/z.rb EOM end - it 'knife download --purge of a deleted file succeeds' do - knife('download --purge /cookbooks/x-1.0.0/z.rb').should_succeed "Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on)\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download --purge of a deleted file succeeds" do + knife("download --purge /cookbooks/x-1.0.0/z.rb").should_succeed "Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on)\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x-1.0.0/metadata.rb D\t/cookbooks/x-1.0.0/y.rb EOM end - it 'knife download of an added file succeeds' do - knife('download /cookbooks/x-1.0.0/y.rb').should_succeed "Created /cookbooks/x-1.0.0/y.rb\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of an added file succeeds" do + knife("download /cookbooks/x-1.0.0/y.rb").should_succeed "Created /cookbooks/x-1.0.0/y.rb\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x-1.0.0/metadata.rb A\t/cookbooks/x-1.0.0/z.rb EOM end - it 'knife download of the cookbook itself succeeds' do - knife('download /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife download of the cookbook itself succeeds" do + knife("download /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0/metadata.rb Created /cookbooks/x-1.0.0/y.rb EOM - knife('diff --name-status /cookbooks').should_succeed <<EOM + knife("diff --name-status /cookbooks").should_succeed <<EOM A\t/cookbooks/x-1.0.0/z.rb EOM end - it 'knife download --purge of the cookbook itself succeeds' do - knife('download --purge /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife download --purge of the cookbook itself succeeds" do + knife("download --purge /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0/metadata.rb Created /cookbooks/x-1.0.0/y.rb Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x-1.0.0/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the latest version' do - knife('download --purge /cookbooks').should_succeed <<EOM + it "knife download /cookbooks/x downloads the latest version" do + knife("download --purge /cookbooks").should_succeed <<EOM Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb Created /cookbooks/x-1.0.1 Created /cookbooks/x-1.0.1/metadata.rb Created /cookbooks/x-1.0.1/onlyin1.0.1.rb EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife download /cookbooks downloads the updated file' do - knife('download --purge /cookbooks').should_succeed <<EOM + it "knife download /cookbooks downloads the updated file" do + knife("download --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-0.9.9 Created /cookbooks/x-0.9.9/metadata.rb Created /cookbooks/x-0.9.9/onlyin0.9.9.rb Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the latest version' do - knife('download --purge /cookbooks').should_succeed <<EOM + it "knife download /cookbooks/x downloads the latest version" do + knife("download --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-1.0.1 Created /cookbooks/x-1.0.1/metadata.rb Created /cookbooks/x-1.0.1/onlyin1.0.1.rb Deleted extra entry /cookbooks/x-1.0.0 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife download --purge /cookbooks downloads the old version and deletes the new version' do - knife('download --purge /cookbooks').should_succeed <<EOM + it "knife download --purge /cookbooks downloads the old version and deletes the new version" do + knife("download --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-0.9.9 Created /cookbooks/x-0.9.9/metadata.rb Created /cookbooks/x-0.9.9/onlyin0.9.9.rb Deleted extra entry /cookbooks/x-1.0.0 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_chef_server 'has an environment' do + when_the_chef_server "has an environment" do before do - environment 'x', {} + environment "x", {} end - when_the_repository 'has the same environment with the wrong name in the file' do + when_the_repository "has the same environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife download succeeds" do + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has the same environment with no name in the file' do + when_the_repository "has the same environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife download succeeds" do + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end end end # with versioned cookbooks - when_the_chef_server 'has a cookbook' do + when_the_chef_server "has a cookbook" do before do - cookbook 'x', '1.0.0' + cookbook "x", "1.0.0" end - when_the_repository 'is empty' do - it 'knife download /cookbooks/x signs all requests' do + when_the_repository "is empty" do + it "knife download /cookbooks/x signs all requests" do # Check that BasicClient.request() always gets called with X-OPS-USERID original_new = Chef::HTTP::BasicClient.method(:new) @@ -1077,13 +1077,13 @@ EOM new_result = original_new.call(*args) original_request = new_result.method(:request) expect(new_result).to receive(:request) { |method, url, body, headers, &response_handler| - expect(headers['X-OPS-USERID']).not_to be_nil + expect(headers["X-OPS-USERID"]).not_to be_nil original_request.call(method, url, body, headers, &response_handler) }.at_least(:once) new_result }.at_least(:once) - knife('download /cookbooks/x').should_succeed <<EOM + knife("download /cookbooks/x").should_succeed <<EOM Created /cookbooks Created /cookbooks/x Created /cookbooks/x/metadata.rb @@ -1094,19 +1094,19 @@ EOM when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do before do - user 'foo', {} - user 'bar', {} - user 'foobar', {} - organization 'foo', { 'full_name' => 'Something' } + user "foo", {} + user "bar", {} + user "foobar", {} + organization "foo", { "full_name" => "Something" } end before :each do - Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo') + Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo") end when_the_repository "has all the default stuff" do before do - knife('download /').should_succeed <<EOM + knife("download /").should_succeed <<EOM Created /acls Created /acls/clients Created /acls/clients/foo-validator.json @@ -1167,31 +1167,31 @@ Created /roles EOM end - context 'and the server has one of each thing' do + context "and the server has one of each thing" do before do # acl_for %w(organizations foo groups blah) - client 'x', {} - cookbook 'x', '1.0.0' - container 'x', {} - data_bag 'x', { 'y' => {} } - environment 'x', {} - group 'x', {} - org_invite 'foo' - org_member 'bar' - node 'x', {} - policy 'x', '1.0.0', {} - policy 'blah', '1.0.0', {} - policy_group 'x', { - 'policies' => { - 'x' => { 'revision_id' => '1.0.0' }, - 'blah' => { 'revision_id' => '1.0.0' }, + client "x", {} + cookbook "x", "1.0.0" + container "x", {} + data_bag "x", { "y" => {} } + environment "x", {} + group "x", {} + org_invite "foo" + org_member "bar" + node "x", {} + policy "x", "1.0.0", {} + policy "blah", "1.0.0", {} + policy_group "x", { + "policies" => { + "x" => { "revision_id" => "1.0.0" }, + "blah" => { "revision_id" => "1.0.0" }, } } - role 'x', {} + role "x", {} end before do - knife('download /acls /groups/clients.json /groups/users.json').should_succeed <<-EOM + knife("download /acls /groups/clients.json /groups/users.json").should_succeed <<-EOM Created /acls/clients/x.json Created /acls/containers/x.json Created /acls/cookbooks/x.json @@ -1205,8 +1205,8 @@ Updated /groups/users.json EOM end - it 'knife download / downloads everything' do - knife('download /').should_succeed <<EOM + it "knife download / downloads everything" do + knife("download /").should_succeed <<EOM Created /clients/x.json Created /containers/x.json Created /cookbooks/x @@ -1223,58 +1223,58 @@ Created /policies/x-1.0.0.json Created /policy_groups/x.json Created /roles/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end context "and the repository has an identical copy of each thing" do before do # TODO We have to upload acls for an existing group due to a lack of # dependency detection during upload. Fix that! - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'containers/x.json', {} - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/x.json', {} - file 'groups/x.json', {} - file 'invitations.json', [ 'foo' ] - file 'members.json', [ 'bar' ] - file 'nodes/x.json', {} - file 'org.json', { 'full_name' => 'Something' } - file 'policies/x-1.0.0.json', { } - file 'policies/blah-1.0.0.json', { } - file 'policy_groups/x.json', { 'policies' => { 'x' => { 'revision_id' => '1.0.0' }, 'blah' => { 'revision_id' => '1.0.0' } } } - file 'roles/x.json', {} + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "containers/x.json", {} + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/x.json", {} + file "groups/x.json", {} + file "invitations.json", [ "foo" ] + file "members.json", [ "bar" ] + file "nodes/x.json", {} + file "org.json", { "full_name" => "Something" } + file "policies/x-1.0.0.json", { } + file "policies/blah-1.0.0.json", { } + file "policy_groups/x.json", { "policies" => { "x" => { "revision_id" => "1.0.0" }, "blah" => { "revision_id" => "1.0.0" } } } + file "roles/x.json", {} end - it 'knife download makes no changes' do - knife('download /').should_succeed '' + it "knife download makes no changes" do + knife("download /").should_succeed "" end end context "and the repository has a slightly different copy of each thing" do before do # acl_for %w(organizations foo groups blah) - file 'clients/x.json', { 'validator' => true } - file 'containers/x.json', {} - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.1") - file 'data_bags/x/y.json', { 'a' => 'b' } - file 'environments/x.json', { 'description' => 'foo' } - file 'groups/x.json', { 'description' => 'foo' } - file 'groups/x.json', { 'groups' => [ 'admin' ] } - file 'nodes/x.json', { 'run_list' => [ 'blah' ] } - file 'org.json', { 'full_name' => 'Something Else ' } - file 'policies/x-1.0.0.json', { 'run_list' => [ 'blah' ] } - file 'policy_groups/x.json', { - 'policies' => { - 'x' => { 'revision_id' => '1.0.1' }, - 'y' => { 'revision_id' => '1.0.0' }, + file "clients/x.json", { "validator" => true } + file "containers/x.json", {} + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.1") + file "data_bags/x/y.json", { "a" => "b" } + file "environments/x.json", { "description" => "foo" } + file "groups/x.json", { "description" => "foo" } + file "groups/x.json", { "groups" => [ "admin" ] } + file "nodes/x.json", { "run_list" => [ "blah" ] } + file "org.json", { "full_name" => "Something Else " } + file "policies/x-1.0.0.json", { "run_list" => [ "blah" ] } + file "policy_groups/x.json", { + "policies" => { + "x" => { "revision_id" => "1.0.1" }, + "y" => { "revision_id" => "1.0.0" }, } } - file 'roles/x.json', { 'run_list' => [ 'blah' ] } + file "roles/x.json", { "run_list" => [ "blah" ] } end - it 'knife download updates everything' do - knife('download /').should_succeed <<EOM + it "knife download updates everything" do + knife("download /").should_succeed <<EOM Updated /clients/x.json Updated /cookbooks/x/metadata.rb Updated /data_bags/x/y.json @@ -1289,7 +1289,7 @@ Updated /policies/x-1.0.0.json Updated /policy_groups/x.json Updated /roles/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end diff --git a/spec/integration/knife/list_spec.rb b/spec/integration/knife/list_spec.rb index eb2ed279e5..32f5bb43f8 100644 --- a/spec/integration/knife/list_spec.rb +++ b/spec/integration/knife/list_spec.rb @@ -15,11 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/list' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/list" -describe 'knife list', :workstation do +describe "knife list", :workstation do include IntegrationSupport include KnifeSupport @@ -27,7 +27,7 @@ describe 'knife list', :workstation do when_the_chef_server "is empty" do it "knife list / returns all top level directories" do - knife('list /').should_succeed <<-EOM + knife("list /").should_succeed <<-EOM /clients /cookbooks /data_bags @@ -39,7 +39,7 @@ EOM end it "knife list -R / returns everything" do - knife('list -R /').should_succeed <<-EOM + knife("list -R /").should_succeed <<-EOM /: clients cookbooks @@ -72,27 +72,27 @@ EOM when_the_chef_server "has plenty of stuff in it" do before do - client 'client1', {} - client 'client2', {} - cookbook 'cookbook1', '1.0.0' - cookbook 'cookbook2', '1.0.1', { 'recipes' => { 'default.rb' => '' } } - data_bag 'bag1', { 'item1' => {}, 'item2' => {} } - data_bag 'bag2', { 'item1' => {}, 'item2' => {} } - environment 'environment1', {} - environment 'environment2', {} - node 'node1', {} - node 'node2', {} - policy 'policy1', '1.2.3', {} - policy 'policy2', '1.2.3', {} - policy 'policy2', '1.3.5', {} - role 'role1', {} - role 'role2', {} - user 'user1', {} - user 'user2', {} + client "client1", {} + client "client2", {} + cookbook "cookbook1", "1.0.0" + cookbook "cookbook2", "1.0.1", { "recipes" => { "default.rb" => "" } } + data_bag "bag1", { "item1" => {}, "item2" => {} } + data_bag "bag2", { "item1" => {}, "item2" => {} } + environment "environment1", {} + environment "environment2", {} + node "node1", {} + node "node2", {} + policy "policy1", "1.2.3", {} + policy "policy2", "1.2.3", {} + policy "policy2", "1.3.5", {} + role "role1", {} + role "role2", {} + user "user1", {} + user "user2", {} end it "knife list / returns all top level directories" do - knife('list /').should_succeed <<-EOM + knife("list /").should_succeed <<-EOM /clients /cookbooks /data_bags @@ -104,7 +104,7 @@ EOM end it "knife list -R / returns everything" do - knife('list -R /').should_succeed <<-EOM + knife("list -R /").should_succeed <<-EOM /: clients cookbooks @@ -167,7 +167,7 @@ EOM end it "knife list -R --flat / returns everything" do - knife('list -R --flat /').should_succeed <<-EOM + knife("list -R --flat /").should_succeed <<-EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -205,7 +205,7 @@ EOM end it "knife list -Rfp / returns everything" do - knife('list -Rfp /').should_succeed <<-EOM + knife("list -Rfp /").should_succeed <<-EOM /clients/ /clients/chef-validator.json /clients/chef-webui.json @@ -243,18 +243,18 @@ EOM end it "knife list /cookbooks returns the list of cookbooks" do - knife('list /cookbooks').should_succeed <<-EOM + knife("list /cookbooks").should_succeed <<-EOM /cookbooks/cookbook1 /cookbooks/cookbook2 EOM end it "knife list /cookbooks/*2/*/*.rb returns the one file" do - knife('list /cookbooks/*2/*/*.rb').should_succeed "/cookbooks/cookbook2/recipes/default.rb\n" + knife("list /cookbooks/*2/*/*.rb").should_succeed "/cookbooks/cookbook2/recipes/default.rb\n" end it "knife list /**.rb returns all ruby files" do - knife('list /**.rb').should_succeed <<-EOM + knife("list /**.rb").should_succeed <<-EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/metadata.rb /cookbooks/cookbook2/recipes/default.rb @@ -262,7 +262,7 @@ EOM end it "knife list /cookbooks/**.rb returns all ruby files" do - knife('list /cookbooks/**.rb').should_succeed <<-EOM + knife("list /cookbooks/**.rb").should_succeed <<-EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/metadata.rb /cookbooks/cookbook2/recipes/default.rb @@ -270,7 +270,7 @@ EOM end it "knife list /**.json returns all json files" do - knife('list /**.json').should_succeed <<-EOM + knife("list /**.json").should_succeed <<-EOM /clients/chef-validator.json /clients/chef-webui.json /clients/client1.json @@ -293,7 +293,7 @@ EOM end it "knife list /data**.json returns all data bag json files" do - knife('list /data**.json').should_succeed <<-EOM + knife("list /data**.json").should_succeed <<-EOM /data_bags/bag1/item1.json /data_bags/bag1/item2.json /data_bags/bag2/item1.json @@ -302,30 +302,30 @@ EOM end it "knife list /environments/missing_file.json reports missing file" do - knife('list /environments/missing_file.json').should_fail "ERROR: /environments/missing_file.json: No such file or directory\n" + knife("list /environments/missing_file.json").should_fail "ERROR: /environments/missing_file.json: No such file or directory\n" end context "missing file/directory exact match tests" do it "knife list /blarghle reports missing directory" do - knife('list /blarghle').should_fail "ERROR: /blarghle: No such file or directory\n" + knife("list /blarghle").should_fail "ERROR: /blarghle: No such file or directory\n" end it "knife list /roles/blarghle reports missing directory" do - knife('list /roles/blarghle').should_fail "ERROR: /roles/blarghle: No such file or directory\n" + knife("list /roles/blarghle").should_fail "ERROR: /roles/blarghle: No such file or directory\n" end it "knife list /roles/blarghle/blorghle reports missing directory" do - knife('list /roles/blarghle/blorghle').should_fail "ERROR: /roles/blarghle/blorghle: No such file or directory\n" + knife("list /roles/blarghle/blorghle").should_fail "ERROR: /roles/blarghle/blorghle: No such file or directory\n" end end - context 'symlink tests' do - when_the_repository 'is empty' do - context 'when cwd is at the top of the repository' do - before { cwd '.' } + context "symlink tests" do + when_the_repository "is empty" do + context "when cwd is at the top of the repository" do + before { cwd "." } it "knife list -Rfp returns everything" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM clients/ clients/chef-validator.json clients/chef-webui.json @@ -364,13 +364,13 @@ EOM end end - when_the_repository 'has a cookbooks directory' do - before { directory 'cookbooks' } - context 'when cwd is in cookbooks/' do - before { cwd 'cookbooks' } + when_the_repository "has a cookbooks directory" do + before { directory "cookbooks" } + context "when cwd is in cookbooks/" do + before { cwd "cookbooks" } it "knife list -Rfp / returns everything" do - knife('list -Rfp /').should_succeed <<-EOM + knife("list -Rfp /").should_succeed <<-EOM /clients/ /clients/chef-validator.json /clients/chef-webui.json @@ -408,7 +408,7 @@ EOM end it "knife list -Rfp .. returns everything" do - knife('list -Rfp ..').should_succeed <<-EOM + knife("list -Rfp ..").should_succeed <<-EOM /clients/ /clients/chef-validator.json /clients/chef-webui.json @@ -446,7 +446,7 @@ EOM end it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -458,14 +458,14 @@ EOM end end - when_the_repository 'has a cookbooks/cookbook2 directory' do - before { directory 'cookbooks/cookbook2' } + when_the_repository "has a cookbooks/cookbook2 directory" do + before { directory "cookbooks/cookbook2" } - context 'when cwd is in cookbooks/cookbook2' do - before { cwd 'cookbooks/cookbook2' } + context "when cwd is in cookbooks/cookbook2" do + before { cwd "cookbooks/cookbook2" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM metadata.rb recipes/ recipes/default.rb @@ -474,17 +474,17 @@ EOM end end - when_the_repository 'has a cookbooks directory and a symlinked cookbooks directory', :skip => (Chef::Platform.windows?) do + when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", :skip => (Chef::Platform.windows?) do before do - directory 'cookbooks' - symlink 'symlinked', 'cookbooks' + directory "cookbooks" + symlink "symlinked", "cookbooks" end - context 'when cwd is in cookbooks/' do - before { cwd 'cookbooks' } + context "when cwd is in cookbooks/" do + before { cwd "cookbooks" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -495,11 +495,11 @@ EOM end end - context 'when cwd is in symlinked/' do - before { cwd 'symlinked' } + context "when cwd is in symlinked/" do + before { cwd "symlinked" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -511,17 +511,17 @@ EOM end end - when_the_repository 'has a real_cookbooks directory and a cookbooks symlink to it', :skip => (Chef::Platform.windows?) do + when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", :skip => (Chef::Platform.windows?) do before do - directory 'real_cookbooks' - symlink 'cookbooks', 'real_cookbooks' + directory "real_cookbooks" + symlink "cookbooks", "real_cookbooks" end - context 'when cwd is in real_cookbooks/' do - before { cwd 'real_cookbooks' } + context "when cwd is in real_cookbooks/" do + before { cwd "real_cookbooks" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -532,11 +532,11 @@ EOM end end - context 'when cwd is in cookbooks/' do - before { cwd 'cookbooks' } + context "when cwd is in cookbooks/" do + before { cwd "cookbooks" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -553,51 +553,51 @@ EOM context "--local" do when_the_repository "is empty" do it "knife list --local / returns nothing" do - knife('list --local /').should_succeed "" + knife("list --local /").should_succeed "" end it "knife list /roles returns nothing" do - knife('list --local /roles').should_fail "ERROR: /roles: No such file or directory\n" + knife("list --local /roles").should_fail "ERROR: /roles: No such file or directory\n" end end when_the_repository "has a bunch of stuff" do before do - file 'clients/client1.json', {} - file 'clients/client2.json', {} + file "clients/client1.json", {} + file "clients/client2.json", {} - directory 'cookbooks/cookbook1' do - file 'metadata.rb', cb_metadata("cookbook1", "1.0.0") + directory "cookbooks/cookbook1" do + file "metadata.rb", cb_metadata("cookbook1", "1.0.0") end - directory 'cookbooks/cookbook2' do - file 'metadata.rb', cb_metadata("cookbook2", "2.0.0") - file 'recipes/default.rb', '' + directory "cookbooks/cookbook2" do + file "metadata.rb", cb_metadata("cookbook2", "2.0.0") + file "recipes/default.rb", "" end - directory 'data_bags' do - directory 'bag1' do - file 'item1.json', {} - file 'item2.json', {} + directory "data_bags" do + directory "bag1" do + file "item1.json", {} + file "item2.json", {} end - directory 'bag2' do - file 'item1.json', {} - file 'item2.json', {} + directory "bag2" do + file "item1.json", {} + file "item2.json", {} end end - file 'environments/environment1.json', {} - file 'environments/environment2.json', {} - file 'nodes/node1.json', {} - file 'nodes/node2.json', {} + file "environments/environment1.json", {} + file "environments/environment2.json", {} + file "nodes/node1.json", {} + file "nodes/node2.json", {} - file 'roles/role1.json', {} - file 'roles/role2.json', {} - file 'users/user1.json', {} - file 'users/user2.json', {} + file "roles/role1.json", {} + file "roles/role2.json", {} + file "users/user1.json", {} + file "users/user2.json", {} end it "knife list -Rfp / returns everything" do - knife('list -Rp --local --flat /').should_succeed <<-EOM + knife("list -Rp --local --flat /").should_succeed <<-EOM /clients/ /clients/client1.json /clients/client2.json @@ -632,15 +632,15 @@ EOM context "missing file/directory tests" do it "knife list --local /blarghle reports missing directory" do - knife('list --local /blarghle').should_fail "ERROR: /blarghle: No such file or directory\n" + knife("list --local /blarghle").should_fail "ERROR: /blarghle: No such file or directory\n" end it "knife list /roles/blarghle reports missing directory" do - knife('list --local /roles/blarghle').should_fail "ERROR: /roles/blarghle: No such file or directory\n" + knife("list --local /roles/blarghle").should_fail "ERROR: /roles/blarghle: No such file or directory\n" end it "knife list /roles/blarghle/blorghle reports missing directory" do - knife('list --local /roles/blarghle/blorghle').should_fail "ERROR: /roles/blarghle/blorghle: No such file or directory\n" + knife("list --local /roles/blarghle/blorghle").should_fail "ERROR: /roles/blarghle/blorghle: No such file or directory\n" end end end @@ -648,16 +648,16 @@ EOM when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do before do - organization 'foo' + organization "foo" end before :each do - Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo') + Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo") end - context 'and is empty' do + context "and is empty" do it "knife list / returns all top level directories" do - knife('list /').should_succeed <<-EOM + knife("list /").should_succeed <<-EOM /acls /clients /containers @@ -676,7 +676,7 @@ EOM end it "knife list -R / returns everything" do - knife('list -R /').should_succeed <<-EOM + knife("list -R /").should_succeed <<-EOM /: acls clients @@ -777,8 +777,8 @@ EOM end end - it 'knife list -R / returns everything' do - knife('list -R /').should_succeed <<-EOM + it "knife list -R / returns everything" do + knife("list -R /").should_succeed <<-EOM /: acls clients @@ -880,35 +880,35 @@ EOM context "has plenty of stuff in it" do before do - client 'client1', {} - client 'client2', {} - container 'container1', {} - container 'container2', {} - cookbook 'cookbook1', '1.0.0' - cookbook 'cookbook2', '1.0.1', { 'recipes' => { 'default.rb' => '' } } - data_bag 'bag1', { 'item1' => {}, 'item2' => {} } - data_bag 'bag2', { 'item1' => {}, 'item2' => {} } - environment 'environment1', {} - environment 'environment2', {} - group 'group1', {} - group 'group2', {} - node 'node1', {} - node 'node2', {} - org_invite 'user1' - org_member 'user2' - policy 'policy1', '1.2.3', {} - policy 'policy2', '1.2.3', {} - policy 'policy2', '1.3.5', {} - policy_group 'policy_group1', { 'policies' => { 'policy1' => { 'revision_id' => '1.2.3' } } } - policy_group 'policy_group2', { 'policies' => { 'policy2' => { 'revision_id' => '1.3.5' } } } - role 'role1', {} - role 'role2', {} - user 'user1', {} - user 'user2', {} + client "client1", {} + client "client2", {} + container "container1", {} + container "container2", {} + cookbook "cookbook1", "1.0.0" + cookbook "cookbook2", "1.0.1", { "recipes" => { "default.rb" => "" } } + data_bag "bag1", { "item1" => {}, "item2" => {} } + data_bag "bag2", { "item1" => {}, "item2" => {} } + environment "environment1", {} + environment "environment2", {} + group "group1", {} + group "group2", {} + node "node1", {} + node "node2", {} + org_invite "user1" + org_member "user2" + policy "policy1", "1.2.3", {} + policy "policy2", "1.2.3", {} + policy "policy2", "1.3.5", {} + policy_group "policy_group1", { "policies" => { "policy1" => { "revision_id" => "1.2.3" } } } + policy_group "policy_group2", { "policies" => { "policy2" => { "revision_id" => "1.3.5" } } } + role "role1", {} + role "role2", {} + user "user1", {} + user "user2", {} end it "knife list -Rfp / returns everything" do - knife('list -Rfp /').should_succeed <<-EOM + knife("list -Rfp /").should_succeed <<-EOM /acls/ /acls/clients/ /acls/clients/client1.json diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb index 75fc8fa55e..92b972b87b 100644 --- a/spec/integration/knife/raw_spec.rb +++ b/spec/integration/knife/raw_spec.rb @@ -15,12 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/raw' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/raw" +require "chef/knife/show" -describe 'knife raw', :workstation do +describe "knife raw", :workstation do include IntegrationSupport include KnifeSupport include AppServerSupport @@ -29,17 +29,17 @@ describe 'knife raw', :workstation do when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - it 'knife raw /nodes/x returns the node', :skip => (RUBY_VERSION < "1.9") do - knife('raw /nodes/x').should_succeed <<EOM + it "knife raw /nodes/x returns the node", :skip => (RUBY_VERSION < "1.9") do + knife("raw /nodes/x").should_succeed <<EOM { "name": "x", "json_class": "Chef::Node", @@ -64,12 +64,12 @@ describe 'knife raw', :workstation do EOM end - it 'knife raw /blarghle returns 404' do - knife('raw /blarghle').should_fail(/ERROR: Server responded with error 404 "Not Found\s*"/) + it "knife raw /blarghle returns 404" do + knife("raw /blarghle").should_fail(/ERROR: Server responded with error 404 "Not Found\s*"/) end - it 'knife raw -m DELETE /roles/x succeeds', :skip => (RUBY_VERSION < "1.9") do - knife('raw -m DELETE /roles/x').should_succeed <<EOM + it "knife raw -m DELETE /roles/x succeeds", :skip => (RUBY_VERSION < "1.9") do + knife("raw -m DELETE /roles/x").should_succeed <<EOM { "name": "x", "description": "", @@ -89,11 +89,11 @@ EOM } } EOM - knife('show /roles/x.json').should_fail "ERROR: /roles/x.json: No such file or directory\n" + knife("show /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n" end - it 'knife raw -m PUT -i blah.txt /roles/x succeeds', :skip => (RUBY_VERSION < "1.9") do - Tempfile.open('raw_put_input') do |file| + it "knife raw -m PUT -i blah.txt /roles/x succeeds", :skip => (RUBY_VERSION < "1.9") do + Tempfile.open("raw_put_input") do |file| file.write <<EOM { "name": "x", @@ -136,7 +136,7 @@ EOM } } EOM - knife('show /roles/x.json').should_succeed <<EOM + knife("show /roles/x.json").should_succeed <<EOM /roles/x.json: { "name": "x", @@ -146,8 +146,8 @@ EOM end end - it 'knife raw -m POST -i blah.txt /roles succeeds', :skip => (RUBY_VERSION < "1.9") do - Tempfile.open('raw_put_input') do |file| + it "knife raw -m POST -i blah.txt /roles succeeds", :skip => (RUBY_VERSION < "1.9") do + Tempfile.open("raw_put_input") do |file| file.write <<EOM { "name": "y", @@ -172,7 +172,7 @@ EOM "uri": "#{Chef::Config.chef_server_url}/roles/y" } EOM - knife('show /roles/y.json').should_succeed <<EOM + knife("show /roles/y.json").should_succeed <<EOM /roles/y.json: { "name": "y", @@ -182,11 +182,11 @@ EOM end end - context 'When a server returns raw json' do + context "When a server returns raw json" do before :each do Chef::Config.chef_server_url = "http://localhost:9018" app = lambda do |env| - [200, {'Content-Type' => 'application/json' }, ['{ "x": "y", "a": "b" }'] ] + [200, {"Content-Type" => "application/json" }, ['{ "x": "y", "a": "b" }'] ] end @raw_server, @raw_server_thread = start_app_server(app, 9018) end @@ -196,8 +196,8 @@ EOM @raw_server_thread.kill if @raw_server_thread end - it 'knife raw /blah returns the prettified json', :skip => (RUBY_VERSION < "1.9") do - knife('raw /blah').should_succeed <<EOM + it "knife raw /blah returns the prettified json", :skip => (RUBY_VERSION < "1.9") do + knife("raw /blah").should_succeed <<EOM { "x": "y", "a": "b" @@ -205,18 +205,18 @@ EOM EOM end - it 'knife raw --no-pretty /blah returns the raw json' do - knife('raw --no-pretty /blah').should_succeed <<EOM + it "knife raw --no-pretty /blah returns the raw json" do + knife("raw --no-pretty /blah").should_succeed <<EOM { "x": "y", "a": "b" } EOM end end - context 'When a server returns text' do + context "When a server returns text" do before :each do Chef::Config.chef_server_url = "http://localhost:9018" app = lambda do |env| - [200, {'Content-Type' => 'text' }, ['{ "x": "y", "a": "b" }'] ] + [200, {"Content-Type" => "text" }, ['{ "x": "y", "a": "b" }'] ] end @raw_server, @raw_server_thread = start_app_server(app, 9018) end @@ -226,14 +226,14 @@ EOM @raw_server_thread.kill if @raw_server_thread end - it 'knife raw /blah returns the raw text' do - knife('raw /blah').should_succeed(<<EOM) + it "knife raw /blah returns the raw text" do + knife("raw /blah").should_succeed(<<EOM) { "x": "y", "a": "b" } EOM end - it 'knife raw --no-pretty /blah returns the raw text' do - knife('raw --no-pretty /blah').should_succeed(<<EOM) + it "knife raw --no-pretty /blah returns the raw text" do + knife("raw --no-pretty /blah").should_succeed(<<EOM) { "x": "y", "a": "b" } EOM end diff --git a/spec/integration/knife/redirection_spec.rb b/spec/integration/knife/redirection_spec.rb index 77bda99453..ee12e85314 100644 --- a/spec/integration/knife/redirection_spec.rb +++ b/spec/integration/knife/redirection_spec.rb @@ -15,26 +15,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/list' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/list" -describe 'redirection', :workstation do +describe "redirection", :workstation do include IntegrationSupport include KnifeSupport include AppServerSupport include_context "default config options" - when_the_chef_server 'has a role' do - before { role 'x', {} } + when_the_chef_server "has a role" do + before { role "x", {} } - context 'and another server redirects to it with 302' do + context "and another server redirects to it with 302" do before :each do real_chef_server_url = Chef::Config.chef_server_url Chef::Config.chef_server_url = "http://localhost:9018" app = lambda do |env| - [302, {'Content-Type' => 'text','Location' => "#{real_chef_server_url}#{env['PATH_INFO']}" }, ['302 found'] ] + [302, {"Content-Type" => "text","Location" => "#{real_chef_server_url}#{env['PATH_INFO']}" }, ["302 found"] ] end @redirector_server, @redirector_server_thread = start_app_server(app, 9018) end @@ -44,8 +44,8 @@ describe 'redirection', :workstation do @redirector_thread.kill if @redirector_thread end - it 'knife list /roles returns the role' do - knife('list /roles').should_succeed "/roles/x.json\n" + it "knife list /roles returns the role" do + knife("list /roles").should_succeed "/roles/x.json\n" end end end diff --git a/spec/integration/knife/serve_spec.rb b/spec/integration/knife/serve_spec.rb index 7bf7d29b40..74b47c0fe3 100644 --- a/spec/integration/knife/serve_spec.rb +++ b/spec/integration/knife/serve_spec.rb @@ -15,34 +15,34 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/serve' -require 'chef/server_api' +require "support/shared/integration/integration_helper" +require "chef/knife/serve" +require "chef/server_api" -describe 'knife serve', :workstation do +describe "knife serve", :workstation do include IntegrationSupport include KnifeSupport include AppServerSupport - when_the_repository 'also has one of each thing' do - before { file 'nodes/x.json', { 'foo' => 'bar' } } + when_the_repository "also has one of each thing" do + before { file "nodes/x.json", { "foo" => "bar" } } - it 'knife serve serves up /nodes/x' do + it "knife serve serves up /nodes/x" do exception = nil t = Thread.new do begin - knife('serve --chef-zero-port=8890') + knife("serve --chef-zero-port=8890") rescue exception = $! end end begin Chef::Config.log_level = :debug - Chef::Config.chef_server_url = 'http://localhost:8890' + Chef::Config.chef_server_url = "http://localhost:8890" Chef::Config.node_name = nil Chef::Config.client_key = nil api = Chef::ServerAPI.new - expect(api.get('nodes/x')['name']).to eq('x') + expect(api.get("nodes/x")["name"]).to eq("x") rescue if exception raise exception diff --git a/spec/integration/knife/show_spec.rb b/spec/integration/knife/show_spec.rb index fad5126f66..06183243ee 100644 --- a/spec/integration/knife/show_spec.rb +++ b/spec/integration/knife/show_spec.rb @@ -15,11 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/show" -describe 'knife show', :workstation do +describe "knife show", :workstation do include IntegrationSupport include KnifeSupport @@ -27,81 +27,81 @@ describe 'knife show', :workstation do when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - when_the_repository 'also has one of each thing' do + when_the_repository "also has one of each thing" do before do - file 'clients/x.json', { 'foo' => 'bar' } - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') - file 'data_bags/x/y.json', { 'foo' => 'bar' } - file 'environments/_default.json', { 'foo' => 'bar' } - file 'environments/x.json', { 'foo' => 'bar' } - file 'nodes/x.json', { 'foo' => 'bar' } - file 'roles/x.json', { 'foo' => 'bar' } - file 'users/x.json', { 'foo' => 'bar' } + file "clients/x.json", { "foo" => "bar" } + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", { "foo" => "bar" } + file "environments/_default.json", { "foo" => "bar" } + file "environments/x.json", { "foo" => "bar" } + file "nodes/x.json", { "foo" => "bar" } + file "roles/x.json", { "foo" => "bar" } + file "users/x.json", { "foo" => "bar" } end - it 'knife show /cookbooks/x/metadata.rb shows the remote version' do - knife('show /cookbooks/x/metadata.rb').should_succeed <<EOM + it "knife show /cookbooks/x/metadata.rb shows the remote version" do + knife("show /cookbooks/x/metadata.rb").should_succeed <<EOM /cookbooks/x/metadata.rb: name "x"; version "1.0.0" EOM end - it 'knife show --local /cookbooks/x/metadata.rb shows the local version' do - knife('show --local /cookbooks/x/metadata.rb').should_succeed <<EOM + it "knife show --local /cookbooks/x/metadata.rb shows the local version" do + knife("show --local /cookbooks/x/metadata.rb").should_succeed <<EOM /cookbooks/x/metadata.rb: name "x"; version "1.0.0" EOM end - it 'knife show /data_bags/x/y.json shows the remote version' do - knife('show /data_bags/x/y.json').should_succeed <<EOM + it "knife show /data_bags/x/y.json shows the remote version" do + knife("show /data_bags/x/y.json").should_succeed <<EOM /data_bags/x/y.json: { "id": "y" } EOM end - it 'knife show --local /data_bags/x/y.json shows the local version' do - knife('show --local /data_bags/x/y.json').should_succeed <<EOM + it "knife show --local /data_bags/x/y.json shows the local version" do + knife("show --local /data_bags/x/y.json").should_succeed <<EOM /data_bags/x/y.json: { "foo": "bar" } EOM end - it 'knife show /environments/x.json shows the remote version', :skip => (RUBY_VERSION < "1.9") do - knife('show /environments/x.json').should_succeed <<EOM + it "knife show /environments/x.json shows the remote version", :skip => (RUBY_VERSION < "1.9") do + knife("show /environments/x.json").should_succeed <<EOM /environments/x.json: { "name": "x" } EOM end - it 'knife show --local /environments/x.json shows the local version' do - knife('show --local /environments/x.json').should_succeed <<EOM + it "knife show --local /environments/x.json shows the local version" do + knife("show --local /environments/x.json").should_succeed <<EOM /environments/x.json: { "foo": "bar" } EOM end - it 'knife show /roles/x.json shows the remote version', :skip => (RUBY_VERSION < "1.9") do - knife('show /roles/x.json').should_succeed <<EOM + it "knife show /roles/x.json shows the remote version", :skip => (RUBY_VERSION < "1.9") do + knife("show /roles/x.json").should_succeed <<EOM /roles/x.json: { "name": "x" } EOM end - it 'knife show --local /roles/x.json shows the local version' do - knife('show --local /roles/x.json').should_succeed <<EOM + it "knife show --local /roles/x.json shows the local version" do + knife("show --local /roles/x.json").should_succeed <<EOM /roles/x.json: { "foo": "bar" @@ -109,34 +109,34 @@ EOM EOM end # show directory - it 'knife show /data_bags/x fails' do - knife('show /data_bags/x').should_fail "ERROR: /data_bags/x: is a directory\n" + it "knife show /data_bags/x fails" do + knife("show /data_bags/x").should_fail "ERROR: /data_bags/x: is a directory\n" end - it 'knife show --local /data_bags/x fails' do - knife('show --local /data_bags/x').should_fail "ERROR: /data_bags/x: is a directory\n" + it "knife show --local /data_bags/x fails" do + knife("show --local /data_bags/x").should_fail "ERROR: /data_bags/x: is a directory\n" end # show nonexistent file - it 'knife show /environments/nonexistent.json fails' do - knife('show /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + it "knife show /environments/nonexistent.json fails" do + knife("show /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" end - it 'knife show --local /environments/nonexistent.json fails' do - knife('show --local /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + it "knife show --local /environments/nonexistent.json fails" do + knife("show --local /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" end end end - when_the_chef_server 'has a hash with multiple keys' do + when_the_chef_server "has a hash with multiple keys" do before do - environment 'x', { - 'default_attributes' => { 'foo' => 'bar' }, - 'cookbook_versions' => { 'blah' => '= 1.0.0'}, - 'override_attributes' => { 'x' => 'y' }, - 'description' => 'woo', - 'name' => 'x', + environment "x", { + "default_attributes" => { "foo" => "bar" }, + "cookbook_versions" => { "blah" => "= 1.0.0"}, + "override_attributes" => { "x" => "y" }, + "description" => "woo", + "name" => "x", } end - it 'knife show shows the attributes in a predetermined order', :skip => (RUBY_VERSION < "1.9") do - knife('show /environments/x.json').should_succeed <<EOM + it "knife show shows the attributes in a predetermined order", :skip => (RUBY_VERSION < "1.9") do + knife("show /environments/x.json").should_succeed <<EOM /environments/x.json: { "name": "x", @@ -155,10 +155,10 @@ EOM end end - when_the_repository 'has an environment with bad JSON' do - before { file 'environments/x.json', '{' } - it 'knife show succeeds' do - knife('show --local /environments/x.json').should_succeed <<EOM + when_the_repository "has an environment with bad JSON" do + before { file "environments/x.json", "{" } + it "knife show succeeds" do + knife("show --local /environments/x.json").should_succeed <<EOM /environments/x.json: { EOM diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb index 6b7679de44..79dae99acf 100644 --- a/spec/integration/knife/upload_spec.rb +++ b/spec/integration/knife/upload_spec.rb @@ -15,44 +15,44 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/upload' -require 'chef/knife/diff' -require 'chef/knife/raw' -require 'chef/json_compat' +require "support/shared/integration/integration_helper" +require "chef/knife/upload" +require "chef/knife/diff" +require "chef/knife/raw" +require "chef/json_compat" -describe 'knife upload', :workstation do +describe "knife upload", :workstation do include IntegrationSupport include KnifeSupport - context 'without versioned cookbooks' do + context "without versioned cookbooks" do when_the_chef_server "has one of each thing" do before do - client 'x', {} - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => {} } - environment 'x', {} - node 'x', {} - role 'x', {} - user 'x', {} + client "x", {} + cookbook "x", "1.0.0" + data_bag "x", { "y" => {} } + environment "x", {} + node "x", {} + role "x", {} + user "x", {} end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' - end - - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" + end + + it "knife upload does nothing" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM D\t/clients/chef-validator.json D\t/clients/chef-webui.json D\t/clients/x.json @@ -67,8 +67,8 @@ D\t/users/x.json EOM end - it 'knife upload --purge deletes everything' do - knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") + it "knife upload --purge deletes everything" do + knife("upload --purge /").should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") Deleted extra entry /clients/chef-validator.json (purge is on) Deleted extra entry /clients/chef-webui.json (purge is on) Deleted extra entry /clients/x.json (purge is on) @@ -80,56 +80,56 @@ Deleted extra entry /roles/x.json (purge is on) Deleted extra entry /users/admin.json (purge is on) Deleted extra entry /users/x.json (purge is on) EOM - knife('diff --name-status /').should_succeed <<EOM + knife("diff --name-status /").should_succeed <<EOM D\t/environments/_default.json EOM end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife upload makes no changes' do - knife('upload /cookbooks/x').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload makes no changes" do + knife("upload /cookbooks/x").should_succeed "" + knife("diff --name-status /").should_succeed "" end - it 'knife upload --purge makes no changes' do - knife('upload --purge /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload --purge makes no changes" do + knife("upload --purge /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', { 'description' => 'blarghle' } + file "roles/x.json", { "description" => "blarghle" } end - it 'knife upload changes the role' do - knife('upload /').should_succeed "Updated /roles/x.json\n" - knife('diff --name-status /').should_succeed '' + it "knife upload changes the role" do + knife("upload /").should_succeed "Updated /roles/x.json\n" + knife("diff --name-status /").should_succeed "" end - it 'knife upload --no-diff does not change the role' do - knife('upload --no-diff /').should_succeed '' - knife('diff --name-status /').should_succeed "M\t/roles/x.json\n" + it "knife upload --no-diff does not change the role" do + knife("upload --no-diff /").should_succeed "" + knife("diff --name-status /").should_succeed "M\t/roles/x.json\n" end end - context 'except the role file is textually different, but not ACTUALLY different' do + context "except the role file is textually different, but not ACTUALLY different" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role", "default_attributes": { @@ -148,45 +148,45 @@ EOM EOM end - it 'knife upload / does not change anything' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload / does not change anything" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed "" end end - context 'when cookbook metadata has a self-dependency' do + context "when cookbook metadata has a self-dependency" do before do - file 'cookbooks/x/metadata.rb', "name 'x'; version '1.0.0'; depends 'x'" + file "cookbooks/x/metadata.rb", "name 'x'; version '1.0.0'; depends 'x'" end it "should warn", :chef_lt_13_only do - knife('upload /cookbooks').should_succeed( + knife("upload /cookbooks").should_succeed( stdout: "Updated /cookbooks/x\n", stderr: "WARN: Ignoring self-dependency in cookbook x, please remove it (in the future this will be fatal).\n", ) - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end it "should fail in Chef 13", :chef_gte_13_only do - knife('upload /cookbooks').should_fail '' + knife("upload /cookbooks").should_fail "" # FIXME: include the error message here end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/blah.rb', '' - file 'cookbooks/y/metadata.rb', cb_metadata("y", "1.0.0") - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/blah.rb", "" + file "cookbooks/y/metadata.rb", cb_metadata("y", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife upload adds the new files' do - knife('upload /').should_succeed <<EOM + it "knife upload adds the new files" do + knife("upload /").should_succeed <<EOM Created /clients/y.json Updated /cookbooks/x Created /cookbooks/y @@ -198,11 +198,11 @@ Created /nodes/y.json Created /roles/y.json Created /users/y.json EOM - knife('diff /').should_succeed '' + knife("diff /").should_succeed "" end - it 'knife upload --no-diff adds the new files' do - knife('upload --no-diff /').should_succeed <<EOM + it "knife upload --no-diff adds the new files" do + knife("upload --no-diff /").should_succeed <<EOM Created /clients/y.json Updated /cookbooks/x Created /cookbooks/y @@ -214,15 +214,15 @@ Created /nodes/y.json Created /roles/y.json Created /users/y.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end - when_the_repository 'is empty' do - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife upload does nothing" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -233,8 +233,8 @@ D\t/users EOM end - it 'knife upload --purge deletes nothing' do - knife('upload --purge /').should_fail <<EOM + it "knife upload --purge deletes nothing" do + knife("upload --purge /").should_fail <<EOM ERROR: /clients cannot be deleted. ERROR: /cookbooks cannot be deleted. ERROR: /data_bags cannot be deleted. @@ -243,7 +243,7 @@ ERROR: /nodes cannot be deleted. ERROR: /roles cannot be deleted. ERROR: /users cannot be deleted. EOM - knife('diff --name-status /').should_succeed <<EOM + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -254,178 +254,178 @@ D\t/users EOM end - context 'when current directory is top level' do + context "when current directory is top level" do before do - cwd '.' + cwd "." end - it 'knife upload with no parameters reports an error' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + it "knife upload with no parameters reports an error" do + knife("upload").should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end end end end - when_the_chef_server 'is empty' do - when_the_repository 'has a data bag item' do + when_the_chef_server "is empty" do + when_the_repository "has a data bag item" do before do - file 'data_bags/x/y.json', { 'foo' => 'bar' } + file "data_bags/x/y.json", { "foo" => "bar" } end - it 'knife upload of the data bag uploads only the values in the data bag item and no other' do - knife('upload /data_bags/x/y.json').should_succeed <<EOM + it "knife upload of the data bag uploads only the values in the data bag item and no other" do + knife("upload /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM EOM - expect(Chef::JSONCompat.parse(knife('raw /data/x/y').stdout, :create_additions => false).keys.sort).to eq([ 'foo', 'id' ]) + expect(Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, :create_additions => false).keys.sort).to eq([ "foo", "id" ]) end - it 'knife upload /data_bags/x /data_bags/x/y.json uploads x once' do - knife('upload /data_bags/x /data_bags/x/y.json').should_succeed <<EOM + it "knife upload /data_bags/x /data_bags/x/y.json uploads x once" do + knife("upload /data_bags/x /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM end end - when_the_repository 'has a data bag item with keys chef_type and data_bag' do + when_the_repository "has a data bag item with keys chef_type and data_bag" do before do - file 'data_bags/x/y.json', { 'chef_type' => 'aaa', 'data_bag' => 'bbb' } + file "data_bags/x/y.json", { "chef_type" => "aaa", "data_bag" => "bbb" } end - it 'upload preserves chef_type and data_bag' do - knife('upload /data_bags/x/y.json').should_succeed <<EOM + it "upload preserves chef_type and data_bag" do + knife("upload /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed '' - result = Chef::JSONCompat.parse(knife('raw /data/x/y').stdout, :create_additions => false) - expect(result.keys.sort).to eq([ 'chef_type', 'data_bag', 'id' ]) - expect(result['chef_type']).to eq('aaa') - expect(result['data_bag']).to eq('bbb') + knife("diff --name-status /data_bags").should_succeed "" + result = Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, :create_additions => false) + expect(result.keys.sort).to eq([ "chef_type", "data_bag", "id" ]) + expect(result["chef_type"]).to eq("aaa") + expect(result["data_bag"]).to eq("bbb") end end # Test upload of an item when the other end doesn't even have the container - when_the_repository 'has two data bag items' do + when_the_repository "has two data bag items" do before do - file 'data_bags/x/y.json', {} - file 'data_bags/x/z.json', {} + file "data_bags/x/y.json", {} + file "data_bags/x/z.json", {} end - it 'knife upload of one data bag item itself succeeds' do - knife('upload /data_bags/x/y.json').should_succeed <<EOM + it "knife upload of one data bag item itself succeeds" do + knife("upload /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM A\t/data_bags/x/z.json EOM end end end - when_the_chef_server 'has three data bag items' do + when_the_chef_server "has three data bag items" do before do - data_bag 'x', { 'deleted' => {}, 'modified' => {}, 'unmodified' => {} } + data_bag "x", { "deleted" => {}, "modified" => {}, "unmodified" => {} } end - when_the_repository 'has a modified, unmodified, added and deleted data bag item' do + when_the_repository "has a modified, unmodified, added and deleted data bag item" do before do - file 'data_bags/x/added.json', {} - file 'data_bags/x/modified.json', { 'foo' => 'bar' } - file 'data_bags/x/unmodified.json', {} + file "data_bags/x/added.json", {} + file "data_bags/x/modified.json", { "foo" => "bar" } + file "data_bags/x/unmodified.json", {} end - it 'knife upload of the modified file succeeds' do - knife('upload /data_bags/x/modified.json').should_succeed <<EOM + it "knife upload of the modified file succeeds" do + knife("upload /data_bags/x/modified.json").should_succeed <<EOM Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the unmodified file does nothing' do - knife('upload /data_bags/x/unmodified.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife upload of the unmodified file does nothing" do + knife("upload /data_bags/x/unmodified.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the added file succeeds' do - knife('upload /data_bags/x/added.json').should_succeed <<EOM + it "knife upload of the added file succeeds" do + knife("upload /data_bags/x/added.json").should_succeed <<EOM Created /data_bags/x/added.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json EOM end - it 'knife upload of the deleted file does nothing' do - knife('upload /data_bags/x/deleted.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife upload of the deleted file does nothing" do + knife("upload /data_bags/x/deleted.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload --purge of the deleted file deletes it' do - knife('upload --purge /data_bags/x/deleted.json').should_succeed <<EOM + it "knife upload --purge of the deleted file deletes it" do + knife("upload --purge /data_bags/x/deleted.json").should_succeed <<EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the entire data bag uploads everything' do - knife('upload /data_bags/x').should_succeed <<EOM + it "knife upload of the entire data bag uploads everything" do + knife("upload /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json EOM end - it 'knife upload --purge of the entire data bag uploads everything' do - knife('upload --purge /data_bags/x').should_succeed <<EOM + it "knife upload --purge of the entire data bag uploads everything" do + knife("upload --purge /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - context 'when cwd is the /data_bags directory' do + context "when cwd is the /data_bags directory" do before do - cwd 'data_bags' + cwd "data_bags" end - it 'knife upload fails' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + it "knife upload fails" do + knife("upload").should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end - it 'knife upload --purge . uploads everything' do - knife('upload --purge .').should_succeed <<EOM + it "knife upload --purge . uploads everything" do + knife("upload --purge .").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - it 'knife upload --purge * uploads everything' do - knife('upload --purge *').should_succeed <<EOM + it "knife upload --purge * uploads everything" do + knife("upload --purge *").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end end end @@ -434,128 +434,128 @@ EOM # Cookbook upload is a funny thing ... direct cookbook upload works, but # upload of a file is designed not to work at present. Make sure that is the # case. - when_the_chef_server 'has a cookbook' do + when_the_chef_server "has a cookbook" do before do - cookbook 'x', '1.0.0', { 'z.rb' => '' } + cookbook "x", "1.0.0", { "z.rb" => "" } end - when_the_repository 'has a modified, extra and missing file for the cookbook' do + when_the_repository "has a modified, extra and missing file for the cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0", "#modified") - file 'cookbooks/x/y.rb', 'hi' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "#modified") + file "cookbooks/x/y.rb", "hi" end - it 'knife upload of any individual file fails' do - knife('upload /cookbooks/x/metadata.rb').should_fail "ERROR: /cookbooks/x/metadata.rb cannot be updated.\n" - knife('upload /cookbooks/x/y.rb').should_fail "ERROR: /cookbooks/x cannot have a child created under it.\n" - knife('upload --purge /cookbooks/x/z.rb').should_fail "ERROR: /cookbooks/x/z.rb cannot be deleted.\n" + it "knife upload of any individual file fails" do + knife("upload /cookbooks/x/metadata.rb").should_fail "ERROR: /cookbooks/x/metadata.rb cannot be updated.\n" + knife("upload /cookbooks/x/y.rb").should_fail "ERROR: /cookbooks/x cannot have a child created under it.\n" + knife("upload --purge /cookbooks/x/z.rb").should_fail "ERROR: /cookbooks/x/z.rb cannot be deleted.\n" end # TODO this is a bit of an inconsistency: if we didn't specify --purge, # technically we shouldn't have deleted missing files. But ... cookbooks # are a special case. - it 'knife upload of the cookbook itself succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload of the cookbook itself succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end - it 'knife upload --purge of the cookbook itself succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload --purge of the cookbook itself succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has a missing file for the cookbook' do + when_the_repository "has a missing file for the cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") end - it 'knife upload of the cookbook succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload of the cookbook succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has an extra file for the cookbook' do + when_the_repository "has an extra file for the cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') - file 'cookbooks/x/z.rb', '' - file 'cookbooks/x/blah.rb', '' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/z.rb", "" + file "cookbooks/x/blah.rb", "" end - it 'knife upload of the cookbook succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload of the cookbook succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has a different file in the cookbook' do + when_the_repository "has a different file in the cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") end - it 'knife upload --freeze freezes the cookbook' do - knife('upload --freeze /cookbooks/x').should_succeed <<EOM + it "knife upload --freeze freezes the cookbook" do + knife("upload --freeze /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM # Modify a file and attempt to upload - file 'cookbooks/x/metadata.rb', 'name "x"; version "1.0.0"#different' - knife('upload /cookbooks/x').should_fail "ERROR: /cookbooks failed to write: Cookbook x is frozen\n" + file "cookbooks/x/metadata.rb", 'name "x"; version "1.0.0"#different' + knife("upload /cookbooks/x").should_fail "ERROR: /cookbooks failed to write: Cookbook x is frozen\n" end end end - when_the_chef_server 'has a frozen cookbook' do + when_the_chef_server "has a frozen cookbook" do before do - cookbook 'frozencook', '1.0.0', {}, :frozen => true + cookbook "frozencook", "1.0.0", {}, :frozen => true end - when_the_repository 'has an update to said cookbook' do + when_the_repository "has an update to said cookbook" do before do - file 'cookbooks/frozencook/metadata.rb', cb_metadata("frozencook", "1.0.0", "# This is different") + file "cookbooks/frozencook/metadata.rb", cb_metadata("frozencook", "1.0.0", "# This is different") end - it 'knife upload fails to upload the frozen cookbook' do - knife('upload /cookbooks/frozencook').should_fail "ERROR: /cookbooks failed to write: Cookbook frozencook is frozen\n" + it "knife upload fails to upload the frozen cookbook" do + knife("upload /cookbooks/frozencook").should_fail "ERROR: /cookbooks failed to write: Cookbook frozencook is frozen\n" end - it 'knife upload --force uploads the frozen cookbook' do - knife('upload --force /cookbooks/frozencook').should_succeed <<EOM + it "knife upload --force uploads the frozen cookbook" do + knife("upload --force /cookbooks/frozencook").should_succeed <<EOM Updated /cookbooks/frozencook EOM end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') - file 'cookbooks/x/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the local version' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the local version" do + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb EOM - knife('upload --purge /cookbooks/x').should_succeed <<EOM + knife("upload --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed <<EOM + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb @@ -563,35 +563,35 @@ EOM end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the local version' do - knife('upload --purge /cookbooks/x').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the local version" do + knife("upload --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the local version' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the local version" do + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb EOM - knife('upload --purge /cookbooks/x').should_succeed <<EOM + knife("upload --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed <<EOM + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb @@ -599,31 +599,31 @@ EOM end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the new version' do - knife('upload --purge /cookbooks/x').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the new version" do + knife("upload --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_chef_server 'has an environment' do + when_the_chef_server "has an environment" do before do - environment 'x', {} + environment "x", {} end - when_the_repository 'has an environment with bad JSON' do + when_the_repository "has an environment with bad JSON" do before do - file 'environments/x.json', '{' + file "environments/x.json", "{" end - it 'knife upload tries and fails' do + it "knife upload tries and fails" do error1 = <<-EOH WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF { @@ -640,75 +640,75 @@ WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error (right here) ------^ EOH - knife('upload /environments/x.json').should_fail(error1) - knife('diff --name-status /environments/x.json').should_succeed("M\t/environments/x.json\n", :stderr => warn) + knife("upload /environments/x.json").should_fail(error1) + knife("diff --name-status /environments/x.json").should_succeed("M\t/environments/x.json\n", :stderr => warn) end end - when_the_repository 'has the same environment with the wrong name in the file' do + when_the_repository "has the same environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife upload fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n" - knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n" + it "knife upload fails" do + knife("upload /environments/x.json").should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n" + knife("diff --name-status /environments/x.json").should_succeed "M\t/environments/x.json\n" end end - when_the_repository 'has the same environment with no name in the file' do + when_the_repository "has the same environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife upload succeeds' do - knife('upload /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end end - when_the_chef_server 'is empty' do + when_the_chef_server "is empty" do - when_the_repository 'has an environment with the wrong name in the file' do + when_the_repository "has an environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife upload fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n" - knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n" + it "knife upload fails" do + knife("upload /environments/x.json").should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n" + knife("diff --name-status /environments/x.json").should_succeed "A\t/environments/x.json\n" end end - when_the_repository 'has an environment with no name in the file' do + when_the_repository "has an environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife upload succeeds' do - knife('upload /environments/x.json').should_succeed "Created /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /environments/x.json").should_succeed "Created /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has a data bag with no id in the file' do + when_the_repository "has a data bag with no id in the file" do before do - file 'data_bags/bag/x.json', { 'foo' => 'bar' } + file "data_bags/bag/x.json", { "foo" => "bar" } end - it 'knife upload succeeds' do - knife('upload /data_bags/bag/x.json').should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n" - knife('diff --name-status /data_bags/bag/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /data_bags/bag/x.json").should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n" + knife("diff --name-status /data_bags/bag/x.json").should_succeed "" end end end when_the_chef_server "is empty" do - when_the_repository 'has a cookbook with an invalid chef_version constraint in it' do + when_the_repository "has a cookbook with an invalid chef_version constraint in it" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0', "\nchef_version '~> 999.0'") + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'") end - it 'knife upload succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Created /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end @@ -718,29 +718,29 @@ EOM when_the_chef_server "has one of each thing" do before do - client 'x', {} - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => {} } - environment 'x', {} - node 'x', {} - role 'x', {} - user 'x', {} + client "x", {} + cookbook "x", "1.0.0" + data_bag "x", { "y" => {} } + environment "x", {} + node "x", {} + role "x", {} + user "x", {} end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' - end - - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" + end + + it "knife upload does nothing" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM D\t/clients/chef-validator.json D\t/clients/chef-webui.json D\t/clients/x.json @@ -755,8 +755,8 @@ D\t/users/x.json EOM end - it 'knife upload --purge deletes everything' do - knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") + it "knife upload --purge deletes everything" do + knife("upload --purge /").should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") Deleted extra entry /clients/chef-validator.json (purge is on) Deleted extra entry /clients/chef-webui.json (purge is on) Deleted extra entry /clients/x.json (purge is on) @@ -768,52 +768,52 @@ Deleted extra entry /roles/x.json (purge is on) Deleted extra entry /users/admin.json (purge is on) Deleted extra entry /users/x.json (purge is on) EOM - knife('diff --name-status /').should_succeed <<EOM + knife("diff --name-status /").should_succeed <<EOM D\t/environments/_default.json EOM end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0') - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { 'description' => 'The default Chef environment' } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife upload makes no changes' do - knife('upload /cookbooks/x-1.0.0').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload makes no changes" do + knife("upload /cookbooks/x-1.0.0").should_succeed "" + knife("diff --name-status /").should_succeed "" end - it 'knife upload --purge makes no changes' do - knife('upload --purge /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload --purge makes no changes" do + knife("upload --purge /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', { 'description' => 'blarghle' } + file "roles/x.json", { "description" => "blarghle" } end - it 'knife upload changes the role' do - knife('upload /').should_succeed "Updated /roles/x.json\n" - knife('diff --name-status /').should_succeed '' + it "knife upload changes the role" do + knife("upload /").should_succeed "Updated /roles/x.json\n" + knife("diff --name-status /").should_succeed "" end end - context 'except the role file is textually different, but not ACTUALLY different' do + context "except the role file is textually different, but not ACTUALLY different" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role", "default_attributes": { @@ -832,28 +832,28 @@ EOM EOM end - it 'knife upload / does not change anything' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload / does not change anything" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed "" end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/blah.rb', '' - file 'cookbooks/x-2.0.0/metadata.rb', cb_metadata('x', '2.0.0') - file 'cookbooks/y-1.0.0/metadata.rb', cb_metadata('y', '1.0.0') - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/blah.rb", "" + file "cookbooks/x-2.0.0/metadata.rb", cb_metadata("x", "2.0.0") + file "cookbooks/y-1.0.0/metadata.rb", cb_metadata("y", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife upload adds the new files' do - knife('upload /').should_succeed <<EOM + it "knife upload adds the new files" do + knife("upload /").should_succeed <<EOM Created /clients/y.json Updated /cookbooks/x-1.0.0 Created /cookbooks/x-2.0.0 @@ -866,15 +866,15 @@ Created /nodes/y.json Created /roles/y.json Created /users/y.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end - when_the_repository 'is empty' do - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife upload does nothing" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -885,8 +885,8 @@ D\t/users EOM end - it 'knife upload --purge deletes nothing' do - knife('upload --purge /').should_fail <<EOM + it "knife upload --purge deletes nothing" do + knife("upload --purge /").should_fail <<EOM ERROR: /clients cannot be deleted. ERROR: /cookbooks cannot be deleted. ERROR: /data_bags cannot be deleted. @@ -895,7 +895,7 @@ ERROR: /nodes cannot be deleted. ERROR: /roles cannot be deleted. ERROR: /users cannot be deleted. EOM - knife('diff --name-status /').should_succeed <<EOM + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -906,130 +906,130 @@ D\t/users EOM end - context 'when current directory is top level' do + context "when current directory is top level" do before do - cwd '.' + cwd "." end - it 'knife upload with no parameters reports an error' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + it "knife upload with no parameters reports an error" do + knife("upload").should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end end end end # Test upload of an item when the other end doesn't even have the container - when_the_chef_server 'is empty' do - when_the_repository 'has two data bag items' do + when_the_chef_server "is empty" do + when_the_repository "has two data bag items" do before do - file 'data_bags/x/y.json', {} - file 'data_bags/x/z.json', {} + file "data_bags/x/y.json", {} + file "data_bags/x/z.json", {} end - it 'knife upload of one data bag item itself succeeds' do - knife('upload /data_bags/x/y.json').should_succeed <<EOM + it "knife upload of one data bag item itself succeeds" do + knife("upload /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM A\t/data_bags/x/z.json EOM end end end - when_the_chef_server 'has three data bag items' do + when_the_chef_server "has three data bag items" do before do - data_bag 'x', { 'deleted' => {}, 'modified' => {}, 'unmodified' => {} } + data_bag "x", { "deleted" => {}, "modified" => {}, "unmodified" => {} } end - when_the_repository 'has a modified, unmodified, added and deleted data bag item' do + when_the_repository "has a modified, unmodified, added and deleted data bag item" do before do - file 'data_bags/x/added.json', {} - file 'data_bags/x/modified.json', { 'foo' => 'bar' } - file 'data_bags/x/unmodified.json', {} + file "data_bags/x/added.json", {} + file "data_bags/x/modified.json", { "foo" => "bar" } + file "data_bags/x/unmodified.json", {} end - it 'knife upload of the modified file succeeds' do - knife('upload /data_bags/x/modified.json').should_succeed <<EOM + it "knife upload of the modified file succeeds" do + knife("upload /data_bags/x/modified.json").should_succeed <<EOM Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the unmodified file does nothing' do - knife('upload /data_bags/x/unmodified.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife upload of the unmodified file does nothing" do + knife("upload /data_bags/x/unmodified.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the added file succeeds' do - knife('upload /data_bags/x/added.json').should_succeed <<EOM + it "knife upload of the added file succeeds" do + knife("upload /data_bags/x/added.json").should_succeed <<EOM Created /data_bags/x/added.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json EOM end - it 'knife upload of the deleted file does nothing' do - knife('upload /data_bags/x/deleted.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife upload of the deleted file does nothing" do + knife("upload /data_bags/x/deleted.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload --purge of the deleted file deletes it' do - knife('upload --purge /data_bags/x/deleted.json').should_succeed <<EOM + it "knife upload --purge of the deleted file deletes it" do + knife("upload --purge /data_bags/x/deleted.json").should_succeed <<EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the entire data bag uploads everything' do - knife('upload /data_bags/x').should_succeed <<EOM + it "knife upload of the entire data bag uploads everything" do + knife("upload /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json EOM end - it 'knife upload --purge of the entire data bag uploads everything' do - knife('upload --purge /data_bags/x').should_succeed <<EOM + it "knife upload --purge of the entire data bag uploads everything" do + knife("upload --purge /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - context 'when cwd is the /data_bags directory' do + context "when cwd is the /data_bags directory" do before do - cwd 'data_bags' + cwd "data_bags" end - it 'knife upload fails' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + it "knife upload fails" do + knife("upload").should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end - it 'knife upload --purge . uploads everything' do - knife('upload --purge .').should_succeed <<EOM + it "knife upload --purge . uploads everything" do + knife("upload --purge .").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - it 'knife upload --purge * uploads everything' do - knife('upload --purge *').should_succeed <<EOM + it "knife upload --purge * uploads everything" do + knife("upload --purge *").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end end end @@ -1038,271 +1038,271 @@ EOM # Cookbook upload is a funny thing ... direct cookbook upload works, but # upload of a file is designed not to work at present. Make sure that is the # case. - when_the_chef_server 'has a cookbook' do + when_the_chef_server "has a cookbook" do before do - cookbook 'x', '1.0.0', { 'z.rb' => '' } + cookbook "x", "1.0.0", { "z.rb" => "" } end - when_the_repository 'has a modified, extra and missing file for the cookbook' do + when_the_repository "has a modified, extra and missing file for the cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0', '#modified') - file 'cookbooks/x-1.0.0/y.rb', 'hi' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", '#modified') + file "cookbooks/x-1.0.0/y.rb", "hi" end - it 'knife upload of any individual file fails' do - knife('upload /cookbooks/x-1.0.0/metadata.rb').should_fail "ERROR: /cookbooks/x-1.0.0/metadata.rb cannot be updated.\n" - knife('upload /cookbooks/x-1.0.0/y.rb').should_fail "ERROR: /cookbooks/x-1.0.0 cannot have a child created under it.\n" - knife('upload --purge /cookbooks/x-1.0.0/z.rb').should_fail "ERROR: /cookbooks/x-1.0.0/z.rb cannot be deleted.\n" + it "knife upload of any individual file fails" do + knife("upload /cookbooks/x-1.0.0/metadata.rb").should_fail "ERROR: /cookbooks/x-1.0.0/metadata.rb cannot be updated.\n" + knife("upload /cookbooks/x-1.0.0/y.rb").should_fail "ERROR: /cookbooks/x-1.0.0 cannot have a child created under it.\n" + knife("upload --purge /cookbooks/x-1.0.0/z.rb").should_fail "ERROR: /cookbooks/x-1.0.0/z.rb cannot be deleted.\n" end # TODO this is a bit of an inconsistency: if we didn't specify --purge, # technically we shouldn't have deleted missing files. But ... cookbooks # are a special case. - it 'knife upload of the cookbook itself succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload of the cookbook itself succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end - it 'knife upload --purge of the cookbook itself succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload --purge of the cookbook itself succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has a missing file for the cookbook' do + when_the_repository "has a missing file for the cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', "1.0.0") + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") end - it 'knife upload of the cookbook succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload of the cookbook succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has an extra file for the cookbook' do + when_the_repository "has an extra file for the cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0') - file 'cookbooks/x-1.0.0/z.rb', '' - file 'cookbooks/x-1.0.0/blah.rb', '' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x-1.0.0/z.rb", "" + file "cookbooks/x-1.0.0/blah.rb", "" end - it 'knife upload of the cookbook succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload of the cookbook succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0') - file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x-1.0.0/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife upload /cookbooks uploads the local version' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks uploads the local version" do + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x-1.0.0/onlyin1.0.0.rb D\t/cookbooks/x-1.0.1 EOM - knife('upload --purge /cookbooks').should_succeed <<EOM + knife("upload --purge /cookbooks").should_succeed <<EOM Updated /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-1.0.1 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife upload /cookbooks uploads the local version' do - knife('upload --purge /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks uploads the local version" do + knife("upload --purge /cookbooks").should_succeed <<EOM Updated /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-0.9.9 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the local version' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the local version" do + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-1.0.1 A\t/cookbooks/x-1.0.0 EOM - knife('upload --purge /cookbooks').should_succeed <<EOM + knife("upload --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-1.0.1 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the new version' do - knife('upload --purge /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the new version" do + knife("upload --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-0.9.9 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_chef_server 'has an environment' do + when_the_chef_server "has an environment" do before do - environment 'x', {} + environment "x", {} end - when_the_repository 'has the same environment with the wrong name in the file' do + when_the_repository "has the same environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife upload fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n" - knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n" + it "knife upload fails" do + knife("upload /environments/x.json").should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n" + knife("diff --name-status /environments/x.json").should_succeed "M\t/environments/x.json\n" end end - when_the_repository 'has the same environment with no name in the file' do + when_the_repository "has the same environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife upload succeeds' do - knife('upload /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end end - when_the_chef_server 'is empty' do + when_the_chef_server "is empty" do - when_the_repository 'has an environment with the wrong name in the file' do + when_the_repository "has an environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife upload fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n" - knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n" + it "knife upload fails" do + knife("upload /environments/x.json").should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n" + knife("diff --name-status /environments/x.json").should_succeed "A\t/environments/x.json\n" end end - when_the_repository 'has an environment with no name in the file' do + when_the_repository "has an environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife upload succeeds' do - knife('upload /environments/x.json').should_succeed "Created /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /environments/x.json").should_succeed "Created /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has a data bag with no id in the file' do + when_the_repository "has a data bag with no id in the file" do before do - file 'data_bags/bag/x.json', { 'foo' => 'bar' } + file "data_bags/bag/x.json", { "foo" => "bar" } end - it 'knife upload succeeds' do - knife('upload /data_bags/bag/x.json').should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n" - knife('diff --name-status /data_bags/bag/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /data_bags/bag/x.json").should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n" + knife("diff --name-status /data_bags/bag/x.json").should_succeed "" end end end when_the_chef_server "is empty" do - when_the_repository 'has a cookbook with an invalid chef_version constraint in it' do + when_the_repository "has a cookbook with an invalid chef_version constraint in it" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0', "\nchef_version '~> 999.0'") + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'") end - it 'knife upload succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Created /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end end # with versioned cookbooks - when_the_chef_server 'has a user' do + when_the_chef_server "has a user" do before do - user 'x', {} + user "x", {} end - when_the_repository 'has the same user with json_class in it' do + when_the_repository "has the same user with json_class in it" do before do - file 'users/x.json', { 'admin' => true, 'json_class' => 'Chef::WebUIUser' } + file "users/x.json", { "admin" => true, "json_class" => "Chef::WebUIUser" } end - it 'knife upload /users/x.json succeeds' do - knife('upload /users/x.json').should_succeed "Updated /users/x.json\n" + it "knife upload /users/x.json succeeds" do + knife("upload /users/x.json").should_succeed "Updated /users/x.json\n" end end end when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do before do - user 'foo', {} - user 'bar', {} - user 'foobar', {} - organization 'foo', { 'full_name' => 'Something' } + user "foo", {} + user "bar", {} + user "foobar", {} + organization "foo", { "full_name" => "Something" } end before :each do - Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo') + Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo") end - context 'and has nothing but a single group named blah' do - group 'blah', {} + context "and has nothing but a single group named blah" do + group "blah", {} - when_the_repository 'has at least one of each thing' do + when_the_repository "has at least one of each thing" do before do # TODO We have to upload acls for an existing group due to a lack of # dependency detection during upload. Fix that! - file 'acls/groups/blah.json', {} - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'containers/x.json', {} - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/x.json', {} - file 'groups/x.json', {} - file 'invitations.json', [ 'foo' ] - file 'members.json', [ 'bar' ] - file 'org.json', { 'full_name' => 'wootles' } - file 'nodes/x.json', {} - file 'policies/x-1.0.0.json', { } - file 'policies/blah-1.0.0.json', { } - file 'policy_groups/x.json', { 'policies' => { 'x' => { 'revision_id' => '1.0.0' }, 'blah' => { 'revision_id' => '1.0.0' } } } - file 'roles/x.json', {} - end - - it 'knife upload / uploads everything' do - knife('upload /').should_succeed <<EOM + file "acls/groups/blah.json", {} + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "containers/x.json", {} + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/x.json", {} + file "groups/x.json", {} + file "invitations.json", [ "foo" ] + file "members.json", [ "bar" ] + file "org.json", { "full_name" => "wootles" } + file "nodes/x.json", {} + file "policies/x-1.0.0.json", { } + file "policies/blah-1.0.0.json", { } + file "policy_groups/x.json", { "policies" => { "x" => { "revision_id" => "1.0.0" }, "blah" => { "revision_id" => "1.0.0" } } } + file "roles/x.json", {} + end + + it "knife upload / uploads everything" do + knife("upload /").should_succeed <<EOM Updated /acls/groups/blah.json Created /clients/x.json Created /containers/x.json @@ -1320,39 +1320,39 @@ Created /policies/x-1.0.0.json Created /policy_groups/x.json Created /roles/x.json EOM - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ 'foo' ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar' ]) + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "foo" ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ]) end context "When the chef server has an identical copy of each thing" do before do - file 'invitations.json', [ 'foo' ] - file 'members.json', [ 'bar' ] - file 'org.json', { 'full_name' => 'Something' } + file "invitations.json", [ "foo" ] + file "members.json", [ "bar" ] + file "org.json", { "full_name" => "Something" } # acl_for %w(organizations foo groups blah) - client 'x', {} - cookbook 'x', '1.0.0' - container 'x', {} - data_bag 'x', { 'y' => {} } - environment 'x', {} - group 'x', {} - org_invite 'foo' - org_member 'bar' - node 'x', {} - policy 'x', '1.0.0', {} - policy 'blah', '1.0.0', {} - policy_group 'x', { - 'policies' => { - 'x' => { 'revision_id' => '1.0.0' }, - 'blah' => { 'revision_id' => '1.0.0' }, + client "x", {} + cookbook "x", "1.0.0" + container "x", {} + data_bag "x", { "y" => {} } + environment "x", {} + group "x", {} + org_invite "foo" + org_member "bar" + node "x", {} + policy "x", "1.0.0", {} + policy "blah", "1.0.0", {} + policy_group "x", { + "policies" => { + "x" => { "revision_id" => "1.0.0" }, + "blah" => { "revision_id" => "1.0.0" }, } } - role 'x', {} + role "x", {} end - it 'knife upload makes no changes' do - knife('upload /').should_succeed <<EOM + it "knife upload makes no changes" do + knife("upload /").should_succeed <<EOM Updated /acls/groups/blah.json EOM end @@ -1360,7 +1360,7 @@ EOM context "When the chef server has a slightly different copy of the policy revision" do before do - policy 'x', '1.0.0', { 'run_list' => [ 'blah' ] } + policy "x", "1.0.0", { "run_list" => [ "blah" ] } end it "should fail because policies are not updateable" do @@ -1373,27 +1373,27 @@ EOM context "When the chef server has a slightly different copy of each thing (except policy revisions)" do before do # acl_for %w(organizations foo groups blah) - client 'x', { 'validator' => true } - container 'x', {} - cookbook 'x', '1.0.0', { 'recipes' => { 'default.rb' => '' } } - data_bag 'x', { 'y' => { 'a' => 'b' } } - environment 'x', { 'description' => 'foo' } - group 'x', { 'groups' => [ 'admin' ] } - node 'x', { 'run_list' => [ 'blah' ] } - policy 'x', '1.0.0', { } - policy 'x', '1.0.1', { } - policy 'y', '1.0.0', { } - policy_group 'x', { - 'policies' => { - 'x' => { 'revision_id' => '1.0.1' }, - 'y' => { 'revision_id' => '1.0.0' }, + client "x", { "validator" => true } + container "x", {} + cookbook "x", "1.0.0", { "recipes" => { "default.rb" => "" } } + data_bag "x", { "y" => { "a" => "b" } } + environment "x", { "description" => "foo" } + group "x", { "groups" => [ "admin" ] } + node "x", { "run_list" => [ "blah" ] } + policy "x", "1.0.0", { } + policy "x", "1.0.1", { } + policy "y", "1.0.0", { } + policy_group "x", { + "policies" => { + "x" => { "revision_id" => "1.0.1" }, + "y" => { "revision_id" => "1.0.0" }, } } - role 'x', { 'run_list' => [ 'blah' ] } + role "x", { "run_list" => [ "blah" ] } end - it 'knife upload updates everything' do - knife('upload /').should_succeed <<EOM + it "knife upload updates everything" do + knife("upload /").should_succeed <<EOM Updated /acls/groups/blah.json Updated /clients/x.json Updated /cookbooks/x @@ -1408,103 +1408,103 @@ Created /policies/blah-1.0.0.json Updated /policy_groups/x.json Updated /roles/x.json EOM - knife('diff --name-status --diff-filter=AMT /').should_succeed '' + knife("diff --name-status --diff-filter=AMT /").should_succeed "" end end end - when_the_repository 'has an org.json that does not change full_name' do + when_the_repository "has an org.json that does not change full_name" do before do - file 'org.json', { 'full_name' => 'Something' } + file "org.json", { "full_name" => "Something" } end - it 'knife upload / emits a warning for bar and adds foo and foobar' do - knife('upload /').should_succeed '' - expect(api.get('/')['full_name']).to eq('Something') + it "knife upload / emits a warning for bar and adds foo and foobar" do + knife("upload /").should_succeed "" + expect(api.get("/")["full_name"]).to eq("Something") end end - when_the_repository 'has an org.json that changes full_name' do + when_the_repository "has an org.json that changes full_name" do before do - file 'org.json', { 'full_name' => 'Something Else'} + file "org.json", { "full_name" => "Something Else"} end - it 'knife upload / emits a warning for bar and adds foo and foobar' do - knife('upload /').should_succeed "Updated /org.json\n" - expect(api.get('/')['full_name']).to eq('Something Else') + it "knife upload / emits a warning for bar and adds foo and foobar" do + knife("upload /").should_succeed "Updated /org.json\n" + expect(api.get("/")["full_name"]).to eq("Something Else") end end - context 'and has invited foo and bar is already a member' do - org_invite 'foo' - org_member 'bar' + context "and has invited foo and bar is already a member" do + org_invite "foo" + org_member "bar" - when_the_repository 'wants to invite foo, bar and foobar' do + when_the_repository "wants to invite foo, bar and foobar" do before do - file 'invitations.json', [ 'foo', 'bar', 'foobar' ] + file "invitations.json", [ "foo", "bar", "foobar" ] end - it 'knife upload / emits a warning for bar and invites foobar' do - knife('upload /').should_succeed "Updated /invitations.json\n", :stderr => "WARN: Could not invite bar to organization foo: User bar is already in organization foo\n" - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ 'foo', 'foobar' ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar' ]) + it "knife upload / emits a warning for bar and invites foobar" do + knife("upload /").should_succeed "Updated /invitations.json\n", :stderr => "WARN: Could not invite bar to organization foo: User bar is already in organization foo\n" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "foo", "foobar" ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ]) end end - when_the_repository 'wants to make foo, bar and foobar members' do + when_the_repository "wants to make foo, bar and foobar members" do before do - file 'members.json', [ 'foo', 'bar', 'foobar' ] + file "members.json", [ "foo", "bar", "foobar" ] end - it 'knife upload / emits a warning for bar and adds foo and foobar' do - knife('upload /').should_succeed "Updated /members.json\n" - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar', 'foo', 'foobar' ]) + it "knife upload / emits a warning for bar and adds foo and foobar" do + knife("upload /").should_succeed "Updated /members.json\n" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar", "foo", "foobar" ]) end end - when_the_repository 'wants to invite foo and have bar as a member' do + when_the_repository "wants to invite foo and have bar as a member" do before do - file 'invitations.json', [ 'foo' ] - file 'members.json', [ 'bar' ] + file "invitations.json", [ "foo" ] + file "members.json", [ "bar" ] end - it 'knife upload / does nothing' do - knife('upload /').should_succeed '' - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ 'foo' ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar' ]) + it "knife upload / does nothing" do + knife("upload /").should_succeed "" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "foo" ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ]) end end end - context 'and has invited bar and foo' do - org_invite 'bar', 'foo' + context "and has invited bar and foo" do + org_invite "bar", "foo" - when_the_repository 'wants to invite foo and bar (different order)' do + when_the_repository "wants to invite foo and bar (different order)" do before do - file 'invitations.json', [ 'foo', 'bar' ] + file "invitations.json", [ "foo", "bar" ] end - it 'knife upload / does nothing' do - knife('upload /').should_succeed '' - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ 'bar', 'foo' ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ ]) + it "knife upload / does nothing" do + knife("upload /").should_succeed "" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "bar", "foo" ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ ]) end end end - context 'and has already added bar and foo as members of the org' do - org_member 'bar', 'foo' + context "and has already added bar and foo as members of the org" do + org_member "bar", "foo" - when_the_repository 'wants to add foo and bar (different order)' do + when_the_repository "wants to add foo and bar (different order)" do before do - file 'members.json', [ 'foo', 'bar' ] + file "members.json", [ "foo", "bar" ] end - it 'knife upload / does nothing' do - knife('upload /').should_succeed '' - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar', 'foo' ]) + it "knife upload / does nothing" do + knife("upload /").should_succeed "" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar", "foo" ]) end end end diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb index bd5eaf66a4..dc7e19a3cb 100644 --- a/spec/integration/recipes/lwrp_inline_resources_spec.rb +++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb @@ -1,5 +1,5 @@ -require 'support/shared/integration/integration_helper' -require 'chef/mixin/shell_out' +require "support/shared/integration/integration_helper" +require "chef/mixin/shell_out" describe "LWRPs with inline resources" do include IntegrationSupport @@ -29,7 +29,7 @@ describe "LWRPs with inline resources" do use_inline_resources def action_a r = new_resource - ruby_block 'run a' do + ruby_block "run a" do block { r.ran_a "ran a" } end end @@ -39,8 +39,8 @@ describe "LWRPs with inline resources" do it "this is totally a bug, but for backcompat purposes, it adds the resources to the main resource collection and does not get marked updated" do r = nil expect_recipe { - r = lwrp_inline_resources_test 'hi' - }.to have_updated('ruby_block[run a]', :run) + r = lwrp_inline_resources_test "hi" + }.to have_updated("ruby_block[run a]", :run) expect(r.ran_a).to eq "ran a" end end @@ -58,7 +58,7 @@ describe "LWRPs with inline resources" do action :a do r = new_resource - ruby_block 'run a' do + ruby_block "run a" do block { r.ran_a "ran a" } end end @@ -68,7 +68,7 @@ describe "LWRPs with inline resources" do r = new_resource # Grab ran_a right now, before we converge ran_a = r.ran_a - ruby_block 'run b' do + ruby_block "run b" do block { r.ran_b "ran b: ran_a value was #{ran_a.inspect}" } end end @@ -78,34 +78,34 @@ describe "LWRPs with inline resources" do it "resources declared in b are executed immediately inline" do r = nil expect_recipe { - r = lwrp_inline_resources_test2 'hi' do + r = lwrp_inline_resources_test2 "hi" do action :b end - }.to have_updated('lwrp_inline_resources_test2[hi]', :b). - and have_updated('ruby_block[run a]', :run). - and have_updated('ruby_block[run b]', :run) + }.to have_updated("lwrp_inline_resources_test2[hi]", :b). + and have_updated("ruby_block[run a]", :run). + and have_updated("ruby_block[run b]", :run) expect(r.ran_b).to eq "ran b: ran_a value was \"ran a\"" end end when_the_repository "has a cookbook with a nested LWRP" do before do - directory 'cookbooks/x' do + directory "cookbooks/x" do - file 'resources/do_nothing.rb', <<-EOM + file "resources/do_nothing.rb", <<-EOM actions :create, :nothing default_action :create EOM - file 'providers/do_nothing.rb', <<-EOM + file "providers/do_nothing.rb", <<-EOM action :create do end EOM - file 'resources/my_machine.rb', <<-EOM + file "resources/my_machine.rb", <<-EOM actions :create, :nothing default_action :create EOM - file 'providers/my_machine.rb', <<-EOM + file "providers/my_machine.rb", <<-EOM use_inline_resources action :create do x_do_nothing 'a' @@ -113,7 +113,7 @@ describe "LWRPs with inline resources" do end EOM - file 'recipes/default.rb', <<-EOM + file "recipes/default.rb", <<-EOM x_my_machine "me" x_my_machine "you" EOM @@ -122,7 +122,7 @@ describe "LWRPs with inline resources" do end it "should complete with success" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" log_level :warn diff --git a/spec/integration/recipes/lwrp_spec.rb b/spec/integration/recipes/lwrp_spec.rb index 7ecdfc7c3a..3bc008d4f8 100644 --- a/spec/integration/recipes/lwrp_spec.rb +++ b/spec/integration/recipes/lwrp_spec.rb @@ -1,5 +1,5 @@ -require 'support/shared/integration/integration_helper' -require 'chef/mixin/shell_out' +require "support/shared/integration/integration_helper" +require "chef/mixin/shell_out" describe "LWRPs" do include IntegrationSupport @@ -20,17 +20,17 @@ describe "LWRPs" do when_the_repository "has a cookbook named l-w-r-p" do before do - directory 'cookbooks/l-w-r-p' do + directory "cookbooks/l-w-r-p" do - file 'resources/foo.rb', <<EOM + file "resources/foo.rb", <<EOM default_action :create EOM - file 'providers/foo.rb', <<EOM + file "providers/foo.rb", <<EOM action :create do end EOM - file 'recipes/default.rb', <<EOM + file "recipes/default.rb", <<EOM l_w_r_p_foo "me" EOM @@ -38,7 +38,7 @@ EOM end it "should complete with success" do - file 'config/client.rb', <<EOM + file "config/client.rb", <<EOM local_mode true cookbook_path "#{path_to('cookbooks')}" log_level :warn diff --git a/spec/integration/recipes/provider_choice.rb b/spec/integration/recipes/provider_choice.rb index 01537b2c05..d08090bbe8 100644 --- a/spec/integration/recipes/provider_choice.rb +++ b/spec/integration/recipes/provider_choice.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" describe "Recipe DSL methods" do include IntegrationSupport @@ -26,7 +26,7 @@ describe "Recipe DSL methods" do it "provider_thingy 'blah' runs the provider and warns" do recipe = converge { - provider_thingy 'blah' do; end + provider_thingy "blah" do; end } expect(recipe.logged_warnings).to match /hello from Chef::Provider::ProviderThingy/ expect(recipe.logged_warnings).to match /you must use 'provides' to provide DSL/i diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index 52bca87c99..db4d158eec 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" describe "Recipe DSL methods" do include IntegrationSupport @@ -15,7 +15,7 @@ describe "Recipe DSL methods" do before(:context) { class BaseThingy < Chef::Resource - resource_name 'base_thingy' + resource_name "base_thingy" default_action :create class<<self @@ -51,27 +51,27 @@ describe "Recipe DSL methods" do it "creates base_thingy when you call base_thingy in a recipe" do recipe = converge { - base_thingy 'blah' do; end + base_thingy "blah" do; end } - expect(recipe.logged_warnings).to eq '' - expect(BaseThingy.created_name).to eq 'blah' + expect(recipe.logged_warnings).to eq "" + expect(BaseThingy.created_name).to eq "blah" expect(BaseThingy.created_resource).to eq BaseThingy end it "errors out when you call base_thingy do ... end in a recipe" do expect_converge { base_thingy do; end - }.to raise_error(ArgumentError, 'You must supply a name when declaring a base_thingy resource') + }.to raise_error(ArgumentError, "You must supply a name when declaring a base_thingy resource") end it "emits a warning when you call base_thingy 'foo', 'bar' do ... end in a recipe" do Chef::Config[:treat_deprecation_warnings_as_errors] = false recipe = converge { - base_thingy 'foo', 'bar' do + base_thingy "foo", "bar" do end } expect(recipe.logged_warnings).to match(/Cannot create resource base_thingy with more than one argument. All arguments except the name \("foo"\) will be ignored. This will cause an error in Chef 13. Arguments: \["foo", "bar"\]/) - expect(BaseThingy.created_name).to eq 'foo' + expect(BaseThingy.created_name).to eq "foo" expect(BaseThingy.created_resource).to eq BaseThingy end @@ -99,7 +99,7 @@ describe "Recipe DSL methods" do it "backcompat_thingy creates a Chef::Resource::BackcompatThingy" do recipe = converge { - backcompat_thingy 'blah' do; end + backcompat_thingy "blah" do; end } expect(BaseThingy.created_resource).to eq Chef::Resource::BackcompatThingy expect(BaseThingy.created_provider).to eq Chef::Provider::BackcompatThingy @@ -117,7 +117,7 @@ describe "Recipe DSL methods" do it "backcompat_thingy creates a BackcompatThingy" do recipe = converge { - backcompat_thingy 'blah' do; end + backcompat_thingy "blah" do; end } expect(recipe.logged_warnings).to match(/Class Chef::Provider::BackcompatThingy does not declare 'provides :backcompat_thingy'./) expect(BaseThingy.created_resource).not_to be_nil @@ -135,7 +135,7 @@ describe "Recipe DSL methods" do it "bar_thingy does not work" do expect_converge { - bar_thingy 'blah' do; end + bar_thingy "blah" do; end }.to raise_error(NoMethodError) end end @@ -151,7 +151,7 @@ describe "Recipe DSL methods" do it "no_name_thingy does not work" do expect_converge { - no_name_thingy 'blah' do; end + no_name_thingy "blah" do; end }.to raise_error(NoMethodError) end end @@ -167,15 +167,15 @@ describe "Recipe DSL methods" do it "another_no_name_thingy does not work" do expect_converge { - another_no_name_thingy 'blah' do; end + another_no_name_thingy "blah" do; end }.to raise_error(NoMethodError) end it "another_thingy_name works" do recipe = converge { - another_thingy_name 'blah' do; end + another_thingy_name "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq(AnotherNoNameThingy) end end @@ -192,21 +192,21 @@ describe "Recipe DSL methods" do it "another_no_name_thingy does not work" do expect_converge { - another_no_name_thingy2 'blah' do; end + another_no_name_thingy2 "blah" do; end }.to raise_error(NoMethodError) end it "another_thingy_name2 does not work" do expect_converge { - another_thingy_name2 'blah' do; end + another_thingy_name2 "blah" do; end }.to raise_error(NoMethodError) end it "yet_another_thingy_name3 works" do recipe = converge { - another_thingy_name3 'blah' do; end + another_thingy_name3 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq(AnotherNoNameThingy2) end end @@ -217,7 +217,7 @@ describe "Recipe DSL methods" do class AnotherNoNameThingy3 < BaseThingy resource_name :another_no_name_thingy_3 - provides :another_no_name_thingy3, os: 'blarghle' + provides :another_no_name_thingy3, os: "blarghle" end } @@ -225,18 +225,18 @@ describe "Recipe DSL methods" do it "and os = linux, another_no_name_thingy3 does not work" do expect_converge { # TODO this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' - another_no_name_thingy3 'blah' do; end + run_context.node.automatic[:os] = "linux" + another_no_name_thingy3 "blah" do; end }.to raise_error(Chef::Exceptions::NoSuchResourceType) end it "and os = blarghle, another_no_name_thingy3 works" do recipe = converge { # TODO this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'blarghle' - another_no_name_thingy3 'blah' do; end + run_context.node.automatic[:os] = "blarghle" + another_no_name_thingy3 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy3) end end @@ -246,8 +246,8 @@ describe "Recipe DSL methods" do class AnotherNoNameThingy4 < BaseThingy resource_name :another_no_name_thingy_4 - provides :another_no_name_thingy4, os: 'blarghle' - provides :another_no_name_thingy4, platform_family: 'foo' + provides :another_no_name_thingy4, os: "blarghle" + provides :another_no_name_thingy4, platform_family: "foo" end } @@ -255,28 +255,28 @@ describe "Recipe DSL methods" do it "and os = linux, another_no_name_thingy4 does not work" do expect_converge { # TODO this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' - another_no_name_thingy4 'blah' do; end + run_context.node.automatic[:os] = "linux" + another_no_name_thingy4 "blah" do; end }.to raise_error(Chef::Exceptions::NoSuchResourceType) end it "and os = blarghle, another_no_name_thingy4 works" do recipe = converge { # TODO this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'blarghle' - another_no_name_thingy4 'blah' do; end + run_context.node.automatic[:os] = "blarghle" + another_no_name_thingy4 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy4) end it "and platform_family = foo, another_no_name_thingy4 works" do recipe = converge { # TODO this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:platform_family] = 'foo' - another_no_name_thingy4 'blah' do; end + run_context.node.automatic[:platform_family] = "foo" + another_no_name_thingy4 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy4) end end @@ -286,7 +286,7 @@ describe "Recipe DSL methods" do class AnotherNoNameThingy5 < BaseThingy resource_name :another_thingy_name_for_another_no_name_thingy5 - provides :another_no_name_thingy5, os: 'blarghle' + provides :another_no_name_thingy5, os: "blarghle" end } @@ -294,26 +294,26 @@ describe "Recipe DSL methods" do it "and os = linux, another_no_name_thingy5 does not work" do expect_converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' - another_no_name_thingy5 'blah' do; end + run_context.node.automatic[:os] = "linux" + another_no_name_thingy5 "blah" do; end }.to raise_error(Chef::Exceptions::NoSuchResourceType) end it "and os = blarghle, another_no_name_thingy5 works" do recipe = converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'blarghle' - another_no_name_thingy5 'blah' do; end + run_context.node.automatic[:os] = "blarghle" + another_no_name_thingy5 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy5) end it "the new resource name can be used in a recipe" do recipe = converge { - another_thingy_name_for_another_no_name_thingy5 'blah' do; end + another_thingy_name_for_another_no_name_thingy5 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy5) end end @@ -322,7 +322,7 @@ describe "Recipe DSL methods" do before(:context) { class AnotherNoNameThingy6 < BaseThingy - provides :another_no_name_thingy6, os: 'blarghle' + provides :another_no_name_thingy6, os: "blarghle" resource_name :another_thingy_name_for_another_no_name_thingy6 end @@ -331,26 +331,26 @@ describe "Recipe DSL methods" do it "and os = linux, another_no_name_thingy6 does not work" do expect_converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' - another_no_name_thingy6 'blah' do; end + run_context.node.automatic[:os] = "linux" + another_no_name_thingy6 "blah" do; end }.to raise_error(Chef::Exceptions::NoSuchResourceType) end it "and os = blarghle, another_no_name_thingy6 works" do recipe = converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'blarghle' - another_no_name_thingy6 'blah' do; end + run_context.node.automatic[:os] = "blarghle" + another_no_name_thingy6 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy6) end it "the new resource name can be used in a recipe" do recipe = converge { - another_thingy_name_for_another_no_name_thingy6 'blah' do; end + another_thingy_name_for_another_no_name_thingy6 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy6) end end @@ -360,7 +360,7 @@ describe "Recipe DSL methods" do class AnotherNoNameThingy7 < BaseThingy resource_name :another_thingy_name_for_another_no_name_thingy7 - provides :another_thingy_name_for_another_no_name_thingy7, os: 'blarghle' + provides :another_thingy_name_for_another_no_name_thingy7, os: "blarghle" end } @@ -368,26 +368,26 @@ describe "Recipe DSL methods" do it "and os = linux, another_thingy_name_for_another_no_name_thingy7 does not work" do expect_converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' - another_thingy_name_for_another_no_name_thingy7 'blah' do; end + run_context.node.automatic[:os] = "linux" + another_thingy_name_for_another_no_name_thingy7 "blah" do; end }.to raise_error(Chef::Exceptions::NoSuchResourceType) end it "and os = blarghle, another_thingy_name_for_another_no_name_thingy7 works" do recipe = converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'blarghle' - another_thingy_name_for_another_no_name_thingy7 'blah' do; end + run_context.node.automatic[:os] = "blarghle" + another_thingy_name_for_another_no_name_thingy7 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy7) end it "the old resource name does not work" do expect_converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' - another_no_name_thingy_7 'blah' do; end + run_context.node.automatic[:os] = "linux" + another_no_name_thingy_7 "blah" do; end }.to raise_error(NoMethodError) end end @@ -397,7 +397,7 @@ describe "Recipe DSL methods" do before(:context) { class AnotherNoNameThingy8 < BaseThingy - provides :another_thingy_name_for_another_no_name_thingy8, os: 'blarghle' + provides :another_thingy_name_for_another_no_name_thingy8, os: "blarghle" resource_name :another_thingy_name_for_another_no_name_thingy8 end @@ -406,26 +406,26 @@ describe "Recipe DSL methods" do it "and os = linux, another_thingy_name_for_another_no_name_thingy8 does not work" do expect_converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' - another_thingy_name_for_another_no_name_thingy8 'blah' do; end + run_context.node.automatic[:os] = "linux" + another_thingy_name_for_another_no_name_thingy8 "blah" do; end }.to raise_error(Chef::Exceptions::NoSuchResourceType) end it "and os = blarghle, another_thingy_name_for_another_no_name_thingy8 works" do recipe = converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'blarghle' - another_thingy_name_for_another_no_name_thingy8 'blah' do; end + run_context.node.automatic[:os] = "blarghle" + another_thingy_name_for_another_no_name_thingy8 "blah" do; end } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq (AnotherNoNameThingy8) end it "the old resource name does not work" do expect_converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' - another_thingy_name8 'blah' do; end + run_context.node.automatic[:os] = "linux" + another_thingy_name8 "blah" do; end }.to raise_error(NoMethodError) end end @@ -444,13 +444,13 @@ describe "Recipe DSL methods" do it "my_supplier does not work in a recipe" do expect_converge { - my_supplier 'blah' do; end + my_supplier "blah" do; end }.to raise_error(NoMethodError) end it "hemlock works in a recipe" do expect_recipe { - hemlock 'blah' do; end + hemlock "blah" do; end }.to emit_no_warnings_or_errors expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::MySupplier end @@ -467,7 +467,7 @@ describe "Recipe DSL methods" do it "thingy3 works in a recipe" do expect_recipe { - thingy3 'blah' do; end + thingy3 "blah" do; end }.to emit_no_warnings_or_errors expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3 end @@ -483,14 +483,14 @@ describe "Recipe DSL methods" do it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do recipe = converge { - thingy3 'blah' do; end + thingy3 "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3 end it "thingy4 does not work in a recipe" do expect_converge { - thingy4 'blah' do; end + thingy4 "blah" do; end }.to raise_error(NoMethodError) end @@ -514,7 +514,7 @@ describe "Recipe DSL methods" do it "thingy5 works in a recipe" do expect_recipe { - thingy5 'blah' do; end + thingy5 "blah" do; end }.to emit_no_warnings_or_errors expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy5 end @@ -531,14 +531,14 @@ describe "Recipe DSL methods" do it "thingy6 works in a recipe and yields Thingy6" do recipe = converge { - thingy6 'blah' do; end + thingy6 "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy6 end it "thingy5 works in a recipe and yields Foo::Thingy5 (the alphabetical one)" do recipe = converge { - thingy5 'blah' do; end + thingy5 "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy5 end @@ -558,7 +558,7 @@ describe "Recipe DSL methods" do it "thingy5reverse works in a recipe and yields AThingy5 (the alphabetical one)" do recipe = converge { - thingy5reverse 'blah' do; end + thingy5reverse "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::AThingy5 end @@ -577,7 +577,7 @@ describe "Recipe DSL methods" do it "thingy5_2 works in a recipe and yields the RecipeDSLSpaceNamespace one (the alphabetical one)" do recipe = converge { - thingy5_2 'blah' do; end + thingy5_2 "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy5 end @@ -596,7 +596,7 @@ describe "Recipe DSL methods" do it "thingy5_2reverse works in a recipe and yields the ARecipeDSLSpaceNamespace one (the alphabetical one)" do recipe = converge { - thingy5_2reverse 'blah' do; end + thingy5_2reverse "blah" do; end } expect(BaseThingy.created_resource).to eq ARecipeDSLSpecNamespace::Thingy5 end @@ -614,7 +614,7 @@ describe "Recipe DSL methods" do it "thingy3 works in a recipe" do expect_recipe { - thingy3 'blah' do; end + thingy3 "blah" do; end }.to emit_no_warnings_or_errors expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3 end @@ -630,14 +630,14 @@ describe "Recipe DSL methods" do it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do recipe = converge { - thingy3 'blah' do; end + thingy3 "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3 end it "thingy4 does not work in a recipe" do expect_converge { - thingy4 'blah' do; end + thingy4 "blah" do; end }.to raise_error(NoMethodError) end @@ -657,14 +657,14 @@ describe "Recipe DSL methods" do it "thingy3 works in a recipe and yields Thingy3 (the alphabetical one)" do recipe = converge { - thingy3 'blah' do; end + thingy3 "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy3 end it "thingy4 does not work in a recipe" do expect_converge { - thingy4 'blah' do; end + thingy4 "blah" do; end }.to raise_error(NoMethodError) end @@ -697,14 +697,14 @@ describe "Recipe DSL methods" do it "thingy7 works in a recipe and yields Thingy7" do recipe = converge { - thingy7 'blah' do; end + thingy7 "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy7 end it "thingy8 works in a recipe and yields Thingy7 (alphabetical)" do recipe = converge { - thingy8 'blah' do; end + thingy8 "blah" do; end } expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy7 end @@ -728,21 +728,21 @@ describe "Recipe DSL methods" do it "thingy12 works in a recipe and yields Thingy12" do expect_recipe { - thingy12 'blah' do; end + thingy12 "blah" do; end }.to emit_no_warnings_or_errors expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy12 end it "twizzle works in a recipe and yields Thingy12" do expect_recipe { - twizzle 'blah' do; end + twizzle "blah" do; end }.to emit_no_warnings_or_errors expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy12 end it "twizzle2 works in a recipe and yields Thingy12" do expect_recipe { - twizzle2 'blah' do; end + twizzle2 "blah" do; end }.to emit_no_warnings_or_errors expect(BaseThingy.created_resource).to eq RecipeDSLSpecNamespace::Thingy12 end @@ -752,20 +752,20 @@ describe "Recipe DSL methods" do before(:context) { class MySuperThingyFoo < BaseThingy resource_name :my_super_thingy_foo - provides :my_super_thingy, platform: 'foo' + provides :my_super_thingy, platform: "foo" end class MySuperThingyBar < BaseThingy resource_name :my_super_thingy_bar - provides :my_super_thingy, platform: 'bar' + provides :my_super_thingy, platform: "bar" end } it "A run with platform 'foo' uses MySuperThingyFoo" do r = Cheffish::ChefRun.new(chef_config) - r.client.run_context.node.automatic['platform'] = 'foo' + r.client.run_context.node.automatic["platform"] = "foo" r.compile_recipe { - my_super_thingy 'blah' do; end + my_super_thingy "blah" do; end } r.converge expect(r).to emit_no_warnings_or_errors @@ -774,9 +774,9 @@ describe "Recipe DSL methods" do it "A run with platform 'bar' uses MySuperThingyBar" do r = Cheffish::ChefRun.new(chef_config) - r.client.run_context.node.automatic['platform'] = 'bar' + r.client.run_context.node.automatic["platform"] = "bar" r.compile_recipe { - my_super_thingy 'blah' do; end + my_super_thingy "blah" do; end } r.converge expect(r).to emit_no_warnings_or_errors @@ -785,10 +785,10 @@ describe "Recipe DSL methods" do it "A run with platform 'x' reports that my_super_thingy is not supported" do r = Cheffish::ChefRun.new(chef_config) - r.client.run_context.node.automatic['platform'] = 'x' + r.client.run_context.node.automatic["platform"] = "x" expect { r.compile_recipe { - my_super_thingy 'blah' do; end + my_super_thingy "blah" do; end } }.to raise_error(Chef::Exceptions::NoSuchResourceType) end @@ -819,7 +819,7 @@ describe "Recipe DSL methods" do it "declaring a resource providing the same :thingy11 with os: 'linux' does not produce a warning" do expect(Chef::Log).not_to receive(:warn) class RecipeDSLSpecNamespace::Thingy11AlternateProvider < BaseThingy - provides :thingy11, os: 'linux' + provides :thingy11, os: "linux" end end end @@ -859,7 +859,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class_a end @@ -887,7 +887,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class end @@ -905,7 +905,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class_z end @@ -923,7 +923,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class end @@ -944,7 +944,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class_z end @@ -962,7 +962,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class end @@ -987,7 +987,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class end @@ -1036,7 +1036,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class_a end end @@ -1048,7 +1048,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class end end @@ -1075,7 +1075,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class end @@ -1087,7 +1087,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class_z end end @@ -1104,7 +1104,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class end end @@ -1118,7 +1118,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{two_classes_one_dsl} 'blah'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class end end @@ -1136,7 +1136,7 @@ describe "Recipe DSL methods" do def self.inspect; name.inspect; end end result.resource_name two_classes_one_dsl - result.provides two_classes_one_dsl, os: 'blarghle' + result.provides two_classes_one_dsl, os: "blarghle" result } before { resource_class_blarghle } # pull on it so it gets defined before the recipe runs @@ -1145,10 +1145,10 @@ describe "Recipe DSL methods" do two_classes_one_dsl = self.two_classes_one_dsl recipe = converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'blarghle' + run_context.node.automatic[:os] = "blarghle" instance_eval("#{two_classes_one_dsl} 'blah' do; end") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class_blarghle end @@ -1156,10 +1156,10 @@ describe "Recipe DSL methods" do two_classes_one_dsl = self.two_classes_one_dsl recipe = converge { # this is an ugly way to test, make Cheffish expose node attrs - run_context.node.automatic[:os] = 'linux' + run_context.node.automatic[:os] = "linux" instance_eval("#{two_classes_one_dsl} 'blah' do; end") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class end end @@ -1196,7 +1196,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{dsl_name} 'foo'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_resource).to eq resource_class expect(resource_class.called_provides).to be_truthy end @@ -1264,7 +1264,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{my_resource} 'foo'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class end @@ -1291,7 +1291,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{my_resource} 'foo'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class end end @@ -1308,7 +1308,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{my_resource} 'foo'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class end @@ -1337,7 +1337,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{my_resource} 'foo'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class2 end end @@ -1363,7 +1363,7 @@ describe "Recipe DSL methods" do recipe = converge { instance_eval("#{my_resource} 'foo'") } - expect(recipe.logged_warnings).to eq '' + expect(recipe.logged_warnings).to eq "" expect(BaseThingy.created_provider).to eq provider_class expect(provider_class.called_provides).to be_truthy end @@ -1484,7 +1484,7 @@ describe "Recipe DSL methods" do it "looks up the provider in Chef::Provider converting the resource name from snake case to camel case" do resource = nil recipe = converge { - resource = lw_resource_with_hw_provider_test_case 'blah' do; end + resource = lw_resource_with_hw_provider_test_case "blah" do; end } expect(resource.created_provider).to eq(Chef::Provider::LwResourceWithHwProviderTestCase) end diff --git a/spec/integration/recipes/remote_directory.rb b/spec/integration/recipes/remote_directory.rb index a1988ccd52..77fe183136 100644 --- a/spec/integration/recipes/remote_directory.rb +++ b/spec/integration/recipes/remote_directory.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" describe Chef::Resource::RemoteDirectory do include IntegrationSupport @@ -20,7 +20,7 @@ describe Chef::Resource::RemoteDirectory do when_the_repository "has a cookbook with a source_dir with two subdirectories, each with one file and subdir in a different alphabetical order" do before do - file 'config/client.rb', <<-EOM + file "config/client.rb", <<-EOM local_mode true cookbook_path "#{path_to('cookbooks')}" EOM diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb index 17a1eb9acd..b8c533b31d 100644 --- a/spec/integration/recipes/resource_action_spec.rb +++ b/spec/integration/recipes/resource_action_spec.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" # Houses any classes we declare module ResourceActionSpec @@ -36,7 +36,7 @@ describe "Resource.action" do end EOM expect(ActionJackson.ran_action).to eq :access_attribute - expect(ActionJackson.succeeded).to eq 'foo!' + expect(ActionJackson.succeeded).to eq "foo!" end it "the action can access public methods" do @@ -47,7 +47,7 @@ describe "Resource.action" do end EOM expect(ActionJackson.ran_action).to eq :access_method - expect(ActionJackson.succeeded).to eq 'foo_public!' + expect(ActionJackson.succeeded).to eq "foo_public!" end it "the action can access protected methods" do @@ -58,7 +58,7 @@ describe "Resource.action" do end EOM expect(ActionJackson.ran_action).to eq :access_protected_method - expect(ActionJackson.succeeded).to eq 'foo_protected!' + expect(ActionJackson.succeeded).to eq "foo_protected!" end it "the action cannot access private methods" do @@ -98,7 +98,7 @@ describe "Resource.action" do end EOM expect(ActionJackson.ran_action).to eq :access_class_method - expect(ActionJackson.succeeded).to eq 'ruby_block_converged!' + expect(ActionJackson.succeeded).to eq "ruby_block_converged!" end it "the action's resources converge before the next resource converges" do @@ -115,8 +115,8 @@ describe "Resource.action" do end EOM expect(ActionJackson.ran_action).to eq :access_attribute - expect(ActionJackson.succeeded).to eq 'foo!' - expect(ActionJackson.ruby_block_converged).to eq 'foo!' + expect(ActionJackson.succeeded).to eq "foo!" + expect(ActionJackson.ruby_block_converged).to eq "foo!" end end @@ -140,21 +140,21 @@ describe "Resource.action" do public def foo_public - 'foo_public!' + "foo_public!" end protected def foo_protected - 'foo_protected!' + "foo_protected!" end private def foo_private - 'foo_private!' + "foo_private!" end public action :access_recipe_dsl do ActionJackson.ran_action = :access_recipe_dsl - ruby_block 'hi there' do + ruby_block "hi there" do block do ActionJackson.succeeded = true end @@ -205,7 +205,7 @@ describe "Resource.action" do end it "Can retrieve ancestors of action class without crashing" do - converge { action_jackson 'hi' } + converge { action_jackson "hi" } expect { ActionJackson.action_class.ancestors.join(",") }.not_to raise_error end @@ -260,9 +260,9 @@ describe "Resource.action" do it "the default action remains the same even though new actions were specified first" do converge { - action_jackalope 'hi' do - foo 'foo!' - bar 'bar!' + action_jackalope "hi" do + foo "foo!" + bar "bar!" end } expect(ActionJackson.ran_action).to eq :access_recipe_dsl @@ -271,10 +271,10 @@ describe "Resource.action" do it "new actions run, and can access overridden, new, and overridden attributes" do converge { - action_jackalope 'hi' do - foo 'foo!' - bar 'bar!' - blarghle 'blarghle!' + action_jackalope "hi" do + foo "foo!" + bar "bar!" + blarghle "blarghle!" action :access_jackalope end } @@ -284,10 +284,10 @@ describe "Resource.action" do it "overridden actions run, call super, and can access overridden, new, and overridden attributes" do converge { - action_jackalope 'hi' do - foo 'foo!' - bar 'bar!' - blarghle 'blarghle!' + action_jackalope "hi" do + foo "foo!" + bar "bar!" + blarghle "blarghle!" action :access_attribute end } @@ -299,10 +299,10 @@ describe "Resource.action" do it "non-overridden actions run and can access overridden and non-overridden variables (but not necessarily new ones)" do converge { - action_jackalope 'hi' do - foo 'foo!' - bar 'bar!' - blarghle 'blarghle!' + action_jackalope "hi" do + foo "foo!" + bar "bar!" + blarghle "blarghle!" action :access_attribute2 end } @@ -328,8 +328,8 @@ describe "Resource.action" do it "the default action is :nothing" do converge { - no_action_jackson 'hi' do - foo 'foo!' + no_action_jackson "hi" do + foo "foo!" NoActionJackson.action_was = action end } @@ -352,7 +352,7 @@ describe "Resource.action" do it "Running the action works" do expect_recipe { - weird_action_jackson 'hi' + weird_action_jackson "hi" }.to be_up_to_date expect(WeirdActionJackson.action_was).to eq :"a-b-c d" end @@ -373,7 +373,7 @@ describe "Resource.action" do resource_name :resource_action_spec_also_with_x property :x action :set_x_to_x do - resource_action_spec_with_x 'hi' do + resource_action_spec_with_x "hi" do x x end end @@ -381,13 +381,13 @@ describe "Resource.action" do __LINE__-4 end action :set_x_to_x_in_non_initializer do - r = resource_action_spec_with_x 'hi' do + r = resource_action_spec_with_x "hi" do x 10 end x_times_2 = r.x*2 end action :set_x_to_10 do - resource_action_spec_with_x 'hi' do + resource_action_spec_with_x "hi" do x 10 end end @@ -397,7 +397,7 @@ describe "Resource.action" do it "Using the enclosing resource to set x to x emits a warning that you're using the wrong x" do recipe = converge { - resource_action_spec_also_with_x 'hi' do + resource_action_spec_also_with_x "hi" do x 1 action :set_x_to_x end @@ -409,7 +409,7 @@ describe "Resource.action" do it "Using the enclosing resource to set x to x outside the initializer emits no warning" do expect_recipe { - resource_action_spec_also_with_x 'hi' do + resource_action_spec_also_with_x "hi" do x 1 action :set_x_to_x_in_non_initializer end @@ -418,7 +418,7 @@ describe "Resource.action" do it "Using the enclosing resource to set x to 10 emits no warning" do expect_recipe { - resource_action_spec_also_with_x 'hi' do + resource_action_spec_also_with_x "hi" do x 1 action :set_x_to_10 end @@ -427,7 +427,7 @@ describe "Resource.action" do it "Using the enclosing resource to set x to 10 emits no warning" do expect_recipe { - r = resource_action_spec_also_with_x 'hi' + r = resource_action_spec_also_with_x "hi" r.x 1 r.action :set_x_to_10 }.to emit_no_warnings_or_errors @@ -442,14 +442,14 @@ describe "Resource.action" do property :template action :create do template "x" do - 'blah' + "blah" end end end it "Raises an error when attempting to use a template in the action" do expect_converge { - has_property_named_template 'hi' + has_property_named_template "hi" }.to raise_error(/Property template of has_property_named_template\[hi\] cannot be passed a block! If you meant to create a resource named template instead, you'll need to first rename the property./) end end @@ -484,16 +484,16 @@ describe "Resource.action" do end it "the methods are not available on the resource" do - expect { DeclaresActionClassMethods.new('hi').a }.to raise_error(NameError) - expect { DeclaresActionClassMethods.new('hi').b }.to raise_error(NameError) - expect { DeclaresActionClassMethods.new('hi').c }.to raise_error(NameError) - expect { DeclaresActionClassMethods.new('hi').d }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").a }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").b }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").c }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").d }.to raise_error(NameError) end it "the methods are available to the action" do r = nil expect_recipe { - r = declares_action_class_methods 'hi' + r = declares_action_class_methods "hi" }.to emit_no_warnings_or_errors expect(r.x).to eq(10) end @@ -512,17 +512,17 @@ describe "Resource.action" do end it "the methods are not available on the resource" do - expect { DeclaresActionClassMethods.new('hi').a }.to raise_error(NameError) - expect { DeclaresActionClassMethods.new('hi').b }.to raise_error(NameError) - expect { DeclaresActionClassMethods.new('hi').c }.to raise_error(NameError) - expect { DeclaresActionClassMethods.new('hi').d }.to raise_error(NameError) - expect { DeclaresActionClassMethods.new('hi').e }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").a }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").b }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").c }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").d }.to raise_error(NameError) + expect { DeclaresActionClassMethods.new("hi").e }.to raise_error(NameError) end it "the methods are available to the action" do r = nil expect_recipe { - r = declares_action_class_methods_too 'hi' + r = declares_action_class_methods_too "hi" }.to emit_no_warnings_or_errors expect(r.x).to eq(15) end diff --git a/spec/integration/recipes/resource_converge_if_changed_spec.rb b/spec/integration/recipes/resource_converge_if_changed_spec.rb index f3b562c50d..2bcccd9831 100644 --- a/spec/integration/recipes/resource_converge_if_changed_spec.rb +++ b/spec/integration/recipes/resource_converge_if_changed_spec.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" describe "Resource::ActionClass#converge_if_changed" do include IntegrationSupport @@ -23,10 +23,10 @@ describe "Resource::ActionClass#converge_if_changed" do result = Class.new(Chef::Resource) do def self.to_s; resource_name; end def self.inspect; resource_name.inspect; end - property :identity1, identity: true, default: 'default_identity1' - property :control1, desired_state: false, default: 'default_control1' - property :state1, default: 'default_state1' - property :state2, default: 'default_state2' + property :identity1, identity: true, default: "default_identity1" + property :control1, desired_state: false, default: "default_control1" + property :state1, default: "default_state1" + property :state2, default: "default_state2" attr_accessor :converged def initialize(*args) super @@ -51,8 +51,8 @@ describe "Resource::ActionClass#converge_if_changed" do context "and current_resource with state1=current, state2=current" do before :each do resource_class.load_current_value do - state1 'current_state1' - state2 'current_state2' + state1 "current_state1" + state2 "current_state2" end end @@ -198,8 +198,8 @@ EOM context "and current_resource with identity1=current, control1=current" do before :each do resource_class.load_current_value do - identity1 'current_identity1' - control1 'current_control1' + identity1 "current_identity1" + control1 "current_control1" end end @@ -314,8 +314,8 @@ EOM context "and current_resource with state1=current, state2=current" do before :each do resource_class.load_current_value do - state1 'current_state1' - state2 'current_state2' + state1 "current_state1" + state2 "current_state2" end end diff --git a/spec/integration/recipes/resource_load_spec.rb b/spec/integration/recipes/resource_load_spec.rb index 556201efd8..66a36b1431 100644 --- a/spec/integration/recipes/resource_load_spec.rb +++ b/spec/integration/recipes/resource_load_spec.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" describe "Resource.load_current_value" do include IntegrationSupport @@ -55,29 +55,29 @@ describe "Resource.load_current_value" do e = self r = nil converge { - r = public_send(e.resource_name, 'blah') do - x 'desired' + r = public_send(e.resource_name, "blah") do + x "desired" end } r end it "current_resource is passed name but not x" do - expect(resource.current_value.x).to eq 'loaded 2 (name=blah)' + expect(resource.current_value.x).to eq "loaded 2 (name=blah)" end it "resource.current_value returns a different resource" do - expect(resource.current_value.x).to eq 'loaded 2 (name=blah)' - expect(resource.x).to eq 'desired' + expect(resource.current_value.x).to eq "loaded 2 (name=blah)" + expect(resource.x).to eq "desired" end it "resource.current_value constructs the resource anew each time" do - expect(resource.current_value.x).to eq 'loaded 2 (name=blah)' - expect(resource.current_value.x).to eq 'loaded 3 (name=blah)' + expect(resource.current_value.x).to eq "loaded 2 (name=blah)" + expect(resource.current_value.x).to eq "loaded 3 (name=blah)" end it "the provider accesses the current value of x" do - expect(resource.class.created_x).to eq 'desired' + expect(resource.class.created_x).to eq "desired" end context "and identity: :i and :d with desired_state: false" do @@ -89,12 +89,12 @@ describe "Resource.load_current_value" do } before { - resource.i 'desired_i' - resource.d 'desired_d' + resource.i "desired_i" + resource.d "desired_d" } it "i, name and d are passed to load_current_value, but not x" do - expect(resource.current_value.x).to eq 'loaded 2 (d=desired_d, i=desired_i, name=blah)' + expect(resource.current_value.x).to eq "loaded 2 (d=desired_d, i=desired_i, name=blah)" end end @@ -107,12 +107,12 @@ describe "Resource.load_current_value" do } before { - resource.i 'desired_i' - resource.d 'desired_d' + resource.i "desired_i" + resource.d "desired_d" } it "i, name and d are passed to load_current_value, but not x" do - expect(resource.current_value.x).to eq 'loaded 2 (d=desired_d, i=desired_i, name=blah)' + expect(resource.current_value.x).to eq "loaded 2 (d=desired_d, i=desired_i, name=blah)" end end end @@ -122,14 +122,14 @@ describe "Resource.load_current_value" do e = self r = nil converge { - r = public_send(e.resource_name, 'blah') do + r = public_send(e.resource_name, "blah") do end } r end it "the provider accesses values from load_current_value" do - expect(resource.class.created_x).to eq 'loaded 1 (name=blah)' + expect(resource.class.created_x).to eq "loaded 1 (name=blah)" end end @@ -151,8 +151,8 @@ describe "Resource.load_current_value" do e = self r = nil converge { - r = public_send(e.subresource_name, 'blah') do - x 'desired' + r = public_send(e.subresource_name, "blah") do + x "desired" end } r @@ -160,7 +160,7 @@ describe "Resource.load_current_value" do context "and a child resource class with no load_current_value" do it "the parent load_current_value is used" do - expect(subresource.current_value.x).to eq 'loaded 2 (name=blah)' + expect(subresource.current_value.x).to eq "loaded 2 (name=blah)" end it "load_current_value yields a copy of the child class" do expect(subresource.current_value).to be_kind_of(subresource_class) @@ -179,8 +179,8 @@ describe "Resource.load_current_value" do it "the overridden load_current_value is used" do current_resource = subresource.current_value - expect(current_resource.x).to eq 'default 3' - expect(current_resource.y).to eq 'loaded_y 2 (name=blah)' + expect(current_resource.x).to eq "default 3" + expect(current_resource.y).to eq "loaded_y 2 (name=blah)" end end @@ -197,8 +197,8 @@ describe "Resource.load_current_value" do it "the original load_current_value is called as well as the child one" do current_resource = subresource.current_value - expect(current_resource.x).to eq 'loaded 3 (name=blah)' - expect(current_resource.y).to eq 'loaded_y 4 (name=blah, x=loaded 3 (name=blah))' + expect(current_resource.x).to eq "loaded 3 (name=blah)" + expect(current_resource.y).to eq "loaded_y 4 (name=blah, x=loaded 3 (name=blah))" end end end diff --git a/spec/integration/solo/solo_spec.rb b/spec/integration/solo/solo_spec.rb index 6240a38144..4849cb4d40 100644 --- a/spec/integration/solo/solo_spec.rb +++ b/spec/integration/solo/solo_spec.rb @@ -1,9 +1,9 @@ -require 'support/shared/integration/integration_helper' -require 'chef/mixin/shell_out' -require 'chef/run_lock' -require 'chef/config' -require 'timeout' -require 'fileutils' +require "support/shared/integration/integration_helper" +require "chef/mixin/shell_out" +require "chef/run_lock" +require "chef/config" +require "timeout" +require "fileutils" describe "chef-solo" do include IntegrationSupport @@ -19,12 +19,12 @@ describe "chef-solo" do when_the_repository "has a cookbook with a basic recipe" do before do - file 'cookbooks/x/metadata.rb', cookbook_x_100_metadata_rb - file 'cookbooks/x/recipes/default.rb', 'puts "ITWORKS"' + file "cookbooks/x/metadata.rb", cookbook_x_100_metadata_rb + file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"' end it "should complete with success" do - file 'config/solo.rb', <<EOM + file "config/solo.rb", <<EOM cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" EOM @@ -34,12 +34,12 @@ EOM end it "should evaluate its node.json file" do - file 'config/solo.rb', <<EOM + file "config/solo.rb", <<EOM cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" EOM - file 'config/node.json',<<-E + file "config/node.json",<<-E {"run_list":["x::default"]} E @@ -52,15 +52,15 @@ E when_the_repository "has a cookbook with an undeclared dependency" do before do - file 'cookbooks/x/metadata.rb', cookbook_x_100_metadata_rb - file 'cookbooks/x/recipes/default.rb', 'include_recipe "ancient::aliens"' + file "cookbooks/x/metadata.rb", cookbook_x_100_metadata_rb + file "cookbooks/x/recipes/default.rb", 'include_recipe "ancient::aliens"' - file 'cookbooks/ancient/metadata.rb', cookbook_ancient_100_metadata_rb - file 'cookbooks/ancient/recipes/aliens.rb', 'print "it was aliens"' + file "cookbooks/ancient/metadata.rb", cookbook_ancient_100_metadata_rb + file "cookbooks/ancient/recipes/aliens.rb", 'print "it was aliens"' end it "should exit with an error" do - file 'config/solo.rb', <<EOM + file "config/solo.rb", <<EOM cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" EOM @@ -72,9 +72,9 @@ EOM when_the_repository "has a cookbook with an incompatible chef_version" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0', "\nchef_version '~> 999.0'") - file 'cookbooks/x/recipes/default.rb', 'puts "ITWORKS"' - file 'config/solo.rb', <<EOM + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'") + file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"' + file "config/solo.rb", <<EOM cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" EOM @@ -89,9 +89,9 @@ EOM when_the_repository "has a cookbook with an incompatible ohai_version" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0', "\nohai_version '~> 999.0'") - file 'cookbooks/x/recipes/default.rb', 'puts "ITWORKS"' - file 'config/solo.rb', <<EOM + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nohai_version '~> 999.0'") + file "cookbooks/x/recipes/default.rb", 'puts "ITWORKS"' + file "config/solo.rb", <<EOM cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" EOM @@ -107,10 +107,10 @@ EOM when_the_repository "has a cookbook with a recipe with sleep" do before do - directory 'logs' - file 'logs/runs.log', '' - file 'cookbooks/x/metadata.rb', cookbook_x_100_metadata_rb - file 'cookbooks/x/recipes/default.rb', <<EOM + directory "logs" + file "logs/runs.log", "" + file "cookbooks/x/metadata.rb", cookbook_x_100_metadata_rb + file "cookbooks/x/recipes/default.rb", <<EOM ruby_block "sleeping" do block do sleep 5 @@ -120,7 +120,7 @@ EOM end it "while running solo concurrently" do - file 'config/solo.rb', <<EOM + file "config/solo.rb", <<EOM cookbook_path "#{path_to('cookbooks')}" file_cache_path "#{path_to('config/cache')}" EOM @@ -149,7 +149,7 @@ EOM # Unfortunately file / directory helpers in integration tests # are implemented using before(:each) so we need to do all below # checks in one example. - run_log = File.read(path_to('logs/runs.log')) + run_log = File.read(path_to("logs/runs.log")) # both of the runs should succeed expect(run_log.lines.reject {|l| !l.include? "INFO: Chef Run complete in"}.length).to eq(2) diff --git a/spec/scripts/ssl-serve.rb b/spec/scripts/ssl-serve.rb index 24ed70addc..0a2376049b 100644 --- a/spec/scripts/ssl-serve.rb +++ b/spec/scripts/ssl-serve.rb @@ -5,10 +5,10 @@ # You can use it to test various HTTP behaviors in chef, like chef-client's # `-j` and `-c` options and remote_file with https connections. # -require 'pp' -require 'openssl' -require 'webrick' -require 'webrick/https' +require "pp" +require "openssl" +require "webrick" +require "webrick/https" $ssl = true @@ -32,9 +32,9 @@ end # 5 == debug, 3 == warning LOGGER = WEBrick::Log.new(STDOUT, 5) DEFAULT_OPTIONS = { - :server => 'webrick', + :server => "webrick", :Port => 9000, - :Host => 'localhost', + :Host => "localhost", :environment => :none, :Logger => LOGGER, :DocumentRoot => File.expand_path("/tmp/chef-118-sampledata") @@ -45,7 +45,7 @@ webrick_opts = DEFAULT_OPTIONS.merge(server_opts) pp :webrick_opts => webrick_opts server = WEBrick::HTTPServer.new(webrick_opts) -trap 'INT' do server.shutdown end +trap "INT" do server.shutdown end server.start diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index deedffed91..2d95ddcae9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -28,15 +28,15 @@ end $:.unshift File.expand_path("../..", __FILE__) -require 'rubygems' -require 'rspec/mocks' +require "rubygems" +require "rspec/mocks" $:.unshift(File.join(File.dirname(__FILE__), "..", "lib")) $:.unshift(File.expand_path("../lib", __FILE__)) $:.unshift(File.dirname(__FILE__)) if ENV["COVERAGE"] - require 'simplecov' + require "simplecov" SimpleCov.start do add_filter "/spec/" add_group "Remote File", "remote_file" @@ -46,34 +46,34 @@ if ENV["COVERAGE"] end end -require 'chef' -require 'chef/knife' +require "chef" +require "chef/knife" -Dir['lib/chef/knife/**/*.rb']. - map {|f| f.gsub('lib/', '') }. - map {|f| f.gsub(%r[\.rb$], '') }. +Dir["lib/chef/knife/**/*.rb"]. + map {|f| f.gsub("lib/", "") }. + map {|f| f.gsub(%r[\.rb$], "") }. each {|f| require f } -require 'chef/resource_resolver' -require 'chef/provider_resolver' +require "chef/resource_resolver" +require "chef/provider_resolver" -require 'chef/mixins' -require 'chef/dsl' -require 'chef/application' -require 'chef/applications' +require "chef/mixins" +require "chef/dsl" +require "chef/application" +require "chef/applications" -require 'chef/shell' -require 'chef/util/file_edit' +require "chef/shell" +require "chef/util/file_edit" -require 'chef/config' +require "chef/config" # If you want to load anything into the testing environment # without versioning it, add it to spec/support/local_gems.rb -require 'spec/support/local_gems.rb' if File.exists?(File.join(File.dirname(__FILE__), 'support', 'local_gems.rb')) +require "spec/support/local_gems.rb" if File.exists?(File.join(File.dirname(__FILE__), "support", "local_gems.rb")) # Explicitly require spec helpers that need to load first -require 'spec/support/platform_helpers' -require 'spec/support/shared/unit/mock_shellout' +require "spec/support/platform_helpers" +require "spec/support/shared/unit/mock_shellout" # Autoloads support files # Excludes support/platforms by default @@ -81,23 +81,23 @@ require 'spec/support/shared/unit/mock_shellout' Dir["spec/support/**/*.rb"]. reject { |f| f =~ %r{^spec/support/platforms} }. reject { |f| f =~ %r{^spec/support/pedant} }. - map { |f| f.gsub(%r{.rb$}, '') }. - map { |f| f.gsub(%r[spec/], '')}. + map { |f| f.gsub(%r{.rb$}, "") }. + map { |f| f.gsub(%r[spec/], "")}. each { |f| require f } OHAI_SYSTEM = Ohai::System.new OHAI_SYSTEM.all_plugins("platform") test_node = Chef::Node.new -test_node.automatic['os'] = (OHAI_SYSTEM['os'] || 'unknown_os').dup.freeze -test_node.automatic['platform_family'] = (OHAI_SYSTEM['platform_family'] || 'unknown_platform_family').dup.freeze -test_node.automatic['platform'] = (OHAI_SYSTEM['platform'] || 'unknown_platform').dup.freeze -test_node.automatic['platform_version'] = (OHAI_SYSTEM['platform_version'] || 'unknown_platform_version').dup.freeze +test_node.automatic["os"] = (OHAI_SYSTEM["os"] || "unknown_os").dup.freeze +test_node.automatic["platform_family"] = (OHAI_SYSTEM["platform_family"] || "unknown_platform_family").dup.freeze +test_node.automatic["platform"] = (OHAI_SYSTEM["platform"] || "unknown_platform").dup.freeze +test_node.automatic["platform_version"] = (OHAI_SYSTEM["platform_version"] || "unknown_platform_version").dup.freeze TEST_NODE = test_node.freeze -TEST_OS = TEST_NODE['os'] -TEST_PLATFORM = TEST_NODE['platform'] -TEST_PLATFORM_VERSION = TEST_NODE['platform_version'] -TEST_PLATFORM_FAMILY = TEST_NODE['platform_family'] +TEST_OS = TEST_NODE["os"] +TEST_PLATFORM = TEST_NODE["platform"] +TEST_PLATFORM_VERSION = TEST_NODE["platform_version"] +TEST_PLATFORM_FAMILY = TEST_NODE["platform_family"] RSpec.configure do |config| config.include(Matchers) @@ -180,7 +180,7 @@ RSpec.configure do |config| node = TEST_NODE.dup resource_class = Chef::ResourceResolver.resolve(type, node: node) if resource_class - resource = resource_class.new('test', Chef::RunContext.new(node, nil, nil)) + resource = resource_class.new("test", Chef::RunContext.new(node, nil, nil)) begin provider = resource.provider_for_action(Array(resource_class.default_action).first) provider.class != target_provider @@ -203,20 +203,20 @@ RSpec.configure do |config| Chef::Config.treat_deprecation_warnings_as_errors(true) # Set environment variable so the setting persists in child processes - ENV['CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS'] = "1" + ENV["CHEF_TREAT_DEPRECATION_WARNINGS_AS_ERRORS"] = "1" end # raise if anyone commits any test to CI with :focus set on it config.before(:example, :focus) do - raise 'This example was committed with `:focus` and should not have been' - end if ENV['CI'] + raise "This example was committed with `:focus` and should not have been" + end if ENV["CI"] config.before(:suite) do ARGV.clear end end -require 'webrick/utils' +require "webrick/utils" # Webrick uses a centralized/synchronized timeout manager. It works by # starting a thread to check for timeouts on an interval. The timeout @@ -242,4 +242,4 @@ module WEBrick end # Enough stuff needs json serialization that I'm just adding it here for equality asserts -require 'chef/json_compat' +require "chef/json_compat" diff --git a/spec/stress/win32/file_spec.rb b/spec/stress/win32/file_spec.rb index 6c4b26b05c..fac811774f 100644 --- a/spec/stress/win32/file_spec.rb +++ b/spec/stress/win32/file_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/win32/file' if windows? +require "spec_helper" +require "chef/win32/file" if windows? -describe 'Chef::ReservedNames::Win32::File', :windows_only do +describe "Chef::ReservedNames::Win32::File", :windows_only do before(:each) do @path = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "data", "old_home_dir", "my-dot-emacs")) end diff --git a/spec/stress/win32/memory_spec.rb b/spec/stress/win32/memory_spec.rb index ed3ad306d0..707613071e 100644 --- a/spec/stress/win32/memory_spec.rb +++ b/spec/stress/win32/memory_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -describe 'Chef::ReservedNames::Win32::Memory', :windows_only do +describe "Chef::ReservedNames::Win32::Memory", :windows_only do end diff --git a/spec/stress/win32/security_spec.rb b/spec/stress/win32/security_spec.rb index 4e0c903aea..1e7d8c3b6f 100644 --- a/spec/stress/win32/security_spec.rb +++ b/spec/stress/win32/security_spec.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" if windows? - require 'chef/win32/security' - require 'tmpdir' - require 'fileutils' + require "chef/win32/security" + require "tmpdir" + require "fileutils" end -describe 'Chef::ReservedNames::Win32::Security', :windows_only do +describe "Chef::ReservedNames::Win32::Security", :windows_only do def monkeyfoo File.join(CHEF_SPEC_DATA, "monkeyfoo").gsub("/", "\\") diff --git a/spec/support/chef_helpers.rb b/spec/support/chef_helpers.rb index 851b1dce0a..a792cd3c5f 100644 --- a/spec/support/chef_helpers.rb +++ b/spec/support/chef_helpers.rb @@ -15,7 +15,7 @@ # CHEF_SPEC_DATA = File.expand_path(File.dirname(__FILE__) + "/../data/") CHEF_SPEC_ASSETS = File.expand_path(File.dirname(__FILE__) + "/../functional/assets/") -CHEF_SPEC_BACKUP_PATH = File.join(Dir.tmpdir, 'test-backup-path') +CHEF_SPEC_BACKUP_PATH = File.join(Dir.tmpdir, "test-backup-path") Chef::Config[:log_level] = :fatal Chef::Config[:persistent_queue] = false @@ -82,12 +82,12 @@ end # This is a helper to canonicalize paths that we're using in the file # tests. def canonicalize_path(path) - windows? ? path.gsub('/', '\\') : path + windows? ? path.gsub("/", '\\') : path end # Check if a cmd exists on the PATH def which(cmd) - paths = ENV['PATH'].split(File::PATH_SEPARATOR) + [ '/bin', '/usr/bin', '/sbin', '/usr/sbin' ] + paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ] paths.each do |path| filename = File.join(path, cmd) return filename if File.executable?(filename) diff --git a/spec/support/key_helpers.rb b/spec/support/key_helpers.rb index 076f709380..cec0e26cb4 100644 --- a/spec/support/key_helpers.rb +++ b/spec/support/key_helpers.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" shared_examples_for "a knife key command" do let(:stderr) { StringIO.new } diff --git a/spec/support/lib/chef/resource/with_state.rb b/spec/support/lib/chef/resource/with_state.rb index 773ae7ddb8..60269632b0 100644 --- a/spec/support/lib/chef/resource/with_state.rb +++ b/spec/support/lib/chef/resource/with_state.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/json_compat' +require "chef/knife" +require "chef/json_compat" class Chef class Resource diff --git a/spec/support/lib/chef/resource/zen_follower.rb b/spec/support/lib/chef/resource/zen_follower.rb index 155e6ae729..83ae078f1d 100644 --- a/spec/support/lib/chef/resource/zen_follower.rb +++ b/spec/support/lib/chef/resource/zen_follower.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/json_compat' +require "chef/knife" +require "chef/json_compat" class Chef class Resource diff --git a/spec/support/lib/chef/resource/zen_master.rb b/spec/support/lib/chef/resource/zen_master.rb index 4106549d79..6f6f4fcabb 100644 --- a/spec/support/lib/chef/resource/zen_master.rb +++ b/spec/support/lib/chef/resource/zen_master.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'chef/knife' -require 'chef/json_compat' +require "chef/knife" +require "chef/json_compat" class Chef class Resource diff --git a/spec/support/matchers/leak.rb b/spec/support/matchers/leak.rb index 01d1e53f92..80f0ae44c7 100644 --- a/spec/support/matchers/leak.rb +++ b/spec/support/matchers/leak.rb @@ -60,10 +60,10 @@ module Matchers def profiler @profiler ||= begin if Chef::Platform.windows? - require File.join(File.dirname(__FILE__), '..', 'platforms', 'prof', 'win32') + require File.join(File.dirname(__FILE__), "..", "platforms", "prof", "win32") RSpec::Prof::Win32::Profiler.new else - require File.join(File.dirname(__FILE__), '..', 'prof', 'gc') + require File.join(File.dirname(__FILE__), "..", "prof", "gc") RSpec::Prof::GC::Profiler.new end end diff --git a/spec/support/mock/constant.rb b/spec/support/mock/constant.rb index c706ad29dd..98756d715f 100644 --- a/spec/support/mock/constant.rb +++ b/spec/support/mock/constant.rb @@ -23,7 +23,7 @@ def mock_constants(constants, &block) end def parse_constant(constant) - source, _, constant_name = constant.to_s.rpartition('::') + source, _, constant_name = constant.to_s.rpartition("::") [constantize(source), constant_name] end @@ -41,7 +41,7 @@ end # File activesupport/lib/active_support/inflector/methods.rb, line 209 def constantize(camel_cased_word) - names = camel_cased_word.split('::') + names = camel_cased_word.split("::") names.shift if names.empty? || names.first.empty? constant = Object diff --git a/spec/support/mock/platform.rb b/spec/support/mock/platform.rb index 7eae82fe7d..a8bbf13589 100644 --- a/spec/support/mock/platform.rb +++ b/spec/support/mock/platform.rb @@ -7,7 +7,7 @@ # or +Chef::FileAccessControl+ def platform_mock(platform = :unix, &block) allow(ChefConfig).to receive(:windows?).and_return(platform == :windows ? true : false) - ENV['SYSTEMDRIVE'] = (platform == :windows ? 'C:' : nil) + ENV["SYSTEMDRIVE"] = (platform == :windows ? "C:" : nil) if platform == :windows Chef::Config.set_defaults_for_windows @@ -16,7 +16,7 @@ def platform_mock(platform = :unix, &block) end if block_given? - mock_constants({"RUBY_PLATFORM" => (platform == :windows ? 'i386-mingw32' : 'x86_64-darwin11.2.0'), + mock_constants({"RUBY_PLATFORM" => (platform == :windows ? "i386-mingw32" : "x86_64-darwin11.2.0"), "File::PATH_SEPARATOR" => (platform == :windows ? ";" : ":"), "File::ALT_SEPARATOR" => (platform == :windows ? "\\" : nil) }) do yield diff --git a/spec/support/platform_helpers.rb b/spec/support/platform_helpers.rb index e80df90499..0259dc6dfb 100644 --- a/spec/support/platform_helpers.rb +++ b/spec/support/platform_helpers.rb @@ -1,6 +1,6 @@ -require 'fcntl' -require 'chef/mixin/shell_out' -require 'ohai/mixin/gce_metadata' +require "fcntl" +require "chef/mixin/shell_out" +require "ohai/mixin/gce_metadata" class ShellHelpers extend Chef::Mixin::ShellOut @@ -11,11 +11,11 @@ def ruby_lt_20? end def chef_gte_13? - Chef::VERSION.split('.').first.to_i >= 13 + Chef::VERSION.split(".").first.to_i >= 13 end def chef_lt_13? - Chef::VERSION.split('.').first.to_i < 13 + Chef::VERSION.split(".").first.to_i < 13 end def ruby_gte_19? @@ -27,11 +27,11 @@ def ruby_20? end def ruby_64bit? - !!(RbConfig::CONFIG['host_cpu'] =~ /x86_64/) + !!(RbConfig::CONFIG["host_cpu"] =~ /x86_64/) end def ruby_32bit? - !!(RbConfig::CONFIG['host_cpu'] =~ /i686/) + !!(RbConfig::CONFIG["host_cpu"] =~ /i686/) end def windows? @@ -43,29 +43,29 @@ def ohai OHAI_SYSTEM end -require 'wmi-lite/wmi' if windows? +require "wmi-lite/wmi" if windows? def windows_domain_joined? return false unless windows? wmi = WmiLite::Wmi.new - computer_system = wmi.first_of('Win32_ComputerSystem') - computer_system['partofdomain'] + computer_system = wmi.first_of("Win32_ComputerSystem") + computer_system["partofdomain"] end def windows_win2k3? return false unless windows? wmi = WmiLite::Wmi.new - host = wmi.first_of('Win32_OperatingSystem') - (host['version'] && host['version'].start_with?("5.2")) + host = wmi.first_of("Win32_OperatingSystem") + (host["version"] && host["version"].start_with?("5.2")) end def windows_2008r2_or_later? return false unless windows? wmi = WmiLite::Wmi.new - host = wmi.first_of('Win32_OperatingSystem') - version = host['version'] + host = wmi.first_of("Win32_OperatingSystem") + version = host["version"] return false unless version - components = version.split('.').map do | component | + components = version.split(".").map do | component | component.to_i end components.length >=2 && components[0] >= 6 && components[1] >= 1 @@ -75,7 +75,7 @@ def windows_powershell_dsc? return false unless windows? supports_dsc = false begin - wmi = WmiLite::Wmi.new('root/microsoft/windows/desiredstateconfiguration') + wmi = WmiLite::Wmi.new("root/microsoft/windows/desiredstateconfiguration") lcm = wmi.query("SELECT * FROM meta_class WHERE __this ISA 'MSFT_DSCLocalConfigurationManager'") supports_dsc = !! lcm rescue WmiLite::WmiException @@ -84,7 +84,7 @@ def windows_powershell_dsc? end def windows_nano_server? - require 'chef/platform/query_helpers' + require "chef/platform/query_helpers" Chef::Platform.windows_nano_server? end @@ -117,7 +117,7 @@ end # detects if the hardware is 64-bit (evaluates to true in "WOW64" mode in a 32-bit app on a 64-bit system) def windows64? - windows? && ( ENV['PROCESSOR_ARCHITECTURE'] == 'AMD64' || ENV['PROCESSOR_ARCHITEW6432'] == 'AMD64' ) + windows? && ( ENV["PROCESSOR_ARCHITECTURE"] == "AMD64" || ENV["PROCESSOR_ARCHITEW6432"] == "AMD64" ) end # detects if the hardware is 32-bit @@ -156,10 +156,10 @@ def wpar? end def supports_cloexec? - Fcntl.const_defined?('F_SETFD') && Fcntl.const_defined?('FD_CLOEXEC') + Fcntl.const_defined?("F_SETFD") && Fcntl.const_defined?("FD_CLOEXEC") end -DEV_NULL = windows? ? 'NUL' : '/dev/null' +DEV_NULL = windows? ? "NUL" : "/dev/null" def selinux_enabled? # This code is currently copied from lib/chef/util/selinux to make diff --git a/spec/support/platforms/prof/win32.rb b/spec/support/platforms/prof/win32.rb index ab256ff0fc..379f75a594 100644 --- a/spec/support/platforms/prof/win32.rb +++ b/spec/support/platforms/prof/win32.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/win32/process' +require "chef/win32/process" module RSpec module Prof diff --git a/spec/support/platforms/win32/spec_service.rb b/spec/support/platforms/win32/spec_service.rb index 3e1f6c3638..037ccc93de 100644 --- a/spec/support/platforms/win32/spec_service.rb +++ b/spec/support/platforms/win32/spec_service.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'win32/daemon' +require "win32/daemon" class SpecService < ::Win32::Daemon def service_init @@ -26,7 +26,7 @@ class SpecService < ::Win32::Daemon def service_main(*startup_parameters) while running? do if !File.exists?(@test_service_file) - File.open(@test_service_file, 'wb') do |f| + File.open(@test_service_file, "wb") do |f| f.write("This file is created by SpecService") end end diff --git a/spec/support/shared/context/client.rb b/spec/support/shared/context/client.rb index eec66dcb26..2089928618 100644 --- a/spec/support/shared/context/client.rb +++ b/spec/support/shared/context/client.rb @@ -1,5 +1,5 @@ -require 'spec_helper' +require "spec_helper" # Stubs a basic client object shared_context "client" do @@ -140,7 +140,7 @@ shared_context "a client run" do before do Chef::Config[:client_fork] = enable_fork - Chef::Config[:cache_path] = windows? ? 'C:\chef' : '/var/chef' + Chef::Config[:cache_path] = windows? ? 'C:\chef' : "/var/chef" Chef::Config[:why_run] = false Chef::Config[:audit_mode] = :enabled diff --git a/spec/support/shared/context/config.rb b/spec/support/shared/context/config.rb index 1412356f3a..bb4ff7e0d1 100644 --- a/spec/support/shared/context/config.rb +++ b/spec/support/shared/context/config.rb @@ -5,15 +5,15 @@ # # Required chef files here: -require 'chef/config' +require "chef/config" # Required spec files here: -require 'spec_helper' +require "spec_helper" # Basic config. Nothing fancy. shared_context "default config options" do before do - Chef::Config[:cache_path] = windows? ? 'C:\chef' : '/var/chef' + Chef::Config[:cache_path] = windows? ? 'C:\chef' : "/var/chef" end # Don't need to have an after block to reset the config... diff --git a/spec/support/shared/context/win32.rb b/spec/support/shared/context/win32.rb index 60ed92ca1d..9e0099d8af 100644 --- a/spec/support/shared/context/win32.rb +++ b/spec/support/shared/context/win32.rb @@ -18,8 +18,8 @@ RSpec.shared_context "Win32" do before(:all) do @original_win32 = if defined?(Win32) - win32 = Object.send(:const_get, 'Win32') - Object.send(:remove_const, 'Win32') + win32 = Object.send(:const_get, "Win32") + Object.send(:remove_const, "Win32") win32 else nil @@ -28,7 +28,7 @@ RSpec.shared_context "Win32" do end after(:all) do - Object.send(:remove_const, 'Win32') if defined?(Win32) - Object.send(:const_set, 'Win32', @original_win32) if @original_win32 + Object.send(:remove_const, "Win32") if defined?(Win32) + Object.send(:const_set, "Win32", @original_win32) if @original_win32 end end diff --git a/spec/support/shared/examples/client.rb b/spec/support/shared/examples/client.rb index 330cb40ac6..5af63dc307 100644 --- a/spec/support/shared/examples/client.rb +++ b/spec/support/shared/examples/client.rb @@ -1,6 +1,6 @@ -require 'spec_helper' -require 'spec/support/shared/context/client' +require "spec_helper" +require "spec/support/shared/context/client" # requires platform and platform_version be defined shared_examples "a completed run" do diff --git a/spec/support/shared/functional/directory_resource.rb b/spec/support/shared/functional/directory_resource.rb index 51c7550a78..6aeef139b3 100644 --- a/spec/support/shared/functional/directory_resource.rb +++ b/spec/support/shared/functional/directory_resource.rb @@ -48,7 +48,7 @@ shared_examples_for "a directory resource" do expect(File).not_to exist(path) resource.recursive(true) - @recursive_path = File.join(path, 'red-headed-stepchild') + @recursive_path = File.join(path, "red-headed-stepchild") resource.path(@recursive_path) resource.run_action(:create) end @@ -133,7 +133,7 @@ shared_examples_for "a directory resource" do context "with the recursive option" do before do - FileUtils.mkdir(File.join(path, 'red-headed-stepchild')) + FileUtils.mkdir(File.join(path, "red-headed-stepchild")) resource.recursive(true) resource.run_action(:delete) end @@ -152,7 +152,7 @@ shared_context Chef::Resource::Directory do # 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 diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb index 3ce3c9c94e..4f517b2041 100644 --- a/spec/support/shared/functional/file_resource.rb +++ b/spec/support/shared/functional/file_resource.rb @@ -144,7 +144,7 @@ shared_examples_for "a file with the wrong content" do end context "when diff is enabled" do - describe 'sensitive attribute' do + describe "sensitive attribute" do context "should be insensitive by default" do it { expect(resource.sensitive).to(be_falsey) } end @@ -165,7 +165,7 @@ shared_examples_for "a file with the wrong content" do end it "should suppress the diff" do - expect(resource.diff).to(include('suppressed sensitive resource')) + expect(resource.diff).to(include("suppressed sensitive resource")) expect(reporter_messages[1]).to eq("suppressed sensitive resource") end @@ -776,7 +776,7 @@ shared_examples_for "a configured file resource" do end context "when the target file is a socket",:unix_only do - require 'socket' + require "socket" # It turns out that the path to a socket can have at most ~104 # bytes. Therefore we are creating our sockets in tmpdir so that @@ -1020,14 +1020,14 @@ end shared_context Chef::Resource::File do if windows? - require 'chef/win32/file' + require "chef/win32/file" end # We create the files in a different directory than tmp to exercise # 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 diff --git a/spec/support/shared/functional/http.rb b/spec/support/shared/functional/http.rb index cfbb8e3689..7b7c17106d 100644 --- a/spec/support/shared/functional/http.rb +++ b/spec/support/shared/functional/http.rb @@ -22,11 +22,11 @@ module ChefHTTPShared def nyan_uncompressed_filename - File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png') + File.join(CHEF_SPEC_DATA, "remote_file", "nyan_cat.png") end def nyan_compressed_filename - File.join(CHEF_SPEC_DATA, 'remote_file', 'nyan_cat.png.gz') + File.join(CHEF_SPEC_DATA, "remote_file", "nyan_cat.png.gz") end def binread(file) @@ -60,7 +60,7 @@ module ChefHTTPShared # this ends in .gz, we do not uncompress it and drop it on the filesystem as a .gz file (the internet often lies) # (expected_content should be compressed) - @api.get("/nyan_cat.png.gz", 200, nil, { 'Content-Type' => 'application/gzip', 'Content-Encoding' => 'gzip' } ) { + @api.get("/nyan_cat.png.gz", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) { File.open(nyan_compressed_filename, "rb") do |f| f.read end @@ -68,7 +68,7 @@ module ChefHTTPShared # this is an uncompressed file that was compressed by some mod_gzip-ish webserver thingy, so we will expand it # (expected_content should be uncompressed) - @api.get("/nyan_cat_compressed.png", 200, nil, { 'Content-Type' => 'application/gzip', 'Content-Encoding' => 'gzip' } ) { + @api.get("/nyan_cat_compressed.png", 200, nil, { "Content-Type" => "application/gzip", "Content-Encoding" => "gzip" } ) { File.open(nyan_compressed_filename, "rb") do |f| f.read end @@ -81,7 +81,7 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_content_length.png", 200, nil, { - 'Content-Length' => nyan_uncompressed_size.to_s + "Content-Length" => nyan_uncompressed_size.to_s } ) { File.open(nyan_uncompressed_filename, "rb") do |f| @@ -92,9 +92,9 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_content_length_compressed.png", 200, nil, { - 'Content-Length' => nyan_compressed_size.to_s, - 'Content-Type' => 'application/gzip', - 'Content-Encoding' => 'gzip', + "Content-Length" => nyan_compressed_size.to_s, + "Content-Type" => "application/gzip", + "Content-Encoding" => "gzip", } ) { File.open(nyan_compressed_filename, "rb") do |f| @@ -109,7 +109,7 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_truncated.png", 200, nil, { - 'Content-Length' => (nyan_uncompressed_size + 1).to_s + "Content-Length" => (nyan_uncompressed_size + 1).to_s } ) { File.open(nyan_uncompressed_filename, "rb") do |f| @@ -120,9 +120,9 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_truncated_compressed.png", 200, nil, { - 'Content-Length' => (nyan_compressed_size + 1).to_s, - 'Content-Type' => 'application/gzip', - 'Content-Encoding' => 'gzip', + "Content-Length" => (nyan_compressed_size + 1).to_s, + "Content-Type" => "application/gzip", + "Content-Encoding" => "gzip", } ) { File.open(nyan_compressed_filename, "rb") do |f| @@ -137,8 +137,8 @@ module ChefHTTPShared # (expected_content should be uncompressed) @api.get("/nyan_cat_transfer_encoding.png", 200, nil, { - 'Content-Length' => (nyan_uncompressed_size + 1).to_s, - 'Transfer-Encoding' => 'anything', + "Content-Length" => (nyan_uncompressed_size + 1).to_s, + "Transfer-Encoding" => "anything", } ) { File.open(nyan_uncompressed_filename, "rb") do |f| @@ -149,19 +149,19 @@ module ChefHTTPShared # # 403 with a Content-Length # - @api.get('/forbidden', 403, 'Forbidden', + @api.get("/forbidden", 403, "Forbidden", { - 'Content-Length' => 'Forbidden'.bytesize.to_s + "Content-Length" => "Forbidden".bytesize.to_s } ) - @api.post('/posty', 200, 'Hi!') + @api.post("/posty", 200, "Hi!") # # 400 with an error # - @api.get('/bad_request', 400, '{ "error": [ "Your request is just terrible." ] }') - @api.post('/bad_request', 400, '{ "error": [ "Your request is just terrible." ] }') + @api.get("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }') + @api.post("/bad_request", 400, '{ "error": [ "Your request is just terrible." ] }') end @@ -175,14 +175,14 @@ end shared_examples_for "downloading all the things" do describe "when downloading a simple uncompressed file" 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 "downloads requests correctly" end describe "when downloading a compressed file that should be left compressed" 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) } # its the callers responsibility to disable_gzip when downloading a .gz url @@ -192,57 +192,57 @@ shared_examples_for "downloading all the things" do end describe "when downloading a file that has been compressed by the webserver" do - let(:source) { 'http://localhost:9000/nyan_cat_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_compressed.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading an uncompressed file with a correct content_length" do - let(:source) { 'http://localhost:9000/nyan_cat_content_length.png' } + let(:source) { "http://localhost:9000/nyan_cat_content_length.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading a file that has been compressed by the webserver with a correct content_length" do - let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_content_length_compressed.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading an uncompressed file that is truncated" do - let(:source) { 'http://localhost:9000/nyan_cat_truncated.png' } + let(:source) { "http://localhost:9000/nyan_cat_truncated.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "validates content length and throws an exception" end describe "when downloading a file that has been compressed by the webserver that is truncated" do - let(:source) { 'http://localhost:9000/nyan_cat_truncated_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_truncated_compressed.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "validates content length and throws an exception" end describe "when downloading a file that has transfer encoding set with a bad content length that should be ignored" do - let(:source) { 'http://localhost:9000/nyan_cat_transfer_encoding.png' } + let(:source) { "http://localhost:9000/nyan_cat_transfer_encoding.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } it_behaves_like "downloads requests correctly" end describe "when downloading an endpoint that 403s" do - let(:source) { 'http://localhost:9000/forbidden' } + let(:source) { "http://localhost:9000/forbidden" } it_behaves_like "an endpoint that 403s" end describe "when downloading an endpoint that 403s" do - let(:source) { 'http://localhost:9000/nyan_cat_content_length_compressed.png' } + let(:source) { "http://localhost:9000/nyan_cat_content_length_compressed.png" } let(:expected_content) { binread(nyan_uncompressed_filename) } - let(:source2) { 'http://localhost:9000/forbidden' } + let(:source2) { "http://localhost:9000/forbidden" } it_behaves_like "a 403 after a successful request when reusing the request object" end diff --git a/spec/support/shared/functional/securable_resource.rb b/spec/support/shared/functional/securable_resource.rb index 1e8edec9ae..453f7e2f45 100644 --- a/spec/support/shared/functional/securable_resource.rb +++ b/spec/support/shared/functional/securable_resource.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'etc' -require 'functional/resource/base' +require "etc" +require "functional/resource/base" shared_context "setup correct permissions" do if windows? @@ -38,9 +38,9 @@ shared_context "setup correct permissions" do # Root only context. before :each, :unix_only, :requires_root do if ohai[:platform] == "aix" - File.chown(Etc.getpwnam('guest').uid, 1337, path) + File.chown(Etc.getpwnam("guest").uid, 1337, path) else - File.chown(Etc.getpwnam('nobody').uid, 1337, path) + File.chown(Etc.getpwnam("nobody").uid, 1337, path) end end @@ -155,9 +155,9 @@ shared_examples_for "a securable resource with existing target" do context "on Unix", :unix_only do if ohai[:platform] == "aix" - let(:expected_user_name) { 'guest' } + let(:expected_user_name) { "guest" } else - let(:expected_user_name) { 'nobody' } + let(:expected_user_name) { "nobody" } end let(:expected_uid) { Etc.getpwnam(expected_user_name).uid } let(:desired_gid) { 1337 } @@ -197,7 +197,7 @@ shared_examples_for "a securable resource with existing target" do describe "when setting the permissions from octal given as a String" do before do - @mode_string = '776' + @mode_string = "776" resource.mode @mode_string resource.run_action(:create) end @@ -258,7 +258,7 @@ shared_examples_for "a securable resource with existing target" do describe "when setting group" do before do - resource.group('Administrators') + resource.group("Administrators") resource.run_action(:create) end @@ -273,8 +273,8 @@ shared_examples_for "a securable resource with existing target" do describe "when setting rights and deny_rights" do before do - resource.deny_rights(:modify, 'Guest') - resource.rights(:read, 'Guest') + resource.deny_rights(:modify, "Guest") + resource.rights(:read, "Guest") resource.run_action(:create) end @@ -303,7 +303,7 @@ shared_examples_for "a securable resource without existing target" do end it "sets owner when owner is specified" do - resource.owner 'Guest' + resource.owner "Guest" resource.run_action(:create) expect(descriptor.owner).to eq(SID.Guest) end @@ -322,7 +322,7 @@ shared_examples_for "a securable resource without existing target" do arbitrary_non_default_owner = SID.Guest expect(arbitrary_non_default_owner).not_to eq(SID.default_security_object_owner) - resource.owner 'Guest' # Change to arbitrary_non_default_owner once issue #1508 is fixed + resource.owner "Guest" # Change to arbitrary_non_default_owner once issue #1508 is fixed resource.run_action(:create) expect(descriptor.owner).to eq(arbitrary_non_default_owner) @@ -340,7 +340,7 @@ shared_examples_for "a securable resource without existing target" do end it "sets group when group is specified" do - resource.group 'Everyone' + resource.group "Everyone" resource.run_action(:create) expect(descriptor.group).to eq(SID.Everyone) end @@ -353,7 +353,7 @@ shared_examples_for "a securable resource without existing target" do arbitrary_non_default_group = SID.Everyone expect(arbitrary_non_default_group).not_to eq(SID.default_security_object_group) - resource.group 'Everyone' # Change to arbitrary_non_default_group once issue #1508 is fixed + resource.group "Everyone" # Change to arbitrary_non_default_group once issue #1508 is fixed resource.run_action(:create) expect(descriptor.group).to eq(arbitrary_non_default_group) @@ -366,45 +366,45 @@ shared_examples_for "a securable resource without existing target" do describe "with rights and deny_rights attributes" do it "correctly sets :read rights" do - resource.rights(:read, 'Guest') + resource.rights(:read, "Guest") resource.run_action(:create) expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_read_perms)) end it "correctly sets :read_execute rights" do - resource.rights(:read_execute, 'Guest') + resource.rights(:read_execute, "Guest") resource.run_action(:create) expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_read_execute_perms)) end it "correctly sets :write rights" do - resource.rights(:write, 'Guest') + resource.rights(:write, "Guest") resource.run_action(:create) expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_write_perms)) end it "correctly sets :modify rights" do - resource.rights(:modify, 'Guest') + resource.rights(:modify, "Guest") resource.run_action(:create) expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_modify_perms)) end it "correctly sets :full_control rights" do - resource.rights(:full_control, 'Guest') + resource.rights(:full_control, "Guest") resource.run_action(:create) expect(explicit_aces).to eq(allowed_acl(SID.Guest, expected_full_control_perms)) end it "correctly sets deny_rights" do # deny is an ACE with full rights, but is a deny type ace, not an allow type - resource.deny_rights(:full_control, 'Guest') + resource.deny_rights(:full_control, "Guest") resource.run_action(:create) expect(explicit_aces).to eq(denied_acl(SID.Guest, expected_full_control_perms)) end it "Sets multiple rights" do - resource.rights(:read, 'Everyone') - resource.rights(:modify, 'Guest') + resource.rights(:read, "Everyone") + resource.rights(:modify, "Guest") resource.run_action(:create) expect(explicit_aces).to eq( @@ -414,8 +414,8 @@ shared_examples_for "a securable resource without existing target" do end it "Sets deny_rights ahead of rights" do - resource.rights(:read, 'Everyone') - resource.deny_rights(:modify, 'Guest') + resource.rights(:read, "Everyone") + resource.deny_rights(:modify, "Guest") resource.run_action(:create) expect(explicit_aces).to eq( @@ -425,8 +425,8 @@ shared_examples_for "a securable resource without existing target" do end it "Sets deny_rights ahead of rights when specified in reverse order" do - resource.deny_rights(:modify, 'Guest') - resource.rights(:read, 'Everyone') + resource.deny_rights(:modify, "Guest") + resource.rights(:read, "Everyone") resource.run_action(:create) expect(explicit_aces).to eq( @@ -445,9 +445,9 @@ shared_examples_for "a securable resource without existing target" do it "respects mode in string form as an octal number" do #on windows, mode cannot modify owner and/or group permissons #unless the owner and/or group as appropriate is specified - resource.mode '400' - resource.owner 'Guest' - resource.group 'Everyone' + resource.mode "400" + resource.owner "Guest" + resource.group "Everyone" resource.run_action(:create) expect(explicit_aces).to eq([ ACE.access_allowed(SID.Guest, Security::FILE_GENERIC_READ) ]) @@ -455,7 +455,7 @@ shared_examples_for "a securable resource without existing target" do it "respects mode in numeric form as a ruby-interpreted octal" do resource.mode 0700 - resource.owner 'Guest' + resource.owner "Guest" resource.run_action(:create) expect(explicit_aces).to eq([ ACE.access_allowed(SID.Guest, Security::FILE_GENERIC_READ | Security::FILE_GENERIC_WRITE | Security::FILE_GENERIC_EXECUTE | Security::DELETE) ]) @@ -463,8 +463,8 @@ shared_examples_for "a securable resource without existing target" do it "respects the owner, group and everyone bits of mode" do resource.mode 0754 - resource.owner 'Guest' - resource.group 'Administrators' + resource.owner "Guest" + resource.group "Administrators" resource.run_action(:create) expect(explicit_aces).to eq([ @@ -476,8 +476,8 @@ shared_examples_for "a securable resource without existing target" do it "respects the individual read, write and execute bits of mode" do resource.mode 0421 - resource.owner 'Guest' - resource.group 'Administrators' + resource.owner "Guest" + resource.group "Administrators" resource.run_action(:create) expect(explicit_aces).to eq([ @@ -487,7 +487,7 @@ shared_examples_for "a securable resource without existing target" do ]) end - it 'warns when mode tries to set owner bits but owner is not specified' do + it "warns when mode tries to set owner bits but owner is not specified" do @warn = [] allow(Chef::Log).to receive(:warn) { |msg| @warn << msg } @@ -497,7 +497,7 @@ shared_examples_for "a securable resource without existing target" do expect(@warn.include?("Mode 400 includes bits for the owner, but owner is not specified")).to be_truthy end - it 'warns when mode tries to set group bits but group is not specified' do + it "warns when mode tries to set group bits but group is not specified" do @warn = [] allow(Chef::Log).to receive(:warn) { |msg| @warn << msg } @@ -511,7 +511,7 @@ shared_examples_for "a securable resource without existing target" do it "does not inherit aces if inherits is set to false" do # We need at least one ACE if we're creating a securable without # inheritance - resource.rights(:full_control, 'Administrators') + resource.rights(:full_control, "Administrators") resource.inherits(false) resource.run_action(:create) diff --git a/spec/support/shared/functional/securable_resource_with_reporting.rb b/spec/support/shared/functional/securable_resource_with_reporting.rb index 3176ebba0d..c9b5bae465 100644 --- a/spec/support/shared/functional/securable_resource_with_reporting.rb +++ b/spec/support/shared/functional/securable_resource_with_reporting.rb @@ -1,5 +1,5 @@ -require 'functional/resource/base' +require "functional/resource/base" ALL_EXPANDED_PERMISSIONS = ["generic read", "generic write", @@ -76,9 +76,9 @@ shared_examples_for "a securable resource with reporting" do # TODO/bug: duplicated from the "securable resource" tests if ohai[:platform] == "aix" - let(:expected_user_name) { 'guest' } + let(:expected_user_name) { "guest" } else - let(:expected_user_name) { 'nobody' } + let(:expected_user_name) { "nobody" } end before do @@ -96,9 +96,9 @@ shared_examples_for "a securable resource with reporting" do # TODO: duplicated from "securable resource" if ohai[:platform] == "aix" - let(:expected_user_name) { 'guest' } + let(:expected_user_name) { "guest" } else - let(:expected_user_name) { 'nobody' } + let(:expected_user_name) { "nobody" } end let(:expected_uid) { Etc.getpwnam(expected_user_name).uid } let(:desired_gid) { 1337 } @@ -303,7 +303,7 @@ shared_examples_for "a securable resource with reporting" do context "and owner is specified with a string (username) in new_resource" do # TODO/bug: duplicated from the "securable resource" tests - let(:expected_user_name) { 'Guest' } + let(:expected_user_name) { "Guest" } before do resource.owner(expected_user_name) diff --git a/spec/support/shared/functional/win32_service.rb b/spec/support/shared/functional/win32_service.rb index 8eca7a47fa..5bd2d772cb 100644 --- a/spec/support/shared/functional/win32_service.rb +++ b/spec/support/shared/functional/win32_service.rb @@ -1,5 +1,5 @@ -require 'chef/application/windows_service_manager' +require "chef/application/windows_service_manager" shared_context "using Win32::Service" do # Some helper methods. @@ -46,7 +46,7 @@ shared_context "using Win32::Service" do :service_name => "spec-service", :service_display_name => "Spec Test Service", :service_description => "Service for testing Chef::Application::WindowsServiceManager.", - :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), '../../platforms/win32/spec_service.rb')), + :service_file_path => File.expand_path(File.join(File.dirname(__FILE__), "../../platforms/win32/spec_service.rb")), :delayed_start => true, } } diff --git a/spec/support/shared/functional/windows_script.rb b/spec/support/shared/functional/windows_script.rb index d84c06c86b..423d968ea5 100644 --- a/spec/support/shared/functional/windows_script.rb +++ b/spec/support/shared/functional/windows_script.rb @@ -19,7 +19,7 @@ # Shared context used by both Powershell and Batch script provider # tests. -require 'chef/platform/query_helpers' +require "chef/platform/query_helpers" shared_context Chef::Resource::WindowsScript do before(:all) do @@ -56,11 +56,11 @@ shared_context Chef::Resource::WindowsScript do if resource_architecture expected_architecture = resource_architecture else - expected_architecture = @ohai_reader.data['kernel']['machine'].to_sym + expected_architecture = @ohai_reader.data["kernel"]["machine"].to_sym end end let(:expected_architecture_output) do - expected_architecture == :i386 ? 'X86' : 'AMD64' + expected_architecture == :i386 ? "X86" : "AMD64" end let(:guard_script_suffix) do "guard" @@ -99,7 +99,7 @@ shared_context Chef::Resource::WindowsScript do it "executes a 64-bit guard", :windows64_only do resource.only_if resource_guard_command, :architecture => guard_architecture resource.run_action(:run) - expect(get_guard_process_architecture).to eq('amd64') + expect(get_guard_process_architecture).to eq("amd64") end end @@ -108,7 +108,7 @@ shared_context Chef::Resource::WindowsScript do it "executes a 32-bit guard" do resource.only_if resource_guard_command, :architecture => guard_architecture resource.run_action(:run) - expect(get_guard_process_architecture).to eq('x86') + expect(get_guard_process_architecture).to eq("x86") end end @@ -138,8 +138,8 @@ shared_context Chef::Resource::WindowsScript do before(:each) do @dir = Dir.mktmpdir("Jerry Smith") @original_env = ENV.to_hash.dup - ENV.delete('TMP') - ENV['TMP'] = @dir + ENV.delete("TMP") + ENV["TMP"] = @dir end after(:each) do @@ -183,7 +183,7 @@ shared_context Chef::Resource::WindowsScript do end end - def get_windows_script_output(suffix = '') + def get_windows_script_output(suffix = "") File.read("#{script_output_path}#{suffix}") end @@ -195,7 +195,7 @@ shared_context Chef::Resource::WindowsScript do get_process_architecture(guard_script_suffix) end - def get_process_architecture(suffix = '') + def get_process_architecture(suffix = "") get_windows_script_output(suffix).strip.downcase end diff --git a/spec/support/shared/integration/app_server_support.rb b/spec/support/shared/integration/app_server_support.rb index a133833d3e..da32a477fd 100644 --- a/spec/support/shared/integration/app_server_support.rb +++ b/spec/support/shared/integration/app_server_support.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'rack' -require 'stringio' +require "rack" +require "stringio" module AppServerSupport def start_app_server(app, port) diff --git a/spec/support/shared/integration/integration_helper.rb b/spec/support/shared/integration/integration_helper.rb index 7d62a698d8..a19c9b35e7 100644 --- a/spec/support/shared/integration/integration_helper.rb +++ b/spec/support/shared/integration/integration_helper.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'tmpdir' -require 'fileutils' -require 'chef/config' -require 'chef/json_compat' -require 'chef/server_api' -require 'support/shared/integration/knife_support' -require 'support/shared/integration/app_server_support' -require 'cheffish/rspec/chef_run_support' -require 'spec_helper' +require "tmpdir" +require "fileutils" +require "chef/config" +require "chef/json_compat" +require "chef/server_api" +require "support/shared/integration/knife_support" +require "support/shared/integration/app_server_support" +require "cheffish/rspec/chef_run_support" +require "spec_helper" module Cheffish class BasicChefClient @@ -75,8 +75,8 @@ module IntegrationSupport def file(relative_path, contents) filename = path_to(relative_path) dir = File.dirname(filename) - FileUtils.mkdir_p(dir) unless dir == '.' - File.open(filename, 'w') do |file| + FileUtils.mkdir_p(dir) unless dir == "." + File.open(filename, "w") do |file| raw = case contents when Hash, Array Chef::JSONCompat.to_json_pretty(contents) @@ -90,7 +90,7 @@ module IntegrationSupport def symlink(relative_path, relative_dest) filename = path_to(relative_path) dir = File.dirname(filename) - FileUtils.mkdir_p(dir) unless dir == '.' + FileUtils.mkdir_p(dir) unless dir == "." dest_filename = path_to(relative_dest) File.symlink(dest_filename, filename) end @@ -111,7 +111,7 @@ module IntegrationSupport RSpec.shared_context "with a chef repo" do before :each do raise "Can only create one directory per test" if @repository_dir - @repository_dir = Dir.mktmpdir('chef_repo') + @repository_dir = Dir.mktmpdir("chef_repo") Chef::Config.chef_repo_path = @repository_dir %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) @@ -140,7 +140,7 @@ module IntegrationSupport # Versioned cookbooks - RSpec.shared_context 'with versioned cookbooks', :versioned_cookbooks => true do + RSpec.shared_context "with versioned cookbooks", :versioned_cookbooks => true do before(:each) { Chef::Config[:versioned_cookbooks] = true } after(:each) { Chef::Config.delete(:versioned_cookbooks) } end diff --git a/spec/support/shared/integration/knife_support.rb b/spec/support/shared/integration/knife_support.rb index fb624bca8b..0a8b855222 100644 --- a/spec/support/shared/integration/knife_support.rb +++ b/spec/support/shared/integration/knife_support.rb @@ -15,14 +15,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'chef/config' -require 'chef/knife' -require 'chef/application/knife' -require 'logger' -require 'chef/log' +require "chef/config" +require "chef/knife" +require "chef/application/knife" +require "logger" +require "chef/log" module KnifeSupport - DEBUG = ENV['DEBUG'] + DEBUG = ENV["DEBUG"] def knife(*args, &block) # Allow knife('role from file roles/blah.json') rather than requiring the # arguments to be split like knife('role', 'from', 'file', 'roles/blah.json') @@ -37,7 +37,7 @@ module KnifeSupport Chef::Config[:concurrency] = 1 # Work on machines where we can't access /var - checksums_cache_dir = Dir.mktmpdir('checksums') do |checksums_cache_dir| + checksums_cache_dir = Dir.mktmpdir("checksums") do |checksums_cache_dir| Chef::Config[:cache_options] = { :path => checksums_cache_dir, :skip_expires => true, @@ -146,11 +146,11 @@ module KnifeSupport private def should_result_in(expected) - expected[:stdout] = '' if !expected[:stdout] - expected[:stderr] = '' if !expected[:stderr] + expected[:stdout] = "" if !expected[:stdout] + expected[:stderr] = "" if !expected[:stderr] expected[:exit_code] = 0 if !expected[:exit_code] # TODO make this go away - stderr_actual = @stderr.sub(/^WARNING: No knife configuration file found\n/, '') + stderr_actual = @stderr.sub(/^WARNING: No knife configuration file found\n/, "") if expected[:stderr].is_a?(Regexp) expect(stderr_actual).to match(expected[:stderr]) diff --git a/spec/support/shared/matchers/exit_with_code.rb b/spec/support/shared/matchers/exit_with_code.rb index 32ebf8db15..cf1825f2ed 100644 --- a/spec/support/shared/matchers/exit_with_code.rb +++ b/spec/support/shared/matchers/exit_with_code.rb @@ -1,4 +1,4 @@ -require 'rspec/expectations' +require "rspec/expectations" # Lifted from http://stackoverflow.com/questions/1480537/how-can-i-validate-exits-and-aborts-in-rspec RSpec::Matchers.define :exit_with_code do |exp_code| diff --git a/spec/support/shared/matchers/match_environment_variable.rb b/spec/support/shared/matchers/match_environment_variable.rb index c8c905f44a..393775ea29 100644 --- a/spec/support/shared/matchers/match_environment_variable.rb +++ b/spec/support/shared/matchers/match_environment_variable.rb @@ -1,6 +1,6 @@ -require 'rspec/expectations' -require 'spec/support/platform_helpers' +require "rspec/expectations" +require "spec/support/platform_helpers" RSpec::Matchers.define :match_environment_variable do |varname| match do |actual| diff --git a/spec/support/shared/unit/api_versioning.rb b/spec/support/shared/unit/api_versioning.rb index ccbe95d029..261efc6f52 100644 --- a/spec/support/shared/unit/api_versioning.rb +++ b/spec/support/shared/unit/api_versioning.rb @@ -19,7 +19,7 @@ require "chef/exceptions" shared_examples_for "version handling" do - let(:response_406) { OpenStruct.new(:code => '406') } + let(:response_406) { OpenStruct.new(:code => "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } before do @@ -38,7 +38,7 @@ shared_examples_for "version handling" do end # version handling shared_examples_for "user and client reregister" do - let(:response_406) { OpenStruct.new(:code => '406') } + let(:response_406) { OpenStruct.new(:code => "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } let(:generic_exception) { Exception.new } let(:min_version) { "2" } @@ -55,7 +55,7 @@ shared_examples_for "user and client reregister" do context "when the exception is 406 and returns x-ops-server-api-version header" do before do allow(rest_v0).to receive(:put).and_raise(exception_406) - allow(response_406).to receive(:[]).with('x-ops-server-api-version').and_return(Chef::JSONCompat.to_json(return_hash_406)) + allow(response_406).to receive(:[]).with("x-ops-server-api-version").and_return(Chef::JSONCompat.to_json(return_hash_406)) end it "raises an error about only V0 being supported" do diff --git a/spec/support/shared/unit/execute_resource.rb b/spec/support/shared/unit/execute_resource.rb index 3a88ff8890..e5bcbd5e91 100644 --- a/spec/support/shared/unit/execute_resource.rb +++ b/spec/support/shared/unit/execute_resource.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" shared_examples_for "an execute resource" do diff --git a/spec/support/shared/unit/file_system_support.rb b/spec/support/shared/unit/file_system_support.rb index 3aee46fc7f..f071cffee3 100644 --- a/spec/support/shared/unit/file_system_support.rb +++ b/spec/support/shared/unit/file_system_support.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'chef/chef_fs/file_system' -require 'chef/chef_fs/file_system/memory/memory_root' -require 'chef/chef_fs/file_system/memory/memory_dir' -require 'chef/chef_fs/file_system/memory/memory_file' +require "chef/chef_fs/file_system" +require "chef/chef_fs/file_system/memory/memory_root" +require "chef/chef_fs/file_system/memory/memory_dir" +require "chef/chef_fs/file_system/memory/memory_file" module FileSystemSupport def memory_fs(pretty_name, value, cannot_be_in_regex = nil) @@ -33,7 +33,7 @@ module FileSystemSupport dir end - def memory_fs_value(value, name = '', parent = nil) + def memory_fs_value(value, name = "", parent = nil) if value.is_a?(Hash) dir = Chef::ChefFS::FileSystem::Memory::MemoryDir.new(name, parent) value.each do |key, child| diff --git a/spec/support/shared/unit/platform_introspector.rb b/spec/support/shared/unit/platform_introspector.rb index 52a780eb10..51a2befdbb 100644 --- a/spec/support/shared/unit/platform_introspector.rb +++ b/spec/support/shared/unit/platform_introspector.rb @@ -30,10 +30,10 @@ shared_examples_for "a platform introspector" do @platform_hash["debian"] = {["5", "6"] => "debian-5/6", "default" => "debian"} @platform_hash["default"] = "default" # The following @platform_hash keys are used for testing version constraints - @platform_hash['exact_match'] = { '1.2.3' => 'exact', '>= 1.0' => 'not exact'} - @platform_hash['multiple_matches'] = { '~> 2.3.4' => 'matched ~> 2.3.4', '>= 2.3' => 'matched >=2.3' } - @platform_hash['invalid_cookbook_version'] = {'>= 21' => 'Matches a single number'} - @platform_hash['successful_matches'] = { '< 3.0' => 'matched < 3.0', '>= 3.0' => 'matched >= 3.0' } + @platform_hash["exact_match"] = { "1.2.3" => "exact", ">= 1.0" => "not exact"} + @platform_hash["multiple_matches"] = { "~> 2.3.4" => "matched ~> 2.3.4", ">= 2.3" => "matched >=2.3" } + @platform_hash["invalid_cookbook_version"] = {">= 21" => "Matches a single number"} + @platform_hash["successful_matches"] = { "< 3.0" => "matched < 3.0", ">= 3.0" => "matched >= 3.0" } @platform_family_hash = { "debian" => "debian value", @@ -84,28 +84,28 @@ shared_examples_for "a platform introspector" do expect(platform_introspector.value_for_platform(@platform_hash)).to eq("openbsd") end - it 'returns the exact match' do - node.automatic_attrs[:platform] = 'exact_match' - node.automatic_attrs[:platform_version] = '1.2.3' - expect(platform_introspector.value_for_platform(@platform_hash)).to eq('exact') + it "returns the exact match" do + node.automatic_attrs[:platform] = "exact_match" + node.automatic_attrs[:platform_version] = "1.2.3" + expect(platform_introspector.value_for_platform(@platform_hash)).to eq("exact") end - it 'raises RuntimeError' do - node.automatic_attrs[:platform] = 'multiple_matches' - node.automatic_attrs[:platform_version] = '2.3.4' + it "raises RuntimeError" do + node.automatic_attrs[:platform] = "multiple_matches" + node.automatic_attrs[:platform_version] = "2.3.4" expect {platform_introspector.value_for_platform(@platform_hash)}.to raise_error(RuntimeError) end - it 'should not require .0 to match >= 21.0' do - node.automatic_attrs[:platform] = 'invalid_cookbook_version' - node.automatic_attrs[:platform_version] = '21' - expect(platform_introspector.value_for_platform(@platform_hash)).to eq('Matches a single number') + it "should not require .0 to match >= 21.0" do + node.automatic_attrs[:platform] = "invalid_cookbook_version" + node.automatic_attrs[:platform_version] = "21" + expect(platform_introspector.value_for_platform(@platform_hash)).to eq("Matches a single number") end - it 'should return the value for that match' do - node.automatic_attrs[:platform] = 'successful_matches' - node.automatic_attrs[:platform_version] = '2.9' - expect(platform_introspector.value_for_platform(@platform_hash)).to eq('matched < 3.0') + it "should return the value for that match" do + node.automatic_attrs[:platform] = "successful_matches" + node.automatic_attrs[:platform_version] = "2.9" + expect(platform_introspector.value_for_platform(@platform_hash)).to eq("matched < 3.0") end describe "when platform versions is an array" do @@ -125,17 +125,17 @@ shared_examples_for "a platform introspector" do describe "when checking platform?" do it "returns true if the node is a provided platform and platforms are provided as symbols" do - node.automatic_attrs[:platform] = 'ubuntu' + node.automatic_attrs[:platform] = "ubuntu" expect(platform_introspector.platform?([:redhat, :ubuntu])).to eq(true) end it "returns true if the node is a provided platform and platforms are provided as strings" do - node.automatic_attrs[:platform] = 'ubuntu' + node.automatic_attrs[:platform] = "ubuntu" expect(platform_introspector.platform?(["redhat", "ubuntu"])).to eq(true) end it "returns false if the node is not of the provided platforms" do - node.automatic_attrs[:platform] = 'ubuntu' + node.automatic_attrs[:platform] = "ubuntu" expect(platform_introspector.platform?(:splatlinux)).to eq(false) end end @@ -143,17 +143,17 @@ shared_examples_for "a platform introspector" do describe "when checking platform_family?" do it "returns true if the node is in a provided platform family and families are provided as symbols" do - node.automatic_attrs[:platform_family] = 'debian' + node.automatic_attrs[:platform_family] = "debian" expect(platform_introspector.platform_family?([:rhel, :debian])).to eq(true) end it "returns true if the node is a provided platform and platforms are provided as strings" do - node.automatic_attrs[:platform_family] = 'rhel' + node.automatic_attrs[:platform_family] = "rhel" expect(platform_introspector.platform_family?(["rhel", "debian"])).to eq(true) end it "returns false if the node is not of the provided platforms" do - node.automatic_attrs[:platform_family] = 'suse' + node.automatic_attrs[:platform_family] = "suse" expect(platform_introspector.platform_family?(:splatlinux)).to eq(false) end @@ -176,13 +176,13 @@ shared_examples_for "a platform introspector" do it "returns the correct default for a given platform" do node.automatic_attrs[:platform] = "debian" - node.automatic_attrs[:platform_version] = '9000' + node.automatic_attrs[:platform_version] = "9000" expect(platform_introspector.value_for_platform(@platform_hash)).to eq([ :restart, :reload, :status ]) end it "returns the correct platform+version specific value " do node.automatic_attrs[:platform] = "debian" - node.automatic_attrs[:platform_version] = '4.0' + node.automatic_attrs[:platform_version] = "4.0" expect(platform_introspector.value_for_platform(@platform_hash)).to eq([:restart, :reload]) end end diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index 973cb047f7..82260b07df 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' -require 'tmpdir' +require "spec_helper" +require "tmpdir" if windows? - require 'chef/win32/file' + require "chef/win32/file" end # Filesystem stubs @@ -37,7 +37,7 @@ end # forwards-vs-reverse slashes on windows sucks def windows_path - windows? ? normalized_path.gsub(/\\/, '/') : normalized_path + windows? ? normalized_path.gsub(/\\/, "/") : normalized_path end # this is all getting a bit stupid, CHEF-4802 cut to remove all this @@ -460,7 +460,7 @@ shared_examples_for Chef::Provider::File do before { setup_normal_file } let(:tempfile) { - t = double('Tempfile', :path => "/tmp/foo-bar-baz", :closed? => true) + t = double("Tempfile", :path => "/tmp/foo-bar-baz", :closed? => true) allow(content).to receive(:tempfile).and_return(t) t } @@ -507,7 +507,7 @@ shared_examples_for Chef::Provider::File do before do setup_normal_file provider.load_current_resource - tempfile = double('Tempfile', :path => "/tmp/foo-bar-baz") + tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz") allow(content).to receive(:tempfile).and_return(tempfile) expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(true) expect(tempfile).to receive(:close).once @@ -520,7 +520,7 @@ shared_examples_for Chef::Provider::File do let(:diff_for_reporting) { "+++\n---\n+foo\n-bar\n" } before do allow(provider).to receive(:contents_changed?).and_return(true) - diff = double('Diff', :for_output => ['+++','---','+foo','-bar'], + diff = double("Diff", :for_output => ["+++","---","+foo","-bar"], :for_reporting => diff_for_reporting ) allow(diff).to receive(:diff).with(resource_path, tempfile_path).and_return(true) expect(provider).to receive(:diff).at_least(:once).and_return(diff) @@ -584,13 +584,13 @@ shared_examples_for Chef::Provider::File do end it "raises an exception when the content object returns a tempfile with a nil path" do - tempfile = double('Tempfile', :path => nil) + tempfile = double("Tempfile", :path => nil) expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile) expect{ provider.send(:do_contents_changes) }.to raise_error end it "raises an exception when the content object returns a tempfile that does not exist" do - tempfile = double('Tempfile', :path => "/tmp/foo-bar-baz") + tempfile = double("Tempfile", :path => "/tmp/foo-bar-baz") expect(provider.send(:content)).to receive(:tempfile).at_least(:once).and_return(tempfile) expect(File).to receive(:exists?).with("/tmp/foo-bar-baz").and_return(false) expect{ provider.send(:do_contents_changes) }.to raise_error diff --git a/spec/support/shared/unit/provider/useradd_based_user_provider.rb b/spec/support/shared/unit/provider/useradd_based_user_provider.rb index 60b048975a..07fe1f772b 100644 --- a/spec/support/shared/unit/provider/useradd_based_user_provider.rb +++ b/spec/support/shared/unit/provider/useradd_based_user_provider.rb @@ -60,14 +60,14 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option it "should set the option for #{attribute} if the new resources #{attribute} is not nil" do allow(@new_resource).to receive(attribute).and_return("hola") - expect(provider.universal_options).to eql([option, 'hola']) + expect(provider.universal_options).to eql([option, "hola"]) end it "should set the option for #{attribute} if the new resources #{attribute} is not nil, without homedir management" do allow(@new_resource).to receive(:supports).and_return({:manage_home => false, :non_unique => false}) allow(@new_resource).to receive(attribute).and_return("hola") - expect(provider.universal_options).to eql([option, 'hola']) + expect(provider.universal_options).to eql([option, "hola"]) end it "should set the option for #{attribute} if the new resources #{attribute} is not nil, without homedir management (using real attributes)" do @@ -75,7 +75,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option allow(@new_resource).to receive(:non_unique).and_return(false) allow(@new_resource).to receive(:non_unique).and_return(false) allow(@new_resource).to receive(attribute).and_return("hola") - expect(provider.universal_options).to eql([option, 'hola']) + expect(provider.universal_options).to eql([option, "hola"]) end end @@ -83,7 +83,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option combined_opts = [] supported_useradd_options.sort{ |a,b| a[0] <=> b[0] }.each do |attribute, option| allow(@new_resource).to receive(attribute).and_return("hola") - combined_opts << option << 'hola' + combined_opts << option << "hola" end expect(provider.universal_options).to eql(combined_opts) end @@ -156,17 +156,17 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option provider.current_resource = @current_resource provider.new_resource.manage_home true provider.new_resource.home "/Users/mud" - provider.new_resource.gid '23' + provider.new_resource.gid "23" end it "runs useradd with the computed command options" do command = ["useradd", - "-c", 'Adam Jacob', - "-g", '23' ] - command.concat(["-p", 'abracadabra']) if supported_useradd_options.key?("password") - command.concat([ "-s", '/usr/bin/zsh', - "-u", '1000', - "-d", '/Users/mud', + "-c", "Adam Jacob", + "-g", "23" ] + command.concat(["-p", "abracadabra"]) if supported_useradd_options.key?("password") + command.concat([ "-s", "/usr/bin/zsh", + "-u", "1000", + "-d", "/Users/mud", "-m", "adam" ]) expect(provider).to receive(:shell_out!).with(*command).and_return(true) @@ -183,11 +183,11 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option it "should not include -m or -d in the command options" do command = ["useradd", - "-c", 'Adam Jacob', - "-g", '23'] - command.concat(["-p", 'abracadabra']) if supported_useradd_options.key?("password") - command.concat([ "-s", '/usr/bin/zsh', - "-u", '1000', + "-c", "Adam Jacob", + "-g", "23"] + command.concat(["-p", "abracadabra"]) if supported_useradd_options.key?("password") + command.concat([ "-s", "/usr/bin/zsh", + "-u", "1000", "-r", "adam" ]) expect(provider).to receive(:shell_out!).with(*command).and_return(true) @@ -202,15 +202,15 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option before(:each) do provider.new_resource.manage_home true provider.new_resource.home "/Users/mud" - provider.new_resource.gid '23' + provider.new_resource.gid "23" end # CHEF-3423, -m must come before the username # CHEF-4305, -d must come before -m to support CentOS/RHEL 5 it "runs usermod with the computed command options" do command = ["usermod", - "-g", '23', - "-d", '/Users/mud', + "-g", "23", + "-d", "/Users/mud", "-m", "adam" ] expect(provider).to receive(:shell_out!).with(*command).and_return(true) @@ -220,8 +220,8 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option it "does not set the -r option to usermod" do @new_resource.system(true) command = ["usermod", - "-g", '23', - "-d", '/Users/mud', + "-g", "23", + "-d", "/Users/mud", "-m", "adam" ] expect(provider).to receive(:shell_out!).with(*command).and_return(true) @@ -231,7 +231,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option it "CHEF-3429: does not set -m if we aren't changing the home directory" do expect(provider).to receive(:updating_home?).and_return(false) command = ["usermod", - "-g", '23', + "-g", "23", "adam" ] expect(provider).to receive(:shell_out!).with(*command).and_return(true) provider.manage_user @@ -307,7 +307,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option end it "should raise a Chef::Exceptions::User if passwd -S fails on anything other than redhat/centos" do - @node.automatic_attrs[:platform] = 'ubuntu' + @node.automatic_attrs[:platform] = "ubuntu" expect(provider).to receive(:shell_out!). with("passwd", "-S", @new_resource.username, {:returns=>[0, 1]}). and_return(passwd_s_status) @@ -315,7 +315,7 @@ shared_examples_for "a useradd-based user provider" do |supported_useradd_option expect { provider.check_lock }.to raise_error(Chef::Exceptions::User) end - ['redhat', 'centos'].each do |os| + ["redhat", "centos"].each do |os| it "should not raise a Chef::Exceptions::User if passwd -S exits with 1 on #{os} and the passwd package is version 0.73-1" do @node.automatic_attrs[:platform] = os expect(passwd_s_status).to receive(:exitstatus).and_return(1) diff --git a/spec/support/shared/unit/script_resource.rb b/spec/support/shared/unit/script_resource.rb index 18ee94606e..60967f30a3 100644 --- a/spec/support/shared/unit/script_resource.rb +++ b/spec/support/shared/unit/script_resource.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" shared_examples_for "a script resource" do @@ -49,18 +49,18 @@ shared_examples_for "a script resource" do end it "should raise an exception if users set command on the resource", :chef_gte_13_only do - expect { script_resource.command('foo') }.to raise_error(Chef::Exceptions::Script) + expect { script_resource.command("foo") }.to raise_error(Chef::Exceptions::Script) end it "should not raise an exception if users set command on the resource", :chef_lt_13_only do - expect { script_resource.command('foo') }.not_to raise_error + expect { script_resource.command("foo") }.not_to raise_error end describe "when executing guards" do let(:resource) { resource = script_resource resource.run_context = run_context - resource.code 'echo hi' + resource.code "echo hi" resource } let(:node) { @@ -83,7 +83,7 @@ shared_examples_for "a script resource" do expect_any_instance_of(Chef::Resource::Conditional).not_to receive(:evaluate_block) expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).not_to receive(:evaluate_action) expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:evaluate).and_return(true) - resource.only_if 'echo hi' + resource.only_if "echo hi" expect(resource.should_skip?(:run)).to eq(nil) end @@ -91,7 +91,7 @@ shared_examples_for "a script resource" do expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:evaluate) expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true) resource.guard_interpreter :script - resource.only_if 'echo hi' + resource.only_if "echo hi" expect(resource.should_skip?(:run)).to eq(nil) end end diff --git a/spec/support/shared/unit/windows_script_resource.rb b/spec/support/shared/unit/windows_script_resource.rb index a2fc884ff2..f32cdc6e50 100644 --- a/spec/support/shared/unit/windows_script_resource.rb +++ b/spec/support/shared/unit/windows_script_resource.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'support/shared/unit/execute_resource' -require 'support/shared/unit/script_resource' +require "support/shared/unit/execute_resource" +require "support/shared/unit/script_resource" shared_examples_for "a Windows script resource" do before(:each) do @@ -51,7 +51,7 @@ shared_examples_for "a Windows script resource" do it "should use a resource to evaluate the guard when guard_interpreter is not specified" do expect_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:evaluate_action).and_return(true) expect_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).not_to receive(:evaluate) - @resource.only_if 'echo hi' + @resource.only_if "echo hi" expect(@resource.should_skip?(:run)).to eq(nil) end diff --git a/spec/tiny_server.rb b/spec/tiny_server.rb index ec2a11fe43..8ad9d2695f 100644 --- a/spec/tiny_server.rb +++ b/spec/tiny_server.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'rubygems' -require 'webrick' -require 'webrick/https' -require 'rack' +require "rubygems" +require "webrick" +require "webrick/https" +require "rack" #require 'thin' -require 'singleton' -require 'open-uri' -require 'chef/config' +require "singleton" +require "open-uri" +require "chef/config" module TinyServer @@ -48,9 +48,9 @@ module TinyServer # 5 == debug, 3 == warning LOGGER = WEBrick::Log.new(STDOUT, 3) DEFAULT_OPTIONS = { - :server => 'webrick', + :server => "webrick", :Port => 9000, - :Host => 'localhost', + :Host => "localhost", :environment => :none, :Logger => LOGGER, :AccessLog => [] # Remove this option to enable the access log when debugging. @@ -155,7 +155,7 @@ module TinyServer :available_routes => @routes, :request => env} # Uncomment me for glorious debugging # pp :not_found => debug_info - [404, {'Content-Type' => 'application/json'}, [ Chef::JSONCompat.to_json(debug_info) ]] + [404, {"Content-Type" => "application/json"}, [ Chef::JSONCompat.to_json(debug_info) ]] end end @@ -185,7 +185,7 @@ module TinyServer end class Response - HEADERS = {'Content-Type' => 'application/json'} + HEADERS = {"Content-Type" => "application/json"} def initialize(response_code=200, data=nil, headers=nil, &block) @response_code, @data = response_code, data diff --git a/spec/unit/api_client/registration_spec.rb b/spec/unit/api_client/registration_spec.rb index 6f0f552c4d..bddb33fa0d 100644 --- a/spec/unit/api_client/registration_spec.rb +++ b/spec/unit/api_client/registration_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' -require 'tempfile' +require "spec_helper" +require "tempfile" -require 'chef/api_client/registration' +require "chef/api_client/registration" describe Chef::ApiClient::Registration do @@ -63,7 +63,7 @@ describe Chef::ApiClient::Registration do let(:response_409) { Net::HTTPConflict.new("1.1", "409", "Conflict") } let(:exception_409) { Net::HTTPServerException.new("409 conflict", response_409) } - let(:generated_private_key_pem) { IO.read(File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA)) } + let(:generated_private_key_pem) { IO.read(File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA)) } let(:generated_private_key) { OpenSSL::PKey::RSA.new(generated_private_key_pem) } let(:generated_public_key) { generated_private_key.public_key } @@ -88,7 +88,7 @@ describe Chef::ApiClient::Registration do before do Chef::Config[:validation_client_name] = "test-validator" - Chef::Config[:validation_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA) + Chef::Config[:validation_key] = File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA) allow(OpenSSL::PKey::RSA).to receive(:generate).with(2048).and_return(generated_private_key) end @@ -196,7 +196,7 @@ describe Chef::ApiClient::Registration do describe "when writing the private key to disk" do before do - allow(registration).to receive(:private_key).and_return('--begin rsa key etc--') + allow(registration).to receive(:private_key).and_return("--begin rsa key etc--") end # Permission read via File.stat is busted on windows, though creating the @@ -215,8 +215,8 @@ describe Chef::ApiClient::Registration do expect(IO.read(key_location)).to eq("--begin rsa key etc--") end - context 'when the client key location is a symlink' do - it 'does not follow the symlink', :unix_only do + context "when the client key location is a symlink" do + it "does not follow the symlink", :unix_only do expected_flags = (File::CREAT|File::TRUNC|File::RDWR) if defined?(File::NOFOLLOW) @@ -226,12 +226,12 @@ describe Chef::ApiClient::Registration do expect(registration.file_flags).to eq(expected_flags) end - context 'with follow_client_key_symlink set to true' do + context "with follow_client_key_symlink set to true" do before do Chef::Config[:follow_client_key_symlink] = true end - it 'follows the symlink', :unix_only do + it "follows the symlink", :unix_only do expect(registration.file_flags).to eq(File::CREAT|File::TRUNC|File::RDWR) end end diff --git a/spec/unit/api_client_spec.rb b/spec/unit/api_client_spec.rb index 2a3f63bde5..1f313d7447 100644 --- a/spec/unit/api_client_spec.rb +++ b/spec/unit/api_client_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/api_client' -require 'tempfile' +require "chef/api_client" +require "tempfile" # DEPRECATION NOTE # @@ -226,7 +226,7 @@ describe Chef::ApiClient do @http_client = double("Chef::ServerAPI mock") allow(Chef::ServerAPI).to receive(:new).and_return(@http_client) expect(@http_client).to receive(:get).with("clients/black").and_return(client) - @client = Chef::ApiClient.load(client['name']) + @client = Chef::ApiClient.load(client["name"]) end it "should deserialize to a Chef::ApiClient object" do @@ -258,7 +258,7 @@ describe Chef::ApiClient do describe "with correctly configured API credentials" do before do Chef::Config[:node_name] = "silent-bob" - Chef::Config[:client_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA) + Chef::Config[:client_key] = File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA) end after do diff --git a/spec/unit/api_client_v1_spec.rb b/spec/unit/api_client_v1_spec.rb index ab55a04950..f3df1f44eb 100644 --- a/spec/unit/api_client_v1_spec.rb +++ b/spec/unit/api_client_v1_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/api_client_v1' -require 'tempfile' +require "chef/api_client_v1" +require "tempfile" describe Chef::ApiClientV1 do before(:each) do @@ -254,7 +254,7 @@ describe Chef::ApiClientV1 do @http_client = double("Chef::ServerAPI mock") allow(Chef::ServerAPI).to receive(:new).and_return(@http_client) expect(@http_client).to receive(:get).with("clients/black").and_return(client) - @client = Chef::ApiClientV1.load(client['name']) + @client = Chef::ApiClientV1.load(client["name"]) end it "should deserialize to a Chef::ApiClientV1 object" do @@ -290,7 +290,7 @@ describe Chef::ApiClientV1 do describe "with correctly configured API credentials" do before do Chef::Config[:node_name] = "silent-bob" - Chef::Config[:client_key] = File.expand_path('ssl/private_key.pem', CHEF_SPEC_DATA) + Chef::Config[:client_key] = File.expand_path("ssl/private_key.pem", CHEF_SPEC_DATA) end after do @@ -326,7 +326,7 @@ describe Chef::ApiClientV1 do end describe "Versioned API Interactions" do - let(:response_406) { OpenStruct.new(:code => '406') } + let(:response_406) { OpenStruct.new(:code => "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } let(:payload) { { @@ -338,8 +338,8 @@ describe Chef::ApiClientV1 do before do @client = Chef::ApiClientV1.new - allow(@client).to receive(:chef_rest_v0).and_return(double('chef rest root v0 object')) - allow(@client).to receive(:chef_rest_v1).and_return(double('chef rest root v1 object')) + allow(@client).to receive(:chef_rest_v0).and_return(double("chef rest root v0 object")) + allow(@client).to receive(:chef_rest_v1).and_return(double("chef rest root v1 object")) @client.name "some_name" @client.validator true @client.admin true diff --git a/spec/unit/application/apply_spec.rb b/spec/unit/application/apply_spec.rb index f6cd0bae03..5aad53d209 100644 --- a/spec/unit/application/apply_spec.rb +++ b/spec/unit/application/apply_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" describe Chef::Application::Apply do diff --git a/spec/unit/application/client_spec.rb b/spec/unit/application/client_spec.rb index 727536f1f8..6ff9597b53 100644 --- a/spec/unit/application/client_spec.rb +++ b/spec/unit/application/client_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" describe Chef::Application::Client, "reconfigure" do let(:app) do @@ -42,8 +42,8 @@ describe Chef::Application::Client, "reconfigure" do ARGV.replace(@original_argv) end - describe 'parse cli_arguments' do - it 'should call set_specific_recipes' do + describe "parse cli_arguments" do + it "should call set_specific_recipes" do expect(app).to receive(:set_specific_recipes).and_return(true) app.reconfigure end @@ -310,9 +310,9 @@ describe Chef::Application::Client, "run_application", :unix_only do @client = Chef::Client.new allow(Chef::Client).to receive(:new).and_return(@client) allow(@client).to receive(:run) do - @pipe[1].puts 'started' + @pipe[1].puts "started" sleep 1 - @pipe[1].puts 'finished' + @pipe[1].puts "finished" end end diff --git a/spec/unit/application/knife_spec.rb b/spec/unit/application/knife_spec.rb index 0fb25176f9..163489110f 100644 --- a/spec/unit/application/knife_spec.rb +++ b/spec/unit/application/knife_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" require "#{CHEF_SPEC_DATA}/knife_subcommand/test_yourself" describe Chef::Application::Knife do @@ -84,7 +84,7 @@ describe Chef::Application::Knife do describe "when given a path to the client key" do it "expands a relative path relative to the CWD" do - relative_path = '.chef/client.pem' + relative_path = ".chef/client.pem" allow(Dir).to receive(:pwd).and_return(CHEF_SPEC_DATA) with_argv(*%W{noop knife command -k #{relative_path}}) do expect(@knife).to receive(:exit).with(0) @@ -94,19 +94,19 @@ describe Chef::Application::Knife do end it "expands a ~/home/path to the correct full path" do - home_path = '~/.chef/client.pem' + home_path = "~/.chef/client.pem" with_argv(*%W{noop knife command -k #{home_path}}) do expect(@knife).to receive(:exit).with(0) @knife.run end - expect(Chef::Config[:client_key]).to eq(File.join(ENV['HOME'], '.chef/client.pem').gsub((File::ALT_SEPARATOR || '\\'), File::SEPARATOR)) + expect(Chef::Config[:client_key]).to eq(File.join(ENV["HOME"], ".chef/client.pem").gsub((File::ALT_SEPARATOR || '\\'), File::SEPARATOR)) end it "does not expand a full path" do full_path = if windows? - 'C:/chef/client.pem' + "C:/chef/client.pem" else - '/etc/chef/client.pem' + "/etc/chef/client.pem" end with_argv(*%W{noop knife command -k #{full_path}}) do expect(@knife).to receive(:exit).with(0) @@ -135,7 +135,7 @@ describe Chef::Application::Knife do expect(@knife).to receive(:exit).with(0) @knife.run end - expect(Chef::Config[:environment]).to eq('production') + expect(Chef::Config[:environment]).to eq("production") end it "should load the environment from the CLI options" do @@ -143,7 +143,7 @@ describe Chef::Application::Knife do expect(@knife).to receive(:exit).with(0) @knife.run end - expect(Chef::Config[:environment]).to eq('development') + expect(Chef::Config[:environment]).to eq("development") end it "should override the config file environment with the CLI environment" do @@ -152,7 +152,7 @@ describe Chef::Application::Knife do expect(@knife).to receive(:exit).with(0) @knife.run end - expect(Chef::Config[:environment]).to eq('override') + expect(Chef::Config[:environment]).to eq("override") end it "should override the config file environment with the CLI environment regardless of order" do @@ -161,7 +161,7 @@ describe Chef::Application::Knife do expect(@knife).to receive(:exit).with(0) @knife.run end - expect(Chef::Config[:environment]).to eq('override') + expect(Chef::Config[:environment]).to eq("override") end it "should run a sub command with the applications command line option prototype" do diff --git a/spec/unit/application/solo_spec.rb b/spec/unit/application/solo_spec.rb index 7013bfa0bc..c5b24f7826 100644 --- a/spec/unit/application/solo_spec.rb +++ b/spec/unit/application/solo_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" describe Chef::Application::Solo do @@ -34,7 +34,7 @@ describe Chef::Application::Solo do end describe "configuring the application" do - it 'should call set_specific_recipes' do + it "should call set_specific_recipes" do expect(app).to receive(:set_specific_recipes) app.reconfigure end @@ -106,7 +106,7 @@ Enable chef-client interval runs by setting `:client_fork = true` in your config describe "when the recipe_url configuration option is specified" do let(:tarfile) { StringIO.new("remote_tarball_content") } let(:target_file) { StringIO.new } - let(:shellout) { double(run_command: nil, error!: nil, stdout: '') } + let(:shellout) { double(run_command: nil, error!: nil, stdout: "") } before do Chef::Config[:cookbook_path] = "#{Dir.tmpdir}/chef-solo/cookbooks" diff --git a/spec/unit/application_spec.rb b/spec/unit/application_spec.rb index 20b7e3a506..6a78e5c827 100644 --- a/spec/unit/application_spec.rb +++ b/spec/unit/application_spec.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" describe Chef::Application do before do @@ -51,7 +51,7 @@ describe Chef::Application do @app.reconfigure end - it 'should not receive set_specific_recipes' do + it "should not receive set_specific_recipes" do expect(@app).to_not receive(:set_specific_recipes) @app.reconfigure end @@ -298,18 +298,18 @@ describe Chef::Application do end end - describe 'run_chef_client' do - context 'with an application' do + describe "run_chef_client" do + context "with an application" do let(:app) { Chef::Application.new } - context 'when called with an invalid argument' do + context "when called with an invalid argument" do before do allow(app).to receive(:fork_chef_client).and_return(true) allow(app).to receive(:run_with_graceful_exit_option).and_return(true) end - it 'should raise an argument error detailing the problem' do - specific_recipes_regexp = Regexp.new 'received non-Array like specific_recipes argument' + it "should raise an argument error detailing the problem" do + specific_recipes_regexp = Regexp.new "received non-Array like specific_recipes argument" expect { app.run_chef_client(nil) }.to raise_error(ArgumentError, specific_recipes_regexp) end end @@ -320,7 +320,7 @@ describe Chef::Application do allow(app).to receive(:run_with_graceful_exit_option).and_return(true) end - it 'should be cool' do + it "should be cool" do expect { app.run_chef_client([]) }.not_to raise_error end end diff --git a/spec/unit/audit/audit_event_proxy_spec.rb b/spec/unit/audit/audit_event_proxy_spec.rb index d8c495deeb..a866075f72 100644 --- a/spec/unit/audit/audit_event_proxy_spec.rb +++ b/spec/unit/audit/audit_event_proxy_spec.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/audit/audit_event_proxy' +require "spec_helper" +require "chef/audit/audit_event_proxy" describe Chef::Audit::AuditEventProxy do diff --git a/spec/unit/audit/audit_reporter_spec.rb b/spec/unit/audit/audit_reporter_spec.rb index f9f03c9620..6b0d1566bf 100644 --- a/spec/unit/audit/audit_reporter_spec.rb +++ b/spec/unit/audit/audit_reporter_spec.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Audit::AuditReporter do @@ -75,7 +75,7 @@ describe Chef::Audit::AuditReporter do it "posts audit data to server endpoint" do headers = { - 'X-Ops-Audit-Report-Protocol-Version' => Chef::Audit::AuditReporter::PROTOCOL_VERSION + "X-Ops-Audit-Report-Protocol-Version" => Chef::Audit::AuditReporter::PROTOCOL_VERSION } expect(rest).to receive(:post). diff --git a/spec/unit/audit/control_group_data_spec.rb b/spec/unit/audit/control_group_data_spec.rb index 3705fafbe7..b25d925e12 100644 --- a/spec/unit/audit/control_group_data_spec.rb +++ b/spec/unit/audit/control_group_data_spec.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'spec_helper' -require 'securerandom' +require "spec_helper" +require "securerandom" describe Chef::Audit::AuditData do diff --git a/spec/unit/audit/logger_spec.rb b/spec/unit/audit/logger_spec.rb index 9dd9ce2cd9..1091ed936b 100644 --- a/spec/unit/audit/logger_spec.rb +++ b/spec/unit/audit/logger_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Audit::Logger do @@ -23,19 +23,19 @@ describe Chef::Audit::Logger do Chef::Audit::Logger.instance_variable_set(:@buffer, nil) end - it 'calling puts creates @buffer and adds the message' do + it "calling puts creates @buffer and adds the message" do Chef::Audit::Logger.puts("Output message") expect(Chef::Audit::Logger.read_buffer).to eq("Output message\n") end - it 'calling puts multiple times adds to the message' do + it "calling puts multiple times adds to the message" do Chef::Audit::Logger.puts("Output message") Chef::Audit::Logger.puts("Output message") Chef::Audit::Logger.puts("Output message") expect(Chef::Audit::Logger.read_buffer).to eq("Output message\nOutput message\nOutput message\n") end - it 'calling it before @buffer is set returns an empty string' do + it "calling it before @buffer is set returns an empty string" do expect(Chef::Audit::Logger.read_buffer).to eq("") end diff --git a/spec/unit/audit/rspec_formatter_spec.rb b/spec/unit/audit/rspec_formatter_spec.rb index 471473e387..e4160bb070 100644 --- a/spec/unit/audit/rspec_formatter_spec.rb +++ b/spec/unit/audit/rspec_formatter_spec.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/audit/rspec_formatter' +require "spec_helper" +require "chef/audit/rspec_formatter" describe Chef::Audit::RspecFormatter do let(:formatter) { Chef::Audit::RspecFormatter.new(nil) } diff --git a/spec/unit/audit/runner_spec.rb b/spec/unit/audit/runner_spec.rb index 1de024260f..83cf8e370b 100644 --- a/spec/unit/audit/runner_spec.rb +++ b/spec/unit/audit/runner_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'spec_helper' -require 'rspec/core/sandbox' -require 'chef/audit/runner' -require 'chef/audit/audit_event_proxy' -require 'chef/audit/rspec_formatter' -require 'rspec/support/spec/in_sub_process' -require 'rspec/support/spec/stderr_splitter' +require "spec_helper" +require "rspec/core/sandbox" +require "chef/audit/runner" +require "chef/audit/audit_event_proxy" +require "chef/audit/rspec_formatter" +require "rspec/support/spec/in_sub_process" +require "rspec/support/spec/stderr_splitter" describe Chef::Audit::Runner do @@ -54,7 +54,7 @@ describe Chef::Audit::Runner do context "during #run" do describe "#setup" do - let(:log_location) { File.join(Dir.tmpdir, 'audit_log') } + let(:log_location) { File.join(Dir.tmpdir, "audit_log") } let(:color) { false } before do diff --git a/spec/unit/chef_class_spec.rb b/spec/unit/chef_class_spec.rb index f1b877520c..899ce1c7d2 100644 --- a/spec/unit/chef_class_spec.rb +++ b/spec/unit/chef_class_spec.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe "Chef class" do let(:platform) { "debian" } let(:node) do node = Chef::Node.new - node.automatic['platform'] = platform + node.automatic["platform"] = platform node end @@ -86,7 +86,7 @@ describe "Chef class" do end context '#event_handler' do - it 'adds a new handler' do + it "adds a new handler" do x = 1 Chef.event_handler do on :converge_start do @@ -98,7 +98,7 @@ describe "Chef class" do expect(x).to eq(2) end - it 'raise error if unknown event type is passed' do + it "raise error if unknown event type is passed" do expect do Chef.event_handler do on :yolo do diff --git a/spec/unit/chef_fs/config_spec.rb b/spec/unit/chef_fs/config_spec.rb index 145cdf2d12..cac4d7d9a2 100644 --- a/spec/unit/chef_fs/config_spec.rb +++ b/spec/unit/chef_fs/config_spec.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/exceptions' -require 'lib/chef/chef_fs/config.rb' +require "spec_helper" +require "chef/exceptions" +require "lib/chef/chef_fs/config.rb" describe Chef::ChefFS::Config do describe "initialize" do it "warns when hosted setups use 'everything'" do base_config = Hash.new() - base_config[:repo_mode] = 'everything' - base_config[:chef_server_url] = 'http://foo.com/organizations/fake_org/' + base_config[:repo_mode] = "everything" + base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/" ui = double("ui") expect(ui).to receive(:warn) @@ -35,8 +35,8 @@ describe Chef::ChefFS::Config do it "doesn't warn when hosted setups use 'hosted_everything'" do base_config = Hash.new() - base_config[:repo_mode] = 'hosted_everything' - base_config[:chef_server_url] = 'http://foo.com/organizations/fake_org/' + base_config[:repo_mode] = "hosted_everything" + base_config[:chef_server_url] = "http://foo.com/organizations/fake_org/" ui = double("ui") expect(ui).to receive(:warn).exactly(0).times @@ -46,8 +46,8 @@ describe Chef::ChefFS::Config do it "doesn't warn when non-hosted setups use 'everything'" do base_config = Hash.new() - base_config[:repo_mode] = 'everything' - base_config[:chef_server_url] = 'http://foo.com/' + base_config[:repo_mode] = "everything" + base_config[:chef_server_url] = "http://foo.com/" ui = double("ui") expect(ui).to receive(:warn).exactly(0).times diff --git a/spec/unit/chef_fs/data_handler/group_handler_spec.rb b/spec/unit/chef_fs/data_handler/group_handler_spec.rb index 6e71fa3b10..7cbd0e4c22 100644 --- a/spec/unit/chef_fs/data_handler/group_handler_spec.rb +++ b/spec/unit/chef_fs/data_handler/group_handler_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'lib/chef/chef_fs/data_handler/group_data_handler' +require "spec_helper" +require "lib/chef/chef_fs/data_handler/group_data_handler" class TestEntry < Mash attr_accessor :name, :org @@ -31,32 +31,32 @@ end describe Chef::ChefFS::DataHandler::GroupDataHandler do describe '#normalize_for_post' do let(:entry) do - TestEntry.new('workers.json', 'hive') + TestEntry.new("workers.json", "hive") end let(:group) do - { 'name' => 'worker_bees', - 'clients' => %w(honey sting), - 'users' => %w(fizz buzz), - 'actors' => %w(honey), + { "name" => "worker_bees", + "clients" => %w(honey sting), + "users" => %w(fizz buzz), + "actors" => %w(honey), } end let(:normalized) do - { 'actors' => - { 'users' => %w(fizz buzz), - 'clients'=> %w(honey sting), - 'groups'=> [], + { "actors" => + { "users" => %w(fizz buzz), + "clients"=> %w(honey sting), + "groups"=> [], }, - 'groupname' => 'workers', - 'name' => 'worker_bees', - 'orgname' => 'hive', + "groupname" => "workers", + "name" => "worker_bees", + "orgname" => "hive", } end let(:handler) { described_class.new } - it 'normalizes the users, clients and groups into actors' do + it "normalizes the users, clients and groups into actors" do expect(handler.normalize_for_post(group, entry)).to eq(normalized) end end diff --git a/spec/unit/chef_fs/diff_spec.rb b/spec/unit/chef_fs/diff_spec.rb index 284a7a5ab7..e2f9a9169d 100644 --- a/spec/unit/chef_fs/diff_spec.rb +++ b/spec/unit/chef_fs/diff_spec.rb @@ -16,24 +16,24 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/chef_fs/file_pattern' -require 'chef/chef_fs/command_line' +require "spec_helper" +require "chef/chef_fs/file_pattern" +require "chef/chef_fs/command_line" # Removes the date stamp from the diff and replaces it with ' DATE' # example match: "/dev/null\t2012-10-16 16:15:54.000000000 +0000" # windows match: "--- /dev/null\tTue Oct 16 18:04:34 2012" def remove_os_differences(diff) diff = diff.gsub(/([+-]{3}.*)\t.*/, '\1 DATE') - diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, 'CONTEXT_LINE_NUMBERS') + diff.gsub(/^@@ -\d(,\d)? \+\d(,\d)? @@/, "CONTEXT_LINE_NUMBERS") end -describe 'diff', :uses_diff => true do +describe "diff", :uses_diff => true do include FileSystemSupport - context 'with two filesystems with all types of difference' do + context "with two filesystems with all types of difference" do let(:a) { - memory_fs('a', { + memory_fs("a", { :both_dirs => { :sub_both_dirs => { :subsub => nil }, :sub_both_files => nil, @@ -60,7 +60,7 @@ describe 'diff', :uses_diff => true do }, /cannot_be_in_a/) } let(:b) { - memory_fs('b', { + memory_fs("b", { :both_dirs => { :sub_both_dirs => { :subsub => nil }, :sub_both_files => nil, @@ -86,9 +86,9 @@ describe 'diff', :uses_diff => true do :file_in_a_dir_in_b => {}, }, /cannot_be_in_b/) } - it 'Chef::ChefFS::CommandLine.diff_print(/)' do + it "Chef::ChefFS::CommandLine.diff_print(/)" do results = [] - Chef::ChefFS::CommandLine.diff_print(pattern('/'), a, b, nil, nil) do |diff| + Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, nil, nil) do |diff| results << remove_os_differences(diff) end expect(results).to match_array([ @@ -110,17 +110,17 @@ deleted file +++ /dev/null DATE CONTEXT_LINE_NUMBERS -subsub -','Only in a/both_dirs: sub_a_only_dir -','diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file +',"Only in a/both_dirs: sub_a_only_dir +",'diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file deleted file --- a/both_dirs/sub_a_only_file DATE +++ /dev/null DATE CONTEXT_LINE_NUMBERS -sub_a_only_file -','File a/both_dirs/sub_dir_in_a_file_in_b is a directory while file b/both_dirs/sub_dir_in_a_file_in_b is a regular file -','File a/both_dirs/sub_file_in_a_dir_in_b is a regular file while file b/both_dirs/sub_file_in_a_dir_in_b is a directory -','Only in b/both_dirs: sub_b_only_dir -','diff --knife a/both_dirs/sub_b_only_file b/both_dirs/sub_b_only_file +',"File a/both_dirs/sub_dir_in_a_file_in_b is a directory while file b/both_dirs/sub_dir_in_a_file_in_b is a regular file +","File a/both_dirs/sub_file_in_a_dir_in_b is a regular file while file b/both_dirs/sub_file_in_a_dir_in_b is a directory +","Only in b/both_dirs: sub_b_only_dir +",'diff --knife a/both_dirs/sub_b_only_file b/both_dirs/sub_b_only_file new file --- /dev/null DATE +++ b/both_dirs/sub_b_only_file DATE @@ -144,17 +144,17 @@ deleted file +++ /dev/null DATE CONTEXT_LINE_NUMBERS -subsub -','Only in a: a_only_dir -','diff --knife a/a_only_file b/a_only_file +',"Only in a: a_only_dir +",'diff --knife a/a_only_file b/a_only_file deleted file --- a/a_only_file DATE +++ /dev/null DATE CONTEXT_LINE_NUMBERS -a_only_file -','File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file -','File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory -','Only in b: b_only_dir -','diff --knife a/b_only_file b/b_only_file +',"File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file +","File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory +","Only in b: b_only_dir +",'diff --knife a/b_only_file b/b_only_file new file --- /dev/null DATE +++ b/b_only_file DATE @@ -162,9 +162,9 @@ CONTEXT_LINE_NUMBERS +b_only_file ' ]) end - it 'Chef::ChefFS::CommandLine.diff_print(/both_dirs)' do + it "Chef::ChefFS::CommandLine.diff_print(/both_dirs)" do results = [] - Chef::ChefFS::CommandLine.diff_print(pattern('/both_dirs'), a, b, nil, nil) do |diff| + Chef::ChefFS::CommandLine.diff_print(pattern("/both_dirs"), a, b, nil, nil) do |diff| results << remove_os_differences(diff) end expect(results).to match_array([ @@ -186,17 +186,17 @@ deleted file +++ /dev/null DATE CONTEXT_LINE_NUMBERS -subsub -','Only in a/both_dirs: sub_a_only_dir -','diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file +',"Only in a/both_dirs: sub_a_only_dir +",'diff --knife a/both_dirs/sub_a_only_file b/both_dirs/sub_a_only_file deleted file --- a/both_dirs/sub_a_only_file DATE +++ /dev/null DATE CONTEXT_LINE_NUMBERS -sub_a_only_file -','File a/both_dirs/sub_dir_in_a_file_in_b is a directory while file b/both_dirs/sub_dir_in_a_file_in_b is a regular file -','File a/both_dirs/sub_file_in_a_dir_in_b is a regular file while file b/both_dirs/sub_file_in_a_dir_in_b is a directory -','Only in b/both_dirs: sub_b_only_dir -','diff --knife a/both_dirs/sub_b_only_file b/both_dirs/sub_b_only_file +',"File a/both_dirs/sub_dir_in_a_file_in_b is a directory while file b/both_dirs/sub_dir_in_a_file_in_b is a regular file +","File a/both_dirs/sub_file_in_a_dir_in_b is a regular file while file b/both_dirs/sub_file_in_a_dir_in_b is a directory +","Only in b/both_dirs: sub_b_only_dir +",'diff --knife a/both_dirs/sub_b_only_file b/both_dirs/sub_b_only_file new file --- /dev/null DATE +++ b/both_dirs/sub_b_only_file DATE @@ -204,33 +204,33 @@ CONTEXT_LINE_NUMBERS +sub_b_only_file ' ]) end - it 'Chef::ChefFS::CommandLine.diff_print(/) with depth 1' do + it "Chef::ChefFS::CommandLine.diff_print(/) with depth 1" do results = [] - Chef::ChefFS::CommandLine.diff_print(pattern('/'), a, b, 1, nil) do |diff| + Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, 1, nil) do |diff| results << remove_os_differences(diff) end expect(results).to match_array([ -'Common subdirectories: b/both_dirs -','diff --knife a/both_files_different b/both_files_different +"Common subdirectories: b/both_dirs +",'diff --knife a/both_files_different b/both_files_different --- a/both_files_different DATE +++ b/both_files_different DATE CONTEXT_LINE_NUMBERS -a +b -','Common subdirectories: b/both_dirs_empty -','Common subdirectories: b/dirs_empty_in_b_filled_in_a -','Common subdirectories: b/dirs_empty_in_a_filled_in_b -','Only in a: a_only_dir -','diff --knife a/a_only_file b/a_only_file +',"Common subdirectories: b/both_dirs_empty +","Common subdirectories: b/dirs_empty_in_b_filled_in_a +","Common subdirectories: b/dirs_empty_in_a_filled_in_b +","Only in a: a_only_dir +",'diff --knife a/a_only_file b/a_only_file deleted file --- a/a_only_file DATE +++ /dev/null DATE CONTEXT_LINE_NUMBERS -a_only_file -','File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file -','File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory -','Only in b: b_only_dir -','diff --knife a/b_only_file b/b_only_file +',"File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file +","File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory +","Only in b: b_only_dir +",'diff --knife a/b_only_file b/b_only_file new file --- /dev/null DATE +++ b/b_only_file DATE @@ -238,33 +238,33 @@ CONTEXT_LINE_NUMBERS +b_only_file ' ]) end - it 'Chef::ChefFS::CommandLine.diff_print(/*_*) with depth 0' do + it "Chef::ChefFS::CommandLine.diff_print(/*_*) with depth 0" do results = [] - Chef::ChefFS::CommandLine.diff_print(pattern('/*_*'), a, b, 0, nil) do |diff| + Chef::ChefFS::CommandLine.diff_print(pattern("/*_*"), a, b, 0, nil) do |diff| results << remove_os_differences(diff) end expect(results).to match_array([ -'Common subdirectories: b/both_dirs -','diff --knife a/both_files_different b/both_files_different +"Common subdirectories: b/both_dirs +",'diff --knife a/both_files_different b/both_files_different --- a/both_files_different DATE +++ b/both_files_different DATE CONTEXT_LINE_NUMBERS -a +b -','Common subdirectories: b/both_dirs_empty -','Common subdirectories: b/dirs_empty_in_b_filled_in_a -','Common subdirectories: b/dirs_empty_in_a_filled_in_b -','Only in a: a_only_dir -','diff --knife a/a_only_file b/a_only_file +',"Common subdirectories: b/both_dirs_empty +","Common subdirectories: b/dirs_empty_in_b_filled_in_a +","Common subdirectories: b/dirs_empty_in_a_filled_in_b +","Only in a: a_only_dir +",'diff --knife a/a_only_file b/a_only_file deleted file --- a/a_only_file DATE +++ /dev/null DATE CONTEXT_LINE_NUMBERS -a_only_file -','File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file -','File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory -','Only in b: b_only_dir -','diff --knife a/b_only_file b/b_only_file +',"File a/dir_in_a_file_in_b is a directory while file b/dir_in_a_file_in_b is a regular file +","File a/file_in_a_dir_in_b is a regular file while file b/file_in_a_dir_in_b is a directory +","Only in b: b_only_dir +",'diff --knife a/b_only_file b/b_only_file new file --- /dev/null DATE +++ b/b_only_file DATE @@ -272,9 +272,9 @@ CONTEXT_LINE_NUMBERS +b_only_file ' ]) end - it 'Chef::ChefFS::CommandLine.diff_print(/) in name-only mode' do + it "Chef::ChefFS::CommandLine.diff_print(/) in name-only mode" do results = [] - Chef::ChefFS::CommandLine.diff_print(pattern('/'), a, b, nil, :name_only) do |diff| + Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, nil, :name_only) do |diff| results << remove_os_differences(diff) end expect(results).to match_array([ @@ -298,9 +298,9 @@ CONTEXT_LINE_NUMBERS "b/file_in_a_dir_in_b\n", ]) end - it 'Chef::ChefFS::CommandLine.diff_print(/) in name-status mode' do + it "Chef::ChefFS::CommandLine.diff_print(/) in name-status mode" do results = [] - Chef::ChefFS::CommandLine.diff_print(pattern('/'), a, b, nil, :name_status) do |diff| + Chef::ChefFS::CommandLine.diff_print(pattern("/"), a, b, nil, :name_status) do |diff| results << remove_os_differences(diff) end expect(results).to match_array([ diff --git a/spec/unit/chef_fs/file_pattern_spec.rb b/spec/unit/chef_fs/file_pattern_spec.rb index ed5f314605..91970cd23c 100644 --- a/spec/unit/chef_fs/file_pattern_spec.rb +++ b/spec/unit/chef_fs/file_pattern_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/chef_fs/file_pattern' +require "spec_helper" +require "chef/chef_fs/file_pattern" describe Chef::ChefFS::FilePattern do def p(str) @@ -26,455 +26,455 @@ describe Chef::ChefFS::FilePattern do # Different kinds of patterns context 'with empty pattern ""' do - let(:pattern) { Chef::ChefFS::FilePattern.new('') } - it 'match?' do - expect(pattern.match?('')).to be_truthy - expect(pattern.match?('/')).to be_falsey - expect(pattern.match?('a')).to be_falsey - expect(pattern.match?('a/b')).to be_falsey + let(:pattern) { Chef::ChefFS::FilePattern.new("") } + it "match?" do + expect(pattern.match?("")).to be_truthy + expect(pattern.match?("/")).to be_falsey + expect(pattern.match?("a")).to be_falsey + expect(pattern.match?("a/b")).to be_falsey end - it 'exact_path' do - expect(pattern.exact_path).to eq('') + it "exact_path" do + expect(pattern.exact_path).to eq("") end - it 'could_match_children?' do - expect(pattern.could_match_children?('')).to be_falsey - expect(pattern.could_match_children?('a/b')).to be_falsey + it "could_match_children?" do + expect(pattern.could_match_children?("")).to be_falsey + expect(pattern.could_match_children?("a/b")).to be_falsey end end context 'with root pattern "/"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/') } - it 'match?' do - expect(pattern.match?('/')).to be_truthy - expect(pattern.match?('')).to be_falsey - expect(pattern.match?('a')).to be_falsey - expect(pattern.match?('/a')).to be_falsey - end - it 'exact_path' do - expect(pattern.exact_path).to eq('/') - end - it 'could_match_children?' do - expect(pattern.could_match_children?('')).to be_falsey - expect(pattern.could_match_children?('/')).to be_falsey - expect(pattern.could_match_children?('a')).to be_falsey - expect(pattern.could_match_children?('a/b')).to be_falsey - expect(pattern.could_match_children?('/a')).to be_falsey + let(:pattern) { Chef::ChefFS::FilePattern.new("/") } + it "match?" do + expect(pattern.match?("/")).to be_truthy + expect(pattern.match?("")).to be_falsey + expect(pattern.match?("a")).to be_falsey + expect(pattern.match?("/a")).to be_falsey + end + it "exact_path" do + expect(pattern.exact_path).to eq("/") + end + it "could_match_children?" do + expect(pattern.could_match_children?("")).to be_falsey + expect(pattern.could_match_children?("/")).to be_falsey + expect(pattern.could_match_children?("a")).to be_falsey + expect(pattern.could_match_children?("a/b")).to be_falsey + expect(pattern.could_match_children?("/a")).to be_falsey end end context 'with simple pattern "abc"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('abc') } - it 'match?' do - expect(pattern.match?('abc')).to be_truthy - expect(pattern.match?('a')).to be_falsey - expect(pattern.match?('abcd')).to be_falsey - expect(pattern.match?('/abc')).to be_falsey - expect(pattern.match?('')).to be_falsey - expect(pattern.match?('/')).to be_falsey - end - it 'exact_path' do - expect(pattern.exact_path).to eq('abc') - end - it 'could_match_children?' do - expect(pattern.could_match_children?('')).to be_falsey - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/abc')).to be_falsey + let(:pattern) { Chef::ChefFS::FilePattern.new("abc") } + it "match?" do + expect(pattern.match?("abc")).to be_truthy + expect(pattern.match?("a")).to be_falsey + expect(pattern.match?("abcd")).to be_falsey + expect(pattern.match?("/abc")).to be_falsey + expect(pattern.match?("")).to be_falsey + expect(pattern.match?("/")).to be_falsey + end + it "exact_path" do + expect(pattern.exact_path).to eq("abc") + end + it "could_match_children?" do + expect(pattern.could_match_children?("")).to be_falsey + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/abc")).to be_falsey end end context 'with simple pattern "/abc"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc') } - it 'match?' do - expect(pattern.match?('/abc')).to be_truthy - expect(pattern.match?('abc')).to be_falsey - expect(pattern.match?('a')).to be_falsey - expect(pattern.match?('abcd')).to be_falsey - expect(pattern.match?('')).to be_falsey - expect(pattern.match?('/')).to be_falsey - end - it 'exact_path' do - expect(pattern.exact_path).to eq('/abc') - end - it 'could_match_children?' do - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/abc')).to be_falsey - expect(pattern.could_match_children?('/')).to be_truthy - expect(pattern.could_match_children?('')).to be_falsey - end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq('abc') + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc") } + it "match?" do + expect(pattern.match?("/abc")).to be_truthy + expect(pattern.match?("abc")).to be_falsey + expect(pattern.match?("a")).to be_falsey + expect(pattern.match?("abcd")).to be_falsey + expect(pattern.match?("")).to be_falsey + expect(pattern.match?("/")).to be_falsey + end + it "exact_path" do + expect(pattern.exact_path).to eq("/abc") + end + it "could_match_children?" do + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/abc")).to be_falsey + expect(pattern.could_match_children?("/")).to be_truthy + expect(pattern.could_match_children?("")).to be_falsey + end + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq("abc") end end context 'with simple pattern "abc/def/ghi"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('abc/def/ghi') } - it 'match?' do - expect(pattern.match?('abc/def/ghi')).to be_truthy - expect(pattern.match?('/abc/def/ghi')).to be_falsey - expect(pattern.match?('abc')).to be_falsey - expect(pattern.match?('abc/def')).to be_falsey - end - it 'exact_path' do - expect(pattern.exact_path).to eq('abc/def/ghi') - end - it 'could_match_children?' do - expect(pattern.could_match_children?('abc')).to be_truthy - expect(pattern.could_match_children?('xyz')).to be_falsey - expect(pattern.could_match_children?('/abc')).to be_falsey - expect(pattern.could_match_children?('abc/def')).to be_truthy - expect(pattern.could_match_children?('abc/xyz')).to be_falsey - expect(pattern.could_match_children?('abc/def/ghi')).to be_falsey - end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('abc')).to eq('def') - expect(pattern.exact_child_name_under('abc/def')).to eq('ghi') + let(:pattern) { Chef::ChefFS::FilePattern.new("abc/def/ghi") } + it "match?" do + expect(pattern.match?("abc/def/ghi")).to be_truthy + expect(pattern.match?("/abc/def/ghi")).to be_falsey + expect(pattern.match?("abc")).to be_falsey + expect(pattern.match?("abc/def")).to be_falsey + end + it "exact_path" do + expect(pattern.exact_path).to eq("abc/def/ghi") + end + it "could_match_children?" do + expect(pattern.could_match_children?("abc")).to be_truthy + expect(pattern.could_match_children?("xyz")).to be_falsey + expect(pattern.could_match_children?("/abc")).to be_falsey + expect(pattern.could_match_children?("abc/def")).to be_truthy + expect(pattern.could_match_children?("abc/xyz")).to be_falsey + expect(pattern.could_match_children?("abc/def/ghi")).to be_falsey + end + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("abc")).to eq("def") + expect(pattern.exact_child_name_under("abc/def")).to eq("ghi") end end context 'with simple pattern "/abc/def/ghi"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/def/ghi') } - it 'match?' do - expect(pattern.match?('/abc/def/ghi')).to be_truthy - expect(pattern.match?('abc/def/ghi')).to be_falsey - expect(pattern.match?('/abc')).to be_falsey - expect(pattern.match?('/abc/def')).to be_falsey - end - it 'exact_path' do - expect(pattern.exact_path).to eq('/abc/def/ghi') - end - it 'could_match_children?' do - expect(pattern.could_match_children?('/abc')).to be_truthy - expect(pattern.could_match_children?('/xyz')).to be_falsey - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/abc/def')).to be_truthy - expect(pattern.could_match_children?('/abc/xyz')).to be_falsey - expect(pattern.could_match_children?('/abc/def/ghi')).to be_falsey - end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq('abc') - expect(pattern.exact_child_name_under('/abc')).to eq('def') - expect(pattern.exact_child_name_under('/abc/def')).to eq('ghi') + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/def/ghi") } + it "match?" do + expect(pattern.match?("/abc/def/ghi")).to be_truthy + expect(pattern.match?("abc/def/ghi")).to be_falsey + expect(pattern.match?("/abc")).to be_falsey + expect(pattern.match?("/abc/def")).to be_falsey + end + it "exact_path" do + expect(pattern.exact_path).to eq("/abc/def/ghi") + end + it "could_match_children?" do + expect(pattern.could_match_children?("/abc")).to be_truthy + expect(pattern.could_match_children?("/xyz")).to be_falsey + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/abc/def")).to be_truthy + expect(pattern.could_match_children?("/abc/xyz")).to be_falsey + expect(pattern.could_match_children?("/abc/def/ghi")).to be_falsey + end + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq("abc") + expect(pattern.exact_child_name_under("/abc")).to eq("def") + expect(pattern.exact_child_name_under("/abc/def")).to eq("ghi") end end context 'with simple pattern "a\*\b"', :skip => (Chef::Platform.windows?) do let(:pattern) { Chef::ChefFS::FilePattern.new('a\*\b') } - it 'match?' do - expect(pattern.match?('a*b')).to be_truthy - expect(pattern.match?('ab')).to be_falsey - expect(pattern.match?('acb')).to be_falsey - expect(pattern.match?('ab')).to be_falsey + it "match?" do + expect(pattern.match?("a*b")).to be_truthy + expect(pattern.match?("ab")).to be_falsey + expect(pattern.match?("acb")).to be_falsey + expect(pattern.match?("ab")).to be_falsey end - it 'exact_path' do - expect(pattern.exact_path).to eq('a*b') + it "exact_path" do + expect(pattern.exact_path).to eq("a*b") end - it 'could_match_children?' do - expect(pattern.could_match_children?('a/*b')).to be_falsey + it "could_match_children?" do + expect(pattern.could_match_children?("a/*b")).to be_falsey end end context 'with star pattern "/abc/*/ghi"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/*/ghi') } - it 'match?' do - expect(pattern.match?('/abc/def/ghi')).to be_truthy - expect(pattern.match?('/abc/ghi')).to be_falsey + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/*/ghi") } + it "match?" do + expect(pattern.match?("/abc/def/ghi")).to be_truthy + expect(pattern.match?("/abc/ghi")).to be_falsey end - it 'exact_path' do + it "exact_path" do expect(pattern.exact_path).to be_nil end - it 'could_match_children?' do - expect(pattern.could_match_children?('/abc')).to be_truthy - expect(pattern.could_match_children?('/xyz')).to be_falsey - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/abc/def')).to be_truthy - expect(pattern.could_match_children?('/abc/xyz')).to be_truthy - expect(pattern.could_match_children?('/abc/def/ghi')).to be_falsey + it "could_match_children?" do + expect(pattern.could_match_children?("/abc")).to be_truthy + expect(pattern.could_match_children?("/xyz")).to be_falsey + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/abc/def")).to be_truthy + expect(pattern.could_match_children?("/abc/xyz")).to be_truthy + expect(pattern.could_match_children?("/abc/def/ghi")).to be_falsey end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq('abc') - expect(pattern.exact_child_name_under('/abc')).to eq(nil) - expect(pattern.exact_child_name_under('/abc/def')).to eq('ghi') + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq("abc") + expect(pattern.exact_child_name_under("/abc")).to eq(nil) + expect(pattern.exact_child_name_under("/abc/def")).to eq("ghi") end end context 'with star pattern "/abc/d*f/ghi"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/d*f/ghi') } - it 'match?' do - expect(pattern.match?('/abc/def/ghi')).to be_truthy - expect(pattern.match?('/abc/dxf/ghi')).to be_truthy - expect(pattern.match?('/abc/df/ghi')).to be_truthy - expect(pattern.match?('/abc/dxyzf/ghi')).to be_truthy - expect(pattern.match?('/abc/d/ghi')).to be_falsey - expect(pattern.match?('/abc/f/ghi')).to be_falsey - expect(pattern.match?('/abc/ghi')).to be_falsey - expect(pattern.match?('/abc/xyz/ghi')).to be_falsey - end - it 'exact_path' do + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d*f/ghi") } + it "match?" do + expect(pattern.match?("/abc/def/ghi")).to be_truthy + expect(pattern.match?("/abc/dxf/ghi")).to be_truthy + expect(pattern.match?("/abc/df/ghi")).to be_truthy + expect(pattern.match?("/abc/dxyzf/ghi")).to be_truthy + expect(pattern.match?("/abc/d/ghi")).to be_falsey + expect(pattern.match?("/abc/f/ghi")).to be_falsey + expect(pattern.match?("/abc/ghi")).to be_falsey + expect(pattern.match?("/abc/xyz/ghi")).to be_falsey + end + it "exact_path" do expect(pattern.exact_path).to be_nil end - it 'could_match_children?' do - expect(pattern.could_match_children?('/abc')).to be_truthy - expect(pattern.could_match_children?('/xyz')).to be_falsey - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/abc/def')).to be_truthy - expect(pattern.could_match_children?('/abc/xyz')).to be_falsey - expect(pattern.could_match_children?('/abc/dxyzf')).to be_truthy - expect(pattern.could_match_children?('/abc/df')).to be_truthy - expect(pattern.could_match_children?('/abc/d')).to be_falsey - expect(pattern.could_match_children?('/abc/f')).to be_falsey - expect(pattern.could_match_children?('/abc/def/ghi')).to be_falsey - end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq('abc') - expect(pattern.exact_child_name_under('/abc')).to eq(nil) - expect(pattern.exact_child_name_under('/abc/def')).to eq('ghi') + it "could_match_children?" do + expect(pattern.could_match_children?("/abc")).to be_truthy + expect(pattern.could_match_children?("/xyz")).to be_falsey + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/abc/def")).to be_truthy + expect(pattern.could_match_children?("/abc/xyz")).to be_falsey + expect(pattern.could_match_children?("/abc/dxyzf")).to be_truthy + expect(pattern.could_match_children?("/abc/df")).to be_truthy + expect(pattern.could_match_children?("/abc/d")).to be_falsey + expect(pattern.could_match_children?("/abc/f")).to be_falsey + expect(pattern.could_match_children?("/abc/def/ghi")).to be_falsey + end + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq("abc") + expect(pattern.exact_child_name_under("/abc")).to eq(nil) + expect(pattern.exact_child_name_under("/abc/def")).to eq("ghi") end end context 'with star pattern "/abc/d??f/ghi"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/d??f/ghi') } - it 'match?' do - expect(pattern.match?('/abc/deef/ghi')).to be_truthy - expect(pattern.match?('/abc/deeef/ghi')).to be_falsey - expect(pattern.match?('/abc/def/ghi')).to be_falsey - expect(pattern.match?('/abc/df/ghi')).to be_falsey - expect(pattern.match?('/abc/d/ghi')).to be_falsey - expect(pattern.match?('/abc/f/ghi')).to be_falsey - expect(pattern.match?('/abc/ghi')).to be_falsey - end - it 'exact_path' do + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d??f/ghi") } + it "match?" do + expect(pattern.match?("/abc/deef/ghi")).to be_truthy + expect(pattern.match?("/abc/deeef/ghi")).to be_falsey + expect(pattern.match?("/abc/def/ghi")).to be_falsey + expect(pattern.match?("/abc/df/ghi")).to be_falsey + expect(pattern.match?("/abc/d/ghi")).to be_falsey + expect(pattern.match?("/abc/f/ghi")).to be_falsey + expect(pattern.match?("/abc/ghi")).to be_falsey + end + it "exact_path" do expect(pattern.exact_path).to be_nil end - it 'could_match_children?' do - expect(pattern.could_match_children?('/abc')).to be_truthy - expect(pattern.could_match_children?('/xyz')).to be_falsey - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/abc/deef')).to be_truthy - expect(pattern.could_match_children?('/abc/deeef')).to be_falsey - expect(pattern.could_match_children?('/abc/def')).to be_falsey - expect(pattern.could_match_children?('/abc/df')).to be_falsey - expect(pattern.could_match_children?('/abc/d')).to be_falsey - expect(pattern.could_match_children?('/abc/f')).to be_falsey - expect(pattern.could_match_children?('/abc/deef/ghi')).to be_falsey - end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq('abc') - expect(pattern.exact_child_name_under('/abc')).to eq(nil) - expect(pattern.exact_child_name_under('/abc/deef')).to eq('ghi') + it "could_match_children?" do + expect(pattern.could_match_children?("/abc")).to be_truthy + expect(pattern.could_match_children?("/xyz")).to be_falsey + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/abc/deef")).to be_truthy + expect(pattern.could_match_children?("/abc/deeef")).to be_falsey + expect(pattern.could_match_children?("/abc/def")).to be_falsey + expect(pattern.could_match_children?("/abc/df")).to be_falsey + expect(pattern.could_match_children?("/abc/d")).to be_falsey + expect(pattern.could_match_children?("/abc/f")).to be_falsey + expect(pattern.could_match_children?("/abc/deef/ghi")).to be_falsey + end + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq("abc") + expect(pattern.exact_child_name_under("/abc")).to eq(nil) + expect(pattern.exact_child_name_under("/abc/deef")).to eq("ghi") end end context 'with star pattern "/abc/d[a-z][0-9]f/ghi"', :skip => (Chef::Platform.windows?) do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/d[a-z][0-9]f/ghi') } - it 'match?' do - expect(pattern.match?('/abc/de1f/ghi')).to be_truthy - expect(pattern.match?('/abc/deef/ghi')).to be_falsey - expect(pattern.match?('/abc/d11f/ghi')).to be_falsey - expect(pattern.match?('/abc/de11f/ghi')).to be_falsey - expect(pattern.match?('/abc/dee1f/ghi')).to be_falsey - expect(pattern.match?('/abc/df/ghi')).to be_falsey - expect(pattern.match?('/abc/d/ghi')).to be_falsey - expect(pattern.match?('/abc/f/ghi')).to be_falsey - expect(pattern.match?('/abc/ghi')).to be_falsey - end - it 'exact_path' do + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/d[a-z][0-9]f/ghi") } + it "match?" do + expect(pattern.match?("/abc/de1f/ghi")).to be_truthy + expect(pattern.match?("/abc/deef/ghi")).to be_falsey + expect(pattern.match?("/abc/d11f/ghi")).to be_falsey + expect(pattern.match?("/abc/de11f/ghi")).to be_falsey + expect(pattern.match?("/abc/dee1f/ghi")).to be_falsey + expect(pattern.match?("/abc/df/ghi")).to be_falsey + expect(pattern.match?("/abc/d/ghi")).to be_falsey + expect(pattern.match?("/abc/f/ghi")).to be_falsey + expect(pattern.match?("/abc/ghi")).to be_falsey + end + it "exact_path" do expect(pattern.exact_path).to be_nil end - it 'could_match_children?' do - expect(pattern.could_match_children?('/abc')).to be_truthy - expect(pattern.could_match_children?('/xyz')).to be_falsey - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/abc/de1f')).to be_truthy - expect(pattern.could_match_children?('/abc/deef')).to be_falsey - expect(pattern.could_match_children?('/abc/d11f')).to be_falsey - expect(pattern.could_match_children?('/abc/de11f')).to be_falsey - expect(pattern.could_match_children?('/abc/dee1f')).to be_falsey - expect(pattern.could_match_children?('/abc/def')).to be_falsey - expect(pattern.could_match_children?('/abc/df')).to be_falsey - expect(pattern.could_match_children?('/abc/d')).to be_falsey - expect(pattern.could_match_children?('/abc/f')).to be_falsey - expect(pattern.could_match_children?('/abc/de1f/ghi')).to be_falsey - end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq('abc') - expect(pattern.exact_child_name_under('/abc')).to eq(nil) - expect(pattern.exact_child_name_under('/abc/de1f')).to eq('ghi') + it "could_match_children?" do + expect(pattern.could_match_children?("/abc")).to be_truthy + expect(pattern.could_match_children?("/xyz")).to be_falsey + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/abc/de1f")).to be_truthy + expect(pattern.could_match_children?("/abc/deef")).to be_falsey + expect(pattern.could_match_children?("/abc/d11f")).to be_falsey + expect(pattern.could_match_children?("/abc/de11f")).to be_falsey + expect(pattern.could_match_children?("/abc/dee1f")).to be_falsey + expect(pattern.could_match_children?("/abc/def")).to be_falsey + expect(pattern.could_match_children?("/abc/df")).to be_falsey + expect(pattern.could_match_children?("/abc/d")).to be_falsey + expect(pattern.could_match_children?("/abc/f")).to be_falsey + expect(pattern.could_match_children?("/abc/de1f/ghi")).to be_falsey + end + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq("abc") + expect(pattern.exact_child_name_under("/abc")).to eq(nil) + expect(pattern.exact_child_name_under("/abc/de1f")).to eq("ghi") end end context 'with star pattern "/abc/**/ghi"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/**/ghi') } - it 'match?' do - expect(pattern.match?('/abc/def/ghi')).to be_truthy - expect(pattern.match?('/abc/d/e/f/ghi')).to be_truthy - expect(pattern.match?('/abc/ghi')).to be_falsey - expect(pattern.match?('/abcdef/d/ghi')).to be_falsey - expect(pattern.match?('/abc/d/defghi')).to be_falsey - expect(pattern.match?('/xyz')).to be_falsey - end - it 'exact_path' do + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/**/ghi") } + it "match?" do + expect(pattern.match?("/abc/def/ghi")).to be_truthy + expect(pattern.match?("/abc/d/e/f/ghi")).to be_truthy + expect(pattern.match?("/abc/ghi")).to be_falsey + expect(pattern.match?("/abcdef/d/ghi")).to be_falsey + expect(pattern.match?("/abc/d/defghi")).to be_falsey + expect(pattern.match?("/xyz")).to be_falsey + end + it "exact_path" do expect(pattern.exact_path).to be_nil end - it 'could_match_children?' do - expect(pattern.could_match_children?('/abc')).to be_truthy - expect(pattern.could_match_children?('/abc/d')).to be_truthy - expect(pattern.could_match_children?('/abc/d/e')).to be_truthy - expect(pattern.could_match_children?('/abc/d/e/f')).to be_truthy - expect(pattern.could_match_children?('/abc/def/ghi')).to be_truthy - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/xyz')).to be_falsey + it "could_match_children?" do + expect(pattern.could_match_children?("/abc")).to be_truthy + expect(pattern.could_match_children?("/abc/d")).to be_truthy + expect(pattern.could_match_children?("/abc/d/e")).to be_truthy + expect(pattern.could_match_children?("/abc/d/e/f")).to be_truthy + expect(pattern.could_match_children?("/abc/def/ghi")).to be_truthy + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/xyz")).to be_falsey end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq('abc') - expect(pattern.exact_child_name_under('/abc')).to eq(nil) - expect(pattern.exact_child_name_under('/abc/def')).to eq(nil) + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq("abc") + expect(pattern.exact_child_name_under("/abc")).to eq(nil) + expect(pattern.exact_child_name_under("/abc/def")).to eq(nil) end end context 'with star pattern "/abc**/ghi"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc**/ghi') } - it 'match?' do - expect(pattern.match?('/abc/def/ghi')).to be_truthy - expect(pattern.match?('/abc/d/e/f/ghi')).to be_truthy - expect(pattern.match?('/abc/ghi')).to be_truthy - expect(pattern.match?('/abcdef/ghi')).to be_truthy - expect(pattern.match?('/abc/defghi')).to be_falsey - expect(pattern.match?('/xyz')).to be_falsey - end - it 'exact_path' do + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc**/ghi") } + it "match?" do + expect(pattern.match?("/abc/def/ghi")).to be_truthy + expect(pattern.match?("/abc/d/e/f/ghi")).to be_truthy + expect(pattern.match?("/abc/ghi")).to be_truthy + expect(pattern.match?("/abcdef/ghi")).to be_truthy + expect(pattern.match?("/abc/defghi")).to be_falsey + expect(pattern.match?("/xyz")).to be_falsey + end + it "exact_path" do expect(pattern.exact_path).to be_nil end - it 'could_match_children?' do - expect(pattern.could_match_children?('/abc')).to be_truthy - expect(pattern.could_match_children?('/abcdef')).to be_truthy - expect(pattern.could_match_children?('/abc/d/e')).to be_truthy - expect(pattern.could_match_children?('/abc/d/e/f')).to be_truthy - expect(pattern.could_match_children?('/abc/def/ghi')).to be_truthy - expect(pattern.could_match_children?('abc')).to be_falsey + it "could_match_children?" do + expect(pattern.could_match_children?("/abc")).to be_truthy + expect(pattern.could_match_children?("/abcdef")).to be_truthy + expect(pattern.could_match_children?("/abc/d/e")).to be_truthy + expect(pattern.could_match_children?("/abc/d/e/f")).to be_truthy + expect(pattern.could_match_children?("/abc/def/ghi")).to be_truthy + expect(pattern.could_match_children?("abc")).to be_falsey end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq(nil) - expect(pattern.exact_child_name_under('/abc')).to eq(nil) - expect(pattern.exact_child_name_under('/abc/def')).to eq(nil) + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq(nil) + expect(pattern.exact_child_name_under("/abc")).to eq(nil) + expect(pattern.exact_child_name_under("/abc/def")).to eq(nil) end end context 'with star pattern "/abc/**ghi"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('/abc/**ghi') } - it 'match?' do - expect(pattern.match?('/abc/def/ghi')).to be_truthy - expect(pattern.match?('/abc/def/ghi/ghi')).to be_truthy - expect(pattern.match?('/abc/def/ghi/jkl')).to be_falsey - expect(pattern.match?('/abc/d/e/f/ghi')).to be_truthy - expect(pattern.match?('/abc/ghi')).to be_truthy - expect(pattern.match?('/abcdef/ghi')).to be_falsey - expect(pattern.match?('/abc/defghi')).to be_truthy - expect(pattern.match?('/xyz')).to be_falsey - end - it 'exact_path' do + let(:pattern) { Chef::ChefFS::FilePattern.new("/abc/**ghi") } + it "match?" do + expect(pattern.match?("/abc/def/ghi")).to be_truthy + expect(pattern.match?("/abc/def/ghi/ghi")).to be_truthy + expect(pattern.match?("/abc/def/ghi/jkl")).to be_falsey + expect(pattern.match?("/abc/d/e/f/ghi")).to be_truthy + expect(pattern.match?("/abc/ghi")).to be_truthy + expect(pattern.match?("/abcdef/ghi")).to be_falsey + expect(pattern.match?("/abc/defghi")).to be_truthy + expect(pattern.match?("/xyz")).to be_falsey + end + it "exact_path" do expect(pattern.exact_path).to be_nil end - it 'could_match_children?' do - expect(pattern.could_match_children?('/abc')).to be_truthy - expect(pattern.could_match_children?('/abcdef')).to be_falsey - expect(pattern.could_match_children?('/abc/d/e')).to be_truthy - expect(pattern.could_match_children?('/abc/d/e/f')).to be_truthy - expect(pattern.could_match_children?('/abc/def/ghi')).to be_truthy - expect(pattern.could_match_children?('abc')).to be_falsey - expect(pattern.could_match_children?('/xyz')).to be_falsey + it "could_match_children?" do + expect(pattern.could_match_children?("/abc")).to be_truthy + expect(pattern.could_match_children?("/abcdef")).to be_falsey + expect(pattern.could_match_children?("/abc/d/e")).to be_truthy + expect(pattern.could_match_children?("/abc/d/e/f")).to be_truthy + expect(pattern.could_match_children?("/abc/def/ghi")).to be_truthy + expect(pattern.could_match_children?("abc")).to be_falsey + expect(pattern.could_match_children?("/xyz")).to be_falsey end - it 'exact_child_name_under' do - expect(pattern.exact_child_name_under('/')).to eq('abc') - expect(pattern.exact_child_name_under('/abc')).to eq(nil) - expect(pattern.exact_child_name_under('/abc/def')).to eq(nil) + it "exact_child_name_under" do + expect(pattern.exact_child_name_under("/")).to eq("abc") + expect(pattern.exact_child_name_under("/abc")).to eq(nil) + expect(pattern.exact_child_name_under("/abc/def")).to eq(nil) end end context 'with star pattern "a**b**c"' do - let(:pattern) { Chef::ChefFS::FilePattern.new('a**b**c') } - it 'match?' do - expect(pattern.match?('axybzwc')).to be_truthy - expect(pattern.match?('abc')).to be_truthy - expect(pattern.match?('axyzwc')).to be_falsey - expect(pattern.match?('ac')).to be_falsey - expect(pattern.match?('a/x/y/b/z/w/c')).to be_truthy - end - it 'exact_path' do + let(:pattern) { Chef::ChefFS::FilePattern.new("a**b**c") } + it "match?" do + expect(pattern.match?("axybzwc")).to be_truthy + expect(pattern.match?("abc")).to be_truthy + expect(pattern.match?("axyzwc")).to be_falsey + expect(pattern.match?("ac")).to be_falsey + expect(pattern.match?("a/x/y/b/z/w/c")).to be_truthy + end + it "exact_path" do expect(pattern.exact_path).to be_nil end end - context 'normalization tests' do - it 'handles trailing slashes' do - expect(p('abc/').normalized_pattern).to eq('abc') - expect(p('abc/').exact_path).to eq('abc') - expect(p('abc/').match?('abc')).to be_truthy - expect(p('//').normalized_pattern).to eq('/') - expect(p('//').exact_path).to eq('/') - expect(p('//').match?('/')).to be_truthy - expect(p('/./').normalized_pattern).to eq('/') - expect(p('/./').exact_path).to eq('/') - expect(p('/./').match?('/')).to be_truthy - end - it 'handles multiple slashes' do - expect(p('abc//def').normalized_pattern).to eq('abc/def') - expect(p('abc//def').exact_path).to eq('abc/def') - expect(p('abc//def').match?('abc/def')).to be_truthy - expect(p('abc//').normalized_pattern).to eq('abc') - expect(p('abc//').exact_path).to eq('abc') - expect(p('abc//').match?('abc')).to be_truthy - end - it 'handles dot' do - expect(p('abc/./def').normalized_pattern).to eq('abc/def') - expect(p('abc/./def').exact_path).to eq('abc/def') - expect(p('abc/./def').match?('abc/def')).to be_truthy - expect(p('./abc/def').normalized_pattern).to eq('abc/def') - expect(p('./abc/def').exact_path).to eq('abc/def') - expect(p('./abc/def').match?('abc/def')).to be_truthy - expect(p('/.').normalized_pattern).to eq('/') - expect(p('/.').exact_path).to eq('/') - expect(p('/.').match?('/')).to be_truthy - end - it 'handles dotdot' do - expect(p('abc/../def').normalized_pattern).to eq('def') - expect(p('abc/../def').exact_path).to eq('def') - expect(p('abc/../def').match?('def')).to be_truthy - expect(p('abc/def/../..').normalized_pattern).to eq('') - expect(p('abc/def/../..').exact_path).to eq('') - expect(p('abc/def/../..').match?('')).to be_truthy - expect(p('/*/../def').normalized_pattern).to eq('/def') - expect(p('/*/../def').exact_path).to eq('/def') - expect(p('/*/../def').match?('/def')).to be_truthy - expect(p('/*/*/../def').normalized_pattern).to eq('/*/def') - expect(p('/*/*/../def').exact_path).to be_nil - expect(p('/*/*/../def').match?('/abc/def')).to be_truthy - expect(p('/abc/def/../..').normalized_pattern).to eq('/') - expect(p('/abc/def/../..').exact_path).to eq('/') - expect(p('/abc/def/../..').match?('/')).to be_truthy - expect(p('abc/../../def').normalized_pattern).to eq('../def') - expect(p('abc/../../def').exact_path).to eq('../def') - expect(p('abc/../../def').match?('../def')).to be_truthy - end - it 'handles dotdot with double star' do - expect(p('abc**/def/../ghi').exact_path).to be_nil - expect(p('abc**/def/../ghi').match?('abc/ghi')).to be_truthy - expect(p('abc**/def/../ghi').match?('abc/x/y/z/ghi')).to be_truthy - expect(p('abc**/def/../ghi').match?('ghi')).to be_falsey - end - it 'raises error on dotdot with overlapping double star' do - expect { Chef::ChefFS::FilePattern.new('abc/**/../def').exact_path }.to raise_error(ArgumentError) - expect { Chef::ChefFS::FilePattern.new('abc/**/abc/../../def').exact_path }.to raise_error(ArgumentError) - end - it 'handles leading dotdot' do - expect(p('../abc/def').exact_path).to eq('../abc/def') - expect(p('../abc/def').match?('../abc/def')).to be_truthy - expect(p('/../abc/def').exact_path).to eq('/abc/def') - expect(p('/../abc/def').match?('/abc/def')).to be_truthy - expect(p('..').exact_path).to eq('..') - expect(p('..').match?('..')).to be_truthy - expect(p('/..').exact_path).to eq('/') - expect(p('/..').match?('/')).to be_truthy + context "normalization tests" do + it "handles trailing slashes" do + expect(p("abc/").normalized_pattern).to eq("abc") + expect(p("abc/").exact_path).to eq("abc") + expect(p("abc/").match?("abc")).to be_truthy + expect(p("//").normalized_pattern).to eq("/") + expect(p("//").exact_path).to eq("/") + expect(p("//").match?("/")).to be_truthy + expect(p("/./").normalized_pattern).to eq("/") + expect(p("/./").exact_path).to eq("/") + expect(p("/./").match?("/")).to be_truthy + end + it "handles multiple slashes" do + expect(p("abc//def").normalized_pattern).to eq("abc/def") + expect(p("abc//def").exact_path).to eq("abc/def") + expect(p("abc//def").match?("abc/def")).to be_truthy + expect(p("abc//").normalized_pattern).to eq("abc") + expect(p("abc//").exact_path).to eq("abc") + expect(p("abc//").match?("abc")).to be_truthy + end + it "handles dot" do + expect(p("abc/./def").normalized_pattern).to eq("abc/def") + expect(p("abc/./def").exact_path).to eq("abc/def") + expect(p("abc/./def").match?("abc/def")).to be_truthy + expect(p("./abc/def").normalized_pattern).to eq("abc/def") + expect(p("./abc/def").exact_path).to eq("abc/def") + expect(p("./abc/def").match?("abc/def")).to be_truthy + expect(p("/.").normalized_pattern).to eq("/") + expect(p("/.").exact_path).to eq("/") + expect(p("/.").match?("/")).to be_truthy + end + it "handles dotdot" do + expect(p("abc/../def").normalized_pattern).to eq("def") + expect(p("abc/../def").exact_path).to eq("def") + expect(p("abc/../def").match?("def")).to be_truthy + expect(p("abc/def/../..").normalized_pattern).to eq("") + expect(p("abc/def/../..").exact_path).to eq("") + expect(p("abc/def/../..").match?("")).to be_truthy + expect(p("/*/../def").normalized_pattern).to eq("/def") + expect(p("/*/../def").exact_path).to eq("/def") + expect(p("/*/../def").match?("/def")).to be_truthy + expect(p("/*/*/../def").normalized_pattern).to eq("/*/def") + expect(p("/*/*/../def").exact_path).to be_nil + expect(p("/*/*/../def").match?("/abc/def")).to be_truthy + expect(p("/abc/def/../..").normalized_pattern).to eq("/") + expect(p("/abc/def/../..").exact_path).to eq("/") + expect(p("/abc/def/../..").match?("/")).to be_truthy + expect(p("abc/../../def").normalized_pattern).to eq("../def") + expect(p("abc/../../def").exact_path).to eq("../def") + expect(p("abc/../../def").match?("../def")).to be_truthy + end + it "handles dotdot with double star" do + expect(p("abc**/def/../ghi").exact_path).to be_nil + expect(p("abc**/def/../ghi").match?("abc/ghi")).to be_truthy + expect(p("abc**/def/../ghi").match?("abc/x/y/z/ghi")).to be_truthy + expect(p("abc**/def/../ghi").match?("ghi")).to be_falsey + end + it "raises error on dotdot with overlapping double star" do + expect { Chef::ChefFS::FilePattern.new("abc/**/../def").exact_path }.to raise_error(ArgumentError) + expect { Chef::ChefFS::FilePattern.new("abc/**/abc/../../def").exact_path }.to raise_error(ArgumentError) + end + it "handles leading dotdot" do + expect(p("../abc/def").exact_path).to eq("../abc/def") + expect(p("../abc/def").match?("../abc/def")).to be_truthy + expect(p("/../abc/def").exact_path).to eq("/abc/def") + expect(p("/../abc/def").match?("/abc/def")).to be_truthy + expect(p("..").exact_path).to eq("..") + expect(p("..").match?("..")).to be_truthy + expect(p("/..").exact_path).to eq("/") + expect(p("/..").match?("/")).to be_truthy end end diff --git a/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb b/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb index b98ec12161..56967eaa63 100644 --- a/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb +++ b/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb @@ -16,19 +16,19 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/chef_fs/file_system/chef_server/cookbook_subdir' +require "spec_helper" +require "chef/chef_fs/file_system/chef_server/cookbook_subdir" describe Chef::ChefFS::FileSystem::ChefServer::CookbookSubdir do let(:root) do - Chef::ChefFS::FileSystem::BaseFSDir.new('', nil) + Chef::ChefFS::FileSystem::BaseFSDir.new("", nil) end let(:cookbook_subdir) do - Chef::ChefFS::FileSystem::ChefServer::CookbookSubdir.new('test', root, false, true) + Chef::ChefFS::FileSystem::ChefServer::CookbookSubdir.new("test", root, false, true) end - it 'can get child' do - cookbook_subdir.child('test') + it "can get child" do + cookbook_subdir.child("test") end end diff --git a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb index 142755a4f1..f3054d8158 100644 --- a/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb +++ b/spec/unit/chef_fs/file_system/operation_failed_error_spec.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/chef_fs/file_system/operation_failed_error' +require "spec_helper" +require "chef/chef_fs/file_system/operation_failed_error" describe Chef::ChefFS::FileSystem::OperationFailedError do - context 'message' do + context "message" do let(:error_message) { 'HTTP error writing: 400 "Bad Request"' } - context 'has a cause attribute and HTTP result code is 400' do - it 'include error cause' do + context "has a cause attribute and HTTP result code is 400" do + it "include error cause" do allow_message_expectations_on_nil response_body = '{"error":["Invalid key test in request body"]}' allow(@response).to receive(:code).and_return("400") @@ -36,8 +36,8 @@ describe Chef::ChefFS::FileSystem::OperationFailedError do end end - context 'does not have a cause attribute' do - it 'does not include error cause' do + context "does not have a cause attribute" do + it "does not include error cause" do expect { raise Chef::ChefFS::FileSystem::OperationFailedError.new(:write, self), error_message }.to raise_error(Chef::ChefFS::FileSystem::OperationFailedError, error_message) diff --git a/spec/unit/chef_fs/file_system_spec.rb b/spec/unit/chef_fs/file_system_spec.rb index a765be61db..8b1c90b91c 100644 --- a/spec/unit/chef_fs/file_system_spec.rb +++ b/spec/unit/chef_fs/file_system_spec.rb @@ -16,132 +16,132 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/chef_fs/file_system' -require 'chef/chef_fs/file_pattern' +require "spec_helper" +require "chef/chef_fs/file_system" +require "chef/chef_fs/file_pattern" describe Chef::ChefFS::FileSystem do include FileSystemSupport - context 'with empty filesystem' do - let(:fs) { memory_fs('', {}) } + context "with empty filesystem" do + let(:fs) { memory_fs("", {}) } - context 'list' do - it '/' do - list_should_yield_paths(fs, '/', '/') + context "list" do + it "/" do + list_should_yield_paths(fs, "/", "/") end - it '/a' do - list_should_yield_paths(fs, '/a', '/a') + it "/a" do + list_should_yield_paths(fs, "/a", "/a") end - it '/a/b' do - list_should_yield_paths(fs, '/a/b', '/a/b') + it "/a/b" do + list_should_yield_paths(fs, "/a/b", "/a/b") end - it '/*' do - list_should_yield_paths(fs, '/*', '/') + it "/*" do + list_should_yield_paths(fs, "/*", "/") end end - context 'resolve_path' do - it '/' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/').path).to eq('/') + context "resolve_path" do + it "/" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/").path).to eq("/") end - it 'nonexistent /a' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a').path).to eq('/a') + it "nonexistent /a" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a").path).to eq("/a") end - it 'nonexistent /a/b' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a/b').path).to eq('/a/b') + it "nonexistent /a/b" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a/b").path).to eq("/a/b") end end end - context 'with a populated filesystem' do + context "with a populated filesystem" do let(:fs) { - memory_fs('', { + memory_fs("", { :a => { :aa => { - :c => '', - :zz => '', + :c => "", + :zz => "", }, :ab => { - :c => '' + :c => "" }, }, - :x => '', + :x => "", :y => {}, },) } - context 'list' do - it '/**' do - list_should_yield_paths(fs, '/**', '/', '/a', '/x', '/y', '/a/aa', '/a/aa/c', '/a/aa/zz', '/a/ab', '/a/ab/c') + context "list" do + it "/**" do + list_should_yield_paths(fs, "/**", "/", "/a", "/x", "/y", "/a/aa", "/a/aa/c", "/a/aa/zz", "/a/ab", "/a/ab/c") end - it '/' do - list_should_yield_paths(fs, '/', '/') + it "/" do + list_should_yield_paths(fs, "/", "/") end - it '/*' do - list_should_yield_paths(fs, '/*', '/', '/a', '/x', '/y') + it "/*" do + list_should_yield_paths(fs, "/*", "/", "/a", "/x", "/y") end - it '/*/*' do - list_should_yield_paths(fs, '/*/*', '/a/aa', '/a/ab') + it "/*/*" do + list_should_yield_paths(fs, "/*/*", "/a/aa", "/a/ab") end - it '/*/*/*' do - list_should_yield_paths(fs, '/*/*/*', '/a/aa/c', '/a/aa/zz', '/a/ab/c') + it "/*/*/*" do + list_should_yield_paths(fs, "/*/*/*", "/a/aa/c", "/a/aa/zz", "/a/ab/c") end - it '/*/*/?' do - list_should_yield_paths(fs, '/*/*/?', '/a/aa/c', '/a/ab/c') + it "/*/*/?" do + list_should_yield_paths(fs, "/*/*/?", "/a/aa/c", "/a/ab/c") end - it '/a/*/c' do - list_should_yield_paths(fs, '/a/*/c', '/a/aa/c', '/a/ab/c') + it "/a/*/c" do + list_should_yield_paths(fs, "/a/*/c", "/a/aa/c", "/a/ab/c") end - it '/**b/c' do - list_should_yield_paths(fs, '/**b/c', '/a/ab/c') + it "/**b/c" do + list_should_yield_paths(fs, "/**b/c", "/a/ab/c") end - it '/a/ab/c' do + it "/a/ab/c" do no_blocking_calls_allowed - list_should_yield_paths(fs, '/a/ab/c', '/a/ab/c') + list_should_yield_paths(fs, "/a/ab/c", "/a/ab/c") end - it 'nonexistent /a/ab/blah' do + it "nonexistent /a/ab/blah" do no_blocking_calls_allowed - list_should_yield_paths(fs, '/a/ab/blah', '/a/ab/blah') + list_should_yield_paths(fs, "/a/ab/blah", "/a/ab/blah") end - it 'nonexistent /a/ab/blah/bjork' do + it "nonexistent /a/ab/blah/bjork" do no_blocking_calls_allowed - list_should_yield_paths(fs, '/a/ab/blah/bjork', '/a/ab/blah/bjork') + list_should_yield_paths(fs, "/a/ab/blah/bjork", "/a/ab/blah/bjork") end end - context 'resolve_path' do + context "resolve_path" do before(:each) do no_blocking_calls_allowed end - it 'resolves /' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/').path).to eq('/') + it "resolves /" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/").path).to eq("/") end - it 'resolves /x' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/x').path).to eq('/x') + it "resolves /x" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/x").path).to eq("/x") end - it 'resolves /a' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a').path).to eq('/a') + it "resolves /a" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a").path).to eq("/a") end - it 'resolves /a/aa' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a/aa').path).to eq('/a/aa') + it "resolves /a/aa" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a/aa").path).to eq("/a/aa") end - it 'resolves /a/aa/zz' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/a/aa/zz').path).to eq('/a/aa/zz') + it "resolves /a/aa/zz" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/a/aa/zz").path).to eq("/a/aa/zz") end - it 'resolves nonexistent /q/x/w' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/q/x/w').path).to eq('/q/x/w') + it "resolves nonexistent /q/x/w" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/q/x/w").path).to eq("/q/x/w") end end - context 'empty?' do - it 'is not empty /' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/').empty?).to be false + context "empty?" do + it "is not empty /" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/").empty?).to be false end - it 'is empty /y' do - expect(Chef::ChefFS::FileSystem.resolve_path(fs, '/y').empty?).to be true + it "is empty /y" do + expect(Chef::ChefFS::FileSystem.resolve_path(fs, "/y").empty?).to be true end it 'is not a directory and can\'t be tested /x' do - expect { Chef::ChefFS::FileSystem.resolve_path(fs, '/x').empty? }.to raise_error(NoMethodError) + expect { Chef::ChefFS::FileSystem.resolve_path(fs, "/x").empty? }.to raise_error(NoMethodError) end end end diff --git a/spec/unit/chef_fs/parallelizer.rb b/spec/unit/chef_fs/parallelizer.rb index 3ca4ee0092..0d667098a8 100644 --- a/spec/unit/chef_fs/parallelizer.rb +++ b/spec/unit/chef_fs/parallelizer.rb @@ -1,5 +1,5 @@ -require 'spec_helper' -require 'chef/chef_fs/parallelizer' +require "spec_helper" +require "chef/chef_fs/parallelizer" describe Chef::ChefFS::Parallelizer do before :each do @@ -14,7 +14,7 @@ describe Chef::ChefFS::Parallelizer do parallelizer.kill end - context 'With a Parallelizer with 5 threads' do + context "With a Parallelizer with 5 threads" do let :parallelizer do Chef::ChefFS::Parallelizer.new(5) end @@ -44,7 +44,7 @@ describe Chef::ChefFS::Parallelizer do it "10 sleep(0.2)s complete within 0.5 seconds" do expect(parallelize(1.upto(10), :ordered => false) do |i| sleep 0.2 - 'x' + "x" end.to_a).to eq(%w(x x x x x x x x x x)) expect(elapsed_time).to be < 0.5 end @@ -62,28 +62,28 @@ describe Chef::ChefFS::Parallelizer do it "An exception in input is passed through but does NOT stop processing" do input = TestEnumerable.new(0.5,0.3,0.1) do - raise 'hi' + raise "hi" end enum = parallelize(input, :ordered => false) { |x| sleep(x); x } results = [] - expect { enum.each { |value| results << value } }.to raise_error 'hi' + expect { enum.each { |value| results << value } }.to raise_error "hi" expect(results).to eq([ 0.1, 0.3, 0.5 ]) expect(elapsed_time).to be < 0.6 end it "Exceptions in output are raised after all processing is done" do processed = 0 - enum = parallelize([1,2,'x',3], :ordered => false) do |x| - if x == 'x' + enum = parallelize([1,2,"x",3], :ordered => false) do |x| + if x == "x" sleep 0.1 - raise 'hi' + raise "hi" end sleep 0.2 processed += 1 x end results = [] - expect { enum.each { |value| results << value } }.to raise_error 'hi' + expect { enum.each { |value| results << value } }.to raise_error "hi" expect(results.sort).to eq([ 1, 2, 3 ]) expect(elapsed_time).to be < 0.3 expect(processed).to eq(3) @@ -91,16 +91,16 @@ describe Chef::ChefFS::Parallelizer do it "Exceptions with :stop_on_exception are raised after all processing is done" do processed = 0 - parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x| - if x == 'x' + parallelized = parallelize([0.3,0.3,"x",0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x| + if x == "x" sleep(0.1) - raise 'hi' + raise "hi" end sleep(x) processed += 1 x end - expect { parallelized.to_a }.to raise_error 'hi' + expect { parallelized.to_a }.to raise_error "hi" expect(processed).to eq(4) end end @@ -116,7 +116,7 @@ describe Chef::ChefFS::Parallelizer do it "10 sleep(0.2)s complete within 0.5 seconds" do expect(parallelize(1.upto(10), :ordered => true) do |i| sleep 0.2 - 'x' + "x" end.to_a).to eq(%w(x x x x x x x x x x)) expect(elapsed_time).to be < 0.5 end @@ -134,28 +134,28 @@ describe Chef::ChefFS::Parallelizer do it "Exceptions in input are raised in the correct sequence but do NOT stop processing" do input = TestEnumerable.new(0.5,0.3,0.1) do - raise 'hi' + raise "hi" end results = [] enum = parallelize(input) { |x| sleep(x); x } - expect { enum.each { |value| results << value } }.to raise_error 'hi' + expect { enum.each { |value| results << value } }.to raise_error "hi" expect(elapsed_time).to be < 0.6 expect(results).to eq([ 0.5, 0.3, 0.1 ]) end it "Exceptions in output are raised in the correct sequence and running processes do NOT stop processing" do processed = 0 - enum = parallelize([1,2,'x',3]) do |x| - if x == 'x' + enum = parallelize([1,2,"x",3]) do |x| + if x == "x" sleep(0.1) - raise 'hi' + raise "hi" end sleep(0.2) processed += 1 x end results = [] - expect { enum.each { |value| results << value } }.to raise_error 'hi' + expect { enum.each { |value| results << value } }.to raise_error "hi" expect(results).to eq([ 1, 2 ]) expect(elapsed_time).to be < 0.3 expect(processed).to eq(3) @@ -163,16 +163,16 @@ describe Chef::ChefFS::Parallelizer do it "Exceptions with :stop_on_exception are raised after all processing is done" do processed = 0 - parallelized = parallelize([0.3,0.3,'x',0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x| - if x == 'x' + parallelized = parallelize([0.3,0.3,"x",0.3,0.3,0.3,0.3,0.3], :ordered => false, :stop_on_exception => true) do |x| + if x == "x" sleep(0.1) - raise 'hi' + raise "hi" end sleep(x) processed += 1 x end - expect { parallelized.to_a }.to raise_error 'hi' + expect { parallelized.to_a }.to raise_error "hi" expect(processed).to eq(4) end end diff --git a/spec/unit/chef_fs/path_util_spec.rb b/spec/unit/chef_fs/path_util_spec.rb index 42eb126dfb..02d0de8857 100644 --- a/spec/unit/chef_fs/path_util_spec.rb +++ b/spec/unit/chef_fs/path_util_spec.rb @@ -16,93 +16,93 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/chef_fs/path_utils' +require "spec_helper" +require "chef/chef_fs/path_utils" describe Chef::ChefFS::PathUtils do - context 'invoking join' do - it 'joins well-behaved distinct path elements' do - expect(Chef::ChefFS::PathUtils.join('a', 'b', 'c')).to eq('a/b/c') + context "invoking join" do + it "joins well-behaved distinct path elements" do + expect(Chef::ChefFS::PathUtils.join("a", "b", "c")).to eq("a/b/c") end - it 'strips extraneous slashes in the middle of paths' do - expect(Chef::ChefFS::PathUtils.join('a/', '/b', '/c/')).to eq('a/b/c') - expect(Chef::ChefFS::PathUtils.join('a/', '/b', '///c/')).to eq('a/b/c') + it "strips extraneous slashes in the middle of paths" do + expect(Chef::ChefFS::PathUtils.join("a/", "/b", "/c/")).to eq("a/b/c") + expect(Chef::ChefFS::PathUtils.join("a/", "/b", "///c/")).to eq("a/b/c") end - it 'preserves the whether the first element was absolute or not' do - expect(Chef::ChefFS::PathUtils.join('/a/', '/b', 'c/')).to eq('/a/b/c') - expect(Chef::ChefFS::PathUtils.join('///a/', '/b', 'c/')).to eq('/a/b/c') + it "preserves the whether the first element was absolute or not" do + expect(Chef::ChefFS::PathUtils.join("/a/", "/b", "c/")).to eq("/a/b/c") + expect(Chef::ChefFS::PathUtils.join("///a/", "/b", "c/")).to eq("/a/b/c") end end - context 'invoking is_absolute?' do - it 'confirms that paths starting with / are absolute' do - expect(Chef::ChefFS::PathUtils.is_absolute?('/foo/bar/baz')).to be true - expect(Chef::ChefFS::PathUtils.is_absolute?('/foo')).to be true + context "invoking is_absolute?" do + it "confirms that paths starting with / are absolute" do + expect(Chef::ChefFS::PathUtils.is_absolute?("/foo/bar/baz")).to be true + expect(Chef::ChefFS::PathUtils.is_absolute?("/foo")).to be true end - it 'confirms that paths starting with // are absolute even though that looks like some windows network path' do - expect(Chef::ChefFS::PathUtils.is_absolute?('//foo/bar/baz')).to be true + it "confirms that paths starting with // are absolute even though that looks like some windows network path" do + expect(Chef::ChefFS::PathUtils.is_absolute?("//foo/bar/baz")).to be true end - it 'confirms that root is indeed absolute' do - expect(Chef::ChefFS::PathUtils.is_absolute?('/')).to be true + it "confirms that root is indeed absolute" do + expect(Chef::ChefFS::PathUtils.is_absolute?("/")).to be true end - it 'confirms that paths starting without / are relative' do - expect(Chef::ChefFS::PathUtils.is_absolute?('foo/bar/baz')).to be false - expect(Chef::ChefFS::PathUtils.is_absolute?('a')).to be false + it "confirms that paths starting without / are relative" do + expect(Chef::ChefFS::PathUtils.is_absolute?("foo/bar/baz")).to be false + expect(Chef::ChefFS::PathUtils.is_absolute?("a")).to be false end - it 'returns false for an empty path.' do - expect(Chef::ChefFS::PathUtils.is_absolute?('')).to be false + it "returns false for an empty path." do + expect(Chef::ChefFS::PathUtils.is_absolute?("")).to be false end end - context 'invoking realest_path' do + context "invoking realest_path" do let(:good_path) { File.dirname(__FILE__) } let(:parent_path) { File.dirname(good_path) } - it 'handles paths with no wildcards or globs' do + it "handles paths with no wildcards or globs" do expect(Chef::ChefFS::PathUtils.realest_path(good_path)).to eq(File.expand_path(good_path)) end - it 'handles paths with .. and .' do - expect(Chef::ChefFS::PathUtils.realest_path(good_path+'/../.')).to eq(File.expand_path(parent_path)) + it "handles paths with .. and ." do + expect(Chef::ChefFS::PathUtils.realest_path(good_path+"/../.")).to eq(File.expand_path(parent_path)) end - it 'handles paths with *' do - expect(Chef::ChefFS::PathUtils.realest_path(good_path + '/*/foo')).to eq(File.expand_path(good_path + '/*/foo')) + it "handles paths with *" do + expect(Chef::ChefFS::PathUtils.realest_path(good_path + "/*/foo")).to eq(File.expand_path(good_path + "/*/foo")) end - it 'handles directories that do not exist' do - expect(Chef::ChefFS::PathUtils.realest_path(good_path + '/something/or/other')).to eq(File.expand_path(good_path + '/something/or/other')) + it "handles directories that do not exist" do + expect(Chef::ChefFS::PathUtils.realest_path(good_path + "/something/or/other")).to eq(File.expand_path(good_path + "/something/or/other")) end - it 'handles root correctly' do + it "handles root correctly" do if Chef::Platform.windows? - expect(Chef::ChefFS::PathUtils.realest_path('C:/')).to eq('C:/') + expect(Chef::ChefFS::PathUtils.realest_path("C:/")).to eq("C:/") else - expect(Chef::ChefFS::PathUtils.realest_path('/')).to eq('/') + expect(Chef::ChefFS::PathUtils.realest_path("/")).to eq("/") end end end - context 'invoking descendant_path' do - it 'handles paths with various casing on windows' do + context "invoking descendant_path" do + it "handles paths with various casing on windows" do allow(Chef::ChefFS).to receive(:windows?) { true } - expect(Chef::ChefFS::PathUtils.descendant_path('C:/ab/b/c', 'C:/AB/B')).to eq('c') - expect(Chef::ChefFS::PathUtils.descendant_path('C:/ab/b/c', 'c:/ab/B')).to eq('c') + expect(Chef::ChefFS::PathUtils.descendant_path("C:/ab/b/c", "C:/AB/B")).to eq("c") + expect(Chef::ChefFS::PathUtils.descendant_path("C:/ab/b/c", "c:/ab/B")).to eq("c") end - it 'returns nil if the path does not have the given ancestor' do - expect(Chef::ChefFS::PathUtils.descendant_path('/D/E/F', '/A/B/C')).to be_nil - expect(Chef::ChefFS::PathUtils.descendant_path('/A/B/D', '/A/B/C')).to be_nil + it "returns nil if the path does not have the given ancestor" do + expect(Chef::ChefFS::PathUtils.descendant_path("/D/E/F", "/A/B/C")).to be_nil + expect(Chef::ChefFS::PathUtils.descendant_path("/A/B/D", "/A/B/C")).to be_nil end - it 'returns blank if the ancestor equals the path' do - expect(Chef::ChefFS::PathUtils.descendant_path('/A/B/D', '/A/B/D')).to eq('') + it "returns blank if the ancestor equals the path" do + expect(Chef::ChefFS::PathUtils.descendant_path("/A/B/D", "/A/B/D")).to eq("") end end end diff --git a/spec/unit/chef_spec.rb b/spec/unit/chef_spec.rb index 8a8d6c6c68..b2be2af5f3 100644 --- a/spec/unit/chef_spec.rb +++ b/spec/unit/chef_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef do it "should have a version defined" do diff --git a/spec/unit/client_spec.rb b/spec/unit/client_spec.rb index ca7440061e..e41c092ae5 100644 --- a/spec/unit/client_spec.rb +++ b/spec/unit/client_spec.rb @@ -18,13 +18,13 @@ # limitations under the License. # -require 'spec_helper' -require 'spec/support/shared/context/client' -require 'spec/support/shared/examples/client' +require "spec_helper" +require "spec/support/shared/context/client" +require "spec/support/shared/examples/client" -require 'chef/run_context' -require 'chef/server_api' -require 'rbconfig' +require "chef/run_context" +require "chef/server_api" +require "rbconfig" class FooError < RuntimeError end @@ -157,7 +157,7 @@ describe Chef::Client do context "when an override run list is given" do it "permits spaces in overriding run list" do - Chef::Client.new(nil, :override_runlist => 'role[a], role[b]') + Chef::Client.new(nil, :override_runlist => "role[a], role[b]") end describe "calling run" do @@ -220,7 +220,7 @@ describe Chef::Client do describe "when converge completes successfully" do include_context "a client run" include_context "converge completed" - context 'when audit mode is enabled' do + context "when audit mode is enabled" do describe "when audit phase errors" do include_context "audit phase failed with error" include_examples "a completed run with audit failure" do @@ -500,7 +500,7 @@ describe Chef::Client do allow_any_instance_of(Chef::RunLock).to receive(:save_pid).and_raise(NoMethodError) end - context 'when audit mode is enabled' do + context "when audit mode is enabled" do before do Chef::Config[:audit_mode] = :enabled end @@ -513,7 +513,7 @@ describe Chef::Client do end end - context 'when audit mode is disabled' do + context "when audit mode is disabled" do before do Chef::Config[:audit_mode] = :disabled end diff --git a/spec/unit/config_fetcher_spec.rb b/spec/unit/config_fetcher_spec.rb index 1b4a4903a8..417087d9a3 100644 --- a/spec/unit/config_fetcher_spec.rb +++ b/spec/unit/config_fetcher_spec.rb @@ -1,5 +1,5 @@ -require 'spec_helper' -require 'chef/config_fetcher' +require "spec_helper" +require "chef/config_fetcher" describe Chef::ConfigFetcher do let(:valid_json) { Chef::JSONCompat.to_json({:a=>"b"}) } diff --git a/spec/unit/config_spec.rb b/spec/unit/config_spec.rb index 8d155c61ab..68cb589251 100644 --- a/spec/unit/config_spec.rb +++ b/spec/unit/config_spec.rb @@ -1,7 +1,7 @@ -require 'spec_helper' +require "spec_helper" -require 'chef/config' +require "chef/config" RSpec.describe Chef::Config do diff --git a/spec/unit/cookbook/chefignore_spec.rb b/spec/unit/cookbook/chefignore_spec.rb index 9f5546de28..9d81981dcf 100644 --- a/spec/unit/cookbook/chefignore_spec.rb +++ b/spec/unit/cookbook/chefignore_spec.rb @@ -15,11 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Cookbook::Chefignore do before do - @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, 'cookbooks')) + @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, "cookbooks")) end it "loads the globs in the chefignore file" do @@ -32,14 +32,14 @@ describe Chef::Cookbook::Chefignore do end it "determines if a file is ignored" do - expect(@chefignore.ignored?('ignored')).to be_truthy - expect(@chefignore.ignored?('recipes/ignoreme.rb')).to be_truthy - expect(@chefignore.ignored?('recipes/dontignoreme.rb')).to be_falsey + expect(@chefignore.ignored?("ignored")).to be_truthy + expect(@chefignore.ignored?("recipes/ignoreme.rb")).to be_truthy + expect(@chefignore.ignored?("recipes/dontignoreme.rb")).to be_falsey end context "when using the single cookbook pattern" do before do - @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, 'standalone_cookbook')) + @chefignore = Chef::Cookbook::Chefignore.new(File.join(CHEF_SPEC_DATA, "standalone_cookbook")) end it "loads the globs in the chefignore file" do diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb index 23ffc21f7f..1a0c1ddf94 100644 --- a/spec/unit/cookbook/cookbook_version_loader_spec.rb +++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Cookbook::CookbookVersionLoader do before do @@ -58,8 +58,8 @@ describe Chef::Cookbook::CookbookVersionLoader do end it "loads libraries" do - expect(loaded_cookbook.library_filenames).to include(full_path('/libraries/openldap.rb')) - expect(loaded_cookbook.library_filenames).to include(full_path('/libraries/openldap/version.rb')) + expect(loaded_cookbook.library_filenames).to include(full_path("/libraries/openldap.rb")) + expect(loaded_cookbook.library_filenames).to include(full_path("/libraries/openldap/version.rb")) end it "loads static files in the files/ dir" do diff --git a/spec/unit/cookbook/file_vendor_spec.rb b/spec/unit/cookbook/file_vendor_spec.rb index 8bf2d3c2a3..2420718dea 100644 --- a/spec/unit/cookbook/file_vendor_spec.rb +++ b/spec/unit/cookbook/file_vendor_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Cookbook::FileVendor do diff --git a/spec/unit/cookbook/metadata_spec.rb b/spec/unit/cookbook/metadata_spec.rb index 48b0b2a059..ad4863ad3d 100644 --- a/spec/unit/cookbook/metadata_spec.rb +++ b/spec/unit/cookbook/metadata_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/cookbook/metadata' +require "spec_helper" +require "chef/cookbook/metadata" describe Chef::Cookbook::Metadata do @@ -142,11 +142,11 @@ describe Chef::Cookbook::Metadata do end it "has an empty source_url string" do - expect(metadata.source_url).to eq('') + expect(metadata.source_url).to eq("") end it "has an empty issues_url string" do - expect(metadata.issues_url).to eq('') + expect(metadata.issues_url).to eq("") end it "is not private" do @@ -189,7 +189,7 @@ describe Chef::Cookbook::Metadata do describe "adding a supported platform" do it "should support adding a supported platform with a single expression" do metadata.supports("ubuntu", ">= 8.04") - expect(metadata.platforms["ubuntu"]).to eq('>= 8.04') + expect(metadata.platforms["ubuntu"]).to eq(">= 8.04") end end @@ -311,17 +311,17 @@ describe Chef::Cookbook::Metadata do end it "strips out self-dependencies", :chef_lt_13_only do - metadata.name('foo') + metadata.name("foo") expect(Chef::Log).to receive(:warn).with( "Ignoring self-dependency in cookbook foo, please remove it (in the future this will be fatal)." ) - metadata.depends('foo') + metadata.depends("foo") expect(metadata.dependencies).to eql({}) end it "errors on self-dependencies", :chef_gte_13_only do - metadata.name('foo') - expect { metadata.depends('foo') }.to raise_error + metadata.name("foo") + expect { metadata.depends("foo") }.to raise_error # FIXME: add the error type end end @@ -462,10 +462,10 @@ describe Chef::Cookbook::Metadata do attrs = { "display_name" => "MySQL Databases", "description" => "Description of MySQL", - "choice" => ['dedicated', 'shared'], + "choice" => ["dedicated", "shared"], "calculated" => false, - "type" => 'string', - "required" => 'recommended', + "type" => "string", + "required" => "recommended", "recipes" => [ "mysql::server", "mysql::master" ], "default" => [ ], "source_url" => "http://example.com", @@ -519,16 +519,16 @@ describe Chef::Cookbook::Metadata do metadata.attribute("db/mysql/databases", :privacy => false) }.not_to raise_error expect { - metadata.attribute("db/mysql/databases", :privacy => 'true') + metadata.attribute("db/mysql/databases", :privacy => "true") }.to raise_error(ArgumentError) end it "should not accept anything but an array of strings for choice" do expect { - metadata.attribute("db/mysql/databases", :choice => ['dedicated', 'shared']) + metadata.attribute("db/mysql/databases", :choice => ["dedicated", "shared"]) }.not_to raise_error expect { - metadata.attribute("db/mysql/databases", :choice => [10, 'shared']) + metadata.attribute("db/mysql/databases", :choice => [10, "shared"]) }.to raise_error(ArgumentError) expect { metadata.attribute("db/mysql/databases", :choice => Hash.new) @@ -586,13 +586,13 @@ describe Chef::Cookbook::Metadata do it "should let required be required, recommended or optional" do expect { - metadata.attribute("db/mysql/databases", :required => 'required') + metadata.attribute("db/mysql/databases", :required => "required") }.not_to raise_error expect { - metadata.attribute("db/mysql/databases", :required => 'recommended') + metadata.attribute("db/mysql/databases", :required => "recommended") }.not_to raise_error expect { - metadata.attribute("db/mysql/databases", :required => 'optional') + metadata.attribute("db/mysql/databases", :required => "optional") }.not_to raise_error end @@ -612,7 +612,7 @@ describe Chef::Cookbook::Metadata do it "should set required to 'optional' by default" do metadata.attribute("db/mysql/databases", {}) - expect(metadata.attributes["db/mysql/databases"][:required]).to eq('optional') + expect(metadata.attributes["db/mysql/databases"][:required]).to eq("optional") end it "should make sure recipes is an array" do @@ -742,7 +742,7 @@ describe Chef::Cookbook::Metadata do describe "recipes" do let(:cookbook) do - c = Chef::CookbookVersion.new('test_cookbook') + c = Chef::CookbookVersion.new("test_cookbook") c.recipe_files = [ "default.rb", "enlighten.rb" ] c end @@ -894,13 +894,13 @@ describe Chef::Cookbook::Metadata do it "should transform deprecated greater than syntax for :#{to_check}" do @hash[to_check.to_s]["foo::bar"] = ">> 0.2" deserial = Chef::Cookbook::Metadata.from_hash(@hash) - expect(deserial.send(to_check)["foo::bar"]).to eq('> 0.2') + expect(deserial.send(to_check)["foo::bar"]).to eq("> 0.2") end it "should transform deprecated less than syntax for :#{to_check}" do @hash[to_check.to_s]["foo::bar"] = "<< 0.2" deserial = Chef::Cookbook::Metadata.from_hash(@hash) - expect(deserial.send(to_check)["foo::bar"]).to eq('< 0.2') + expect(deserial.send(to_check)["foo::bar"]).to eq("< 0.2") end it "should ignore multiple dependency constraints for :#{to_check}" do diff --git a/spec/unit/cookbook/synchronizer_spec.rb b/spec/unit/cookbook/synchronizer_spec.rb index 30ddaad1d7..17803a8392 100644 --- a/spec/unit/cookbook/synchronizer_spec.rb +++ b/spec/unit/cookbook/synchronizer_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper' -require 'chef/cookbook/synchronizer' -require 'chef/cookbook_version' +require "spec_helper" +require "chef/cookbook/synchronizer" +require "chef/cookbook_version" describe Chef::CookbookCacheCleaner do describe "when cleaning up unused cookbook components" do @@ -164,8 +164,8 @@ describe Chef::CookbookSynchronizer do valid_cached_cb_files = %w{cookbooks/valid1/recipes/default.rb cookbooks/valid2/recipes/default.rb} obsolete_cb_files = %w{cookbooks/old1/recipes/default.rb cookbooks/old2/recipes/default.rb} expect(file_cache).to receive(:find).with(File.join(%w{cookbooks ** {*,.*}})).and_return(valid_cached_cb_files + obsolete_cb_files) - expect(file_cache).to receive(:delete).with('cookbooks/old1/recipes/default.rb') - expect(file_cache).to receive(:delete).with('cookbooks/old2/recipes/default.rb') + expect(file_cache).to receive(:delete).with("cookbooks/old1/recipes/default.rb") + expect(file_cache).to receive(:delete).with("cookbooks/old2/recipes/default.rb") allow(synchronizer).to receive(:cache).and_return(file_cache) synchronizer.remove_old_cookbooks end @@ -186,7 +186,7 @@ describe Chef::CookbookSynchronizer do expect(synchronizer).to receive(:have_cookbook?).with("valid1").at_least(:once).and_return(true) # valid2 is a cookbook not in our run_list (we're simulating an override run_list where valid2 needs to be preserved) expect(synchronizer).to receive(:have_cookbook?).with("valid2").at_least(:once).and_return(false) - expect(file_cache).to receive(:delete).with('cookbooks/valid1/recipes/deleted.rb') + expect(file_cache).to receive(:delete).with("cookbooks/valid1/recipes/deleted.rb") expect(synchronizer).to receive(:cookbook_segment).with("valid1", "recipes").at_least(:once).and_return([ { "path" => "recipes/default.rb" }]) allow(synchronizer).to receive(:cache).and_return(file_cache) synchronizer.remove_deleted_files @@ -224,7 +224,7 @@ describe Chef::CookbookSynchronizer do # Fetch and copy default.rb recipe expect(server_api).to receive(:streaming_request). - with('http://chef.example.com/abc123'). + with("http://chef.example.com/abc123"). and_return(cookbook_a_default_recipe_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb") @@ -234,7 +234,7 @@ describe Chef::CookbookSynchronizer do # Fetch and copy default.rb attribute file expect(server_api).to receive(:streaming_request). - with('http://chef.example.com/abc456'). + with("http://chef.example.com/abc456"). and_return(cookbook_a_default_attribute_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb") @@ -252,7 +252,7 @@ describe Chef::CookbookSynchronizer do and_return(false) expect(server_api).to receive(:streaming_request). - with('http://chef.example.com/megaman.conf'). + with("http://chef.example.com/megaman.conf"). and_return(cookbook_a_file_default_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf") @@ -261,7 +261,7 @@ describe Chef::CookbookSynchronizer do and_return("/file-cache/cookbooks/cookbook_a/default/megaman.conf") expect(server_api).to receive(:streaming_request). - with('http://chef.example.com/ffffff'). + with("http://chef.example.com/ffffff"). and_return(cookbook_a_template_default_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb") @@ -281,7 +281,7 @@ describe Chef::CookbookSynchronizer do # Fetch and copy default.rb recipe expect(server_api).to receive(:streaming_request). - with('http://chef.example.com/abc123'). + with("http://chef.example.com/abc123"). and_return(cookbook_a_default_recipe_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_recipes_default_rb", "cookbooks/cookbook_a/recipes/default.rb") @@ -297,7 +297,7 @@ describe Chef::CookbookSynchronizer do # Fetch and copy default.rb attribute file expect(server_api).to receive(:streaming_request). - with('http://chef.example.com/abc456'). + with("http://chef.example.com/abc456"). and_return(cookbook_a_default_attribute_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_attributes_default_rb", "cookbooks/cookbook_a/attributes/default.rb") @@ -323,7 +323,7 @@ describe Chef::CookbookSynchronizer do # Fetch and copy megaman.conf expect(server_api).to receive(:streaming_request). - with('http://chef.example.com/megaman.conf'). + with("http://chef.example.com/megaman.conf"). and_return(cookbook_a_file_default_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_file_default_tempfile", "cookbooks/cookbook_a/files/default/megaman.conf") @@ -334,7 +334,7 @@ describe Chef::CookbookSynchronizer do # Fetch and copy apache2.conf template expect(server_api).to receive(:streaming_request). - with('http://chef.example.com/ffffff'). + with("http://chef.example.com/ffffff"). and_return(cookbook_a_template_default_tempfile) expect(file_cache).to receive(:move_to). with("/tmp/cookbook_a_template_default_tempfile", "cookbooks/cookbook_a/templates/default/apache2.conf.erb") @@ -442,7 +442,7 @@ describe Chef::CookbookSynchronizer do it "does not fetch templates or cookbook files" do # Implicitly tested in previous test; this test is just for behavior specification. expect(server_api).not_to receive(:streaming_request). - with('http://chef.example.com/ffffff') + with("http://chef.example.com/ffffff") synchronizer.sync_cookbooks end diff --git a/spec/unit/cookbook/syntax_check_spec.rb b/spec/unit/cookbook/syntax_check_spec.rb index efdb5b7926..ad270ae712 100644 --- a/spec/unit/cookbook/syntax_check_spec.rb +++ b/spec/unit/cookbook/syntax_check_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" require "chef/cookbook/syntax_check" describe Chef::Cookbook::SyntaxCheck do @@ -24,7 +24,7 @@ describe Chef::Cookbook::SyntaxCheck do allow(ChefConfig).to receive(:windows?) { false } end - let(:cookbook_path) { File.join(CHEF_SPEC_DATA, 'cookbooks', 'openldap') } + let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "cookbooks", "openldap") } let(:syntax_check) { Chef::Cookbook::SyntaxCheck.new(cookbook_path) } let(:open_ldap_cookbook_files) do @@ -46,10 +46,10 @@ describe Chef::Cookbook::SyntaxCheck do @original_log_level = Chef::Log.level Chef::Log.level = :warn # suppress "Syntax OK" messages - @attr_files = %w{default.rb smokey.rb}.map { |f| File.join(cookbook_path, 'attributes', f) } - @libr_files = %w{openldap.rb openldap/version.rb}.map { |f| File.join(cookbook_path, 'libraries', f) } - @defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, 'definitions', f)} - @recipes = %w{default.rb gigantor.rb one.rb return.rb}.map { |f| File.join(cookbook_path, 'recipes', f) } + @attr_files = %w{default.rb smokey.rb}.map { |f| File.join(cookbook_path, "attributes", f) } + @libr_files = %w{openldap.rb openldap/version.rb}.map { |f| File.join(cookbook_path, "libraries", f) } + @defn_files = %w{client.rb server.rb}.map { |f| File.join(cookbook_path, "definitions", f)} + @recipes = %w{default.rb gigantor.rb one.rb return.rb}.map { |f| File.join(cookbook_path, "recipes", f) } @ruby_files = @attr_files + @libr_files + @defn_files + @recipes + [File.join(cookbook_path, "metadata.rb")] basenames = %w{ helpers_via_partial_test.erb helper_test.erb @@ -62,7 +62,7 @@ describe Chef::Cookbook::SyntaxCheck do some_windows_line_endings.erb all_windows_line_endings.erb no_windows_line_endings.erb } - @template_files = basenames.map { |f| File.join(cookbook_path, 'templates', 'default', f)} + @template_files = basenames.map { |f| File.join(cookbook_path, "templates", "default", f)} end after do @@ -77,18 +77,18 @@ describe Chef::Cookbook::SyntaxCheck do end it "creates a syntax checker given the cookbook name and cookbook_path" do - syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:openldap, File.join(CHEF_SPEC_DATA, 'cookbooks')) + syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:openldap, File.join(CHEF_SPEC_DATA, "cookbooks")) expect(syntax_check.cookbook_path).to eq(cookbook_path) expect(syntax_check.ruby_files.sort).to eq(open_ldap_cookbook_files.sort) end context "when using a standalone cookbook" do - let(:cookbook_path) { File.join(CHEF_SPEC_DATA, 'standalone_cookbook') } + let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "standalone_cookbook") } it "creates a syntax checker given the cookbook name and cookbook_path for a standalone cookbook" do syntax_check = Chef::Cookbook::SyntaxCheck.for_cookbook(:standalone_cookbook, CHEF_SPEC_DATA) expect(syntax_check.cookbook_path).to eq(cookbook_path) - expect(syntax_check.ruby_files).to eq([File.join(cookbook_path, 'recipes/default.rb')]) + expect(syntax_check.ruby_files).to eq([File.join(cookbook_path, "recipes/default.rb")]) end end @@ -128,13 +128,13 @@ describe Chef::Cookbook::SyntaxCheck do end it "removes a ruby file from the list of untested files after it is marked as validated" do - recipe = File.join(cookbook_path, 'recipes', 'default.rb') + recipe = File.join(cookbook_path, "recipes", "default.rb") syntax_check.validated(recipe) expect(syntax_check.untested_ruby_files).not_to include(recipe) end it "removes a template file from the list of untested files after it is marked as validated" do - template = File.join(cookbook_path, 'templates', 'default', 'test.erb') + template = File.join(cookbook_path, "templates", "default", "test.erb") syntax_check.validated(template) expect(syntax_check.untested_template_files).not_to include(template) end @@ -151,7 +151,7 @@ describe Chef::Cookbook::SyntaxCheck do describe "and a file has a syntax error" do before do - cookbook_path = File.join(CHEF_SPEC_DATA, 'cookbooks', 'borken') + cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks", "borken") syntax_check.cookbook_path.replace(cookbook_path) end @@ -160,9 +160,9 @@ describe Chef::Cookbook::SyntaxCheck do end it "does not remove the invalid file from the list of untested files" do - expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, 'recipes', 'default.rb')) + expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, "recipes", "default.rb")) syntax_check.validate_ruby_files - expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, 'recipes', 'default.rb')) + expect(syntax_check.untested_ruby_files).to include(File.join(cookbook_path, "recipes", "default.rb")) end it "indicates that a template file has a syntax error" do @@ -170,7 +170,7 @@ describe Chef::Cookbook::SyntaxCheck do end it "does not remove the invalid template from the list of untested templates" do - expect(syntax_check.untested_template_files).to include(File.join(cookbook_path, 'templates', 'default', 'borken.erb')) + expect(syntax_check.untested_template_files).to include(File.join(cookbook_path, "templates", "default", "borken.erb")) expect {syntax_check.validate_templates}.not_to change(syntax_check, :untested_template_files) end @@ -178,10 +178,10 @@ describe Chef::Cookbook::SyntaxCheck do describe "and an ignored file has a syntax error" do before do - cookbook_path = File.join(CHEF_SPEC_DATA, 'cookbooks', 'ignorken') + cookbook_path = File.join(CHEF_SPEC_DATA, "cookbooks", "ignorken") Chef::Config[:cookbook_path] = File.dirname(cookbook_path) syntax_check.cookbook_path.replace(cookbook_path) - @ruby_files = [File.join(cookbook_path, 'metadata.rb'), File.join(cookbook_path, 'recipes/default.rb')] + @ruby_files = [File.join(cookbook_path, "metadata.rb"), File.join(cookbook_path, "recipes/default.rb")] end it "shows that ignored ruby files do not require a syntax check" do diff --git a/spec/unit/cookbook_loader_spec.rb b/spec/unit/cookbook_loader_spec.rb index 8d4413105d..36060cde99 100644 --- a/spec/unit/cookbook_loader_spec.rb +++ b/spec/unit/cookbook_loader_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::CookbookLoader do before do @@ -223,7 +223,7 @@ describe Chef::CookbookLoader do end it "should not load the cookbook again when accessed" do - expect(cookbook_loader).not_to receive('load_cookbook') + expect(cookbook_loader).not_to receive("load_cookbook") cookbook_loader["openldap"] end diff --git a/spec/unit/cookbook_manifest_spec.rb b/spec/unit/cookbook_manifest_spec.rb index f985942e09..8b7cf1fc7e 100644 --- a/spec/unit/cookbook_manifest_spec.rb +++ b/spec/unit/cookbook_manifest_spec.rb @@ -15,10 +15,10 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' -require 'chef/cookbook_manifest' -require 'chef/digester' -require 'pathname' +require "spec_helper" +require "chef/cookbook_manifest" +require "chef/digester" +require "pathname" describe Chef::CookbookManifest do @@ -32,7 +32,7 @@ describe Chef::CookbookManifest do end end - let(:cookbook_root) { '/tmp/blah' } + let(:cookbook_root) { "/tmp/blah" } let(:cookbook_version) do Chef::CookbookVersion.new("tatft", cookbook_root).tap do |c| @@ -62,7 +62,7 @@ describe Chef::CookbookManifest do end it "delegates `root_paths' to cookbook_version" do - expect(cookbook_manifest.root_paths).to eq(['/tmp/blah']) + expect(cookbook_manifest.root_paths).to eq(["/tmp/blah"]) end it "delegates `metadata' to cookbook_version" do @@ -121,18 +121,18 @@ describe Chef::CookbookManifest do context "when given a cookbook with files" do - let(:cookbook_root) { File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'tatft') } - - let(:attribute_filenames) { Dir[File.join(cookbook_root, 'attributes', '**', '*.rb')] } - let(:definition_filenames) { Dir[File.join(cookbook_root, 'definitions', '**', '*.rb')] } - let(:file_filenames) { Dir[File.join(cookbook_root, 'files', '**', '*.tgz')] } - let(:recipe_filenames) { Dir[File.join(cookbook_root, 'recipes', '**', '*.rb')] } - let(:template_filenames) { Dir[File.join(cookbook_root, 'templates', '**', '*.erb')] } - let(:library_filenames) { Dir[File.join(cookbook_root, 'libraries', '**', '*.rb')] } - let(:resource_filenames) { Dir[File.join(cookbook_root, 'resources', '**', '*.rb')] } - let(:provider_filenames) { Dir[File.join(cookbook_root, 'providers', '**', '*.rb')] } - let(:root_filenames) { Array(File.join(cookbook_root, 'README.rdoc')) } - let(:metadata_filenames) { Array(File.join(cookbook_root, 'metadata.json')) } + let(:cookbook_root) { File.join(CHEF_SPEC_DATA, "cb_version_cookbooks", "tatft") } + + let(:attribute_filenames) { Dir[File.join(cookbook_root, "attributes", "**", "*.rb")] } + let(:definition_filenames) { Dir[File.join(cookbook_root, "definitions", "**", "*.rb")] } + let(:file_filenames) { Dir[File.join(cookbook_root, "files", "**", "*.tgz")] } + let(:recipe_filenames) { Dir[File.join(cookbook_root, "recipes", "**", "*.rb")] } + let(:template_filenames) { Dir[File.join(cookbook_root, "templates", "**", "*.erb")] } + let(:library_filenames) { Dir[File.join(cookbook_root, "libraries", "**", "*.rb")] } + let(:resource_filenames) { Dir[File.join(cookbook_root, "resources", "**", "*.rb")] } + let(:provider_filenames) { Dir[File.join(cookbook_root, "providers", "**", "*.rb")] } + let(:root_filenames) { Array(File.join(cookbook_root, "README.rdoc")) } + let(:metadata_filenames) { Array(File.join(cookbook_root, "metadata.json")) } let(:match_md5) { /[0-9a-f]{32}/ } diff --git a/spec/unit/cookbook_site_streaming_uploader_spec.rb b/spec/unit/cookbook_site_streaming_uploader_spec.rb index 07069810dd..bc01962a01 100644 --- a/spec/unit/cookbook_site_streaming_uploader_spec.rb +++ b/spec/unit/cookbook_site_streaming_uploader_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/cookbook_site_streaming_uploader' +require "chef/cookbook_site_streaming_uploader" class FakeTempfile def initialize(basename) @@ -39,7 +39,7 @@ describe Chef::CookbookSiteStreamingUploader do describe "create_build_dir" do before(:each) do - @cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, 'cookbooks')) + @cookbook_repo = File.expand_path(File.join(CHEF_SPEC_DATA, "cookbooks")) @loader = Chef::CookbookLoader.new(@cookbook_repo) @loader.load_cookbooks allow(File).to receive(:unlink) @@ -47,7 +47,7 @@ describe Chef::CookbookSiteStreamingUploader do it "should create the cookbook tmp dir" do cookbook = @loader[:openldap] - files_count = Dir.glob(File.join(@cookbook_repo, cookbook.name.to_s, '**', '*'), File::FNM_DOTMATCH).count { |file| File.file?(file) } + files_count = Dir.glob(File.join(@cookbook_repo, cookbook.name.to_s, "**", "*"), File::FNM_DOTMATCH).count { |file| File.file?(file) } expect(Tempfile).to receive(:new).with("chef-#{cookbook.name}-build").and_return(FakeTempfile.new("chef-#{cookbook.name}-build")) expect(FileUtils).to receive(:mkdir_p).exactly(files_count + 1).times @@ -61,25 +61,25 @@ describe Chef::CookbookSiteStreamingUploader do before(:each) do @uri = "http://cookbooks.dummy.com/api/v1/cookbooks" - @secret_filename = File.join(CHEF_SPEC_DATA, 'ssl/private_key.pem') + @secret_filename = File.join(CHEF_SPEC_DATA, "ssl/private_key.pem") @rsa_key = File.read(@secret_filename) - response = Net::HTTPResponse.new('1.0', '200', 'OK') + response = Net::HTTPResponse.new("1.0", "200", "OK") allow_any_instance_of(Net::HTTP).to receive(:request).and_return(response) end it "should send an http request" do expect_any_instance_of(Net::HTTP).to receive(:request) - Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, 'bill', @secret_filename) + Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename) end it "should read the private key file" do expect(File).to receive(:read).with(@secret_filename).and_return(@rsa_key) - Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, 'bill', @secret_filename) + Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename) end it "should add the authentication signed header" do expect_any_instance_of(Mixlib::Authentication::SigningObject).to receive(:sign).and_return({}) - Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, 'bill', @secret_filename) + Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename) end it "should be able to send post requests" do @@ -88,7 +88,7 @@ describe Chef::CookbookSiteStreamingUploader do expect(Net::HTTP::Post).to receive(:new).once.and_return(post) expect(Net::HTTP::Put).not_to receive(:new) expect(Net::HTTP::Get).not_to receive(:new) - Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, 'bill', @secret_filename) + Chef::CookbookSiteStreamingUploader.make_request(:post, @uri, "bill", @secret_filename) end it "should be able to send put requests" do @@ -97,27 +97,27 @@ describe Chef::CookbookSiteStreamingUploader do expect(Net::HTTP::Post).not_to receive(:new) expect(Net::HTTP::Put).to receive(:new).once.and_return(put) expect(Net::HTTP::Get).not_to receive(:new) - Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, 'bill', @secret_filename) + Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename) end it "should be able to receive files to attach as argument" do - Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, 'bill', @secret_filename, { - :myfile => File.new(File.join(CHEF_SPEC_DATA, 'config.rb')), # a dummy file + Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, { + :myfile => File.new(File.join(CHEF_SPEC_DATA, "config.rb")), # a dummy file }) end it "should be able to receive strings to attach as argument" do - Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, 'bill', @secret_filename, { - :mystring => 'Lorem ipsum' + Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, { + :mystring => "Lorem ipsum" }) end it "should be able to receive strings and files as argument at the same time" do - Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, 'bill', @secret_filename, { - :myfile1 => File.new(File.join(CHEF_SPEC_DATA, 'config.rb')), - :mystring1 => 'Lorem ipsum', - :myfile2 => File.new(File.join(CHEF_SPEC_DATA, 'config.rb')), - :mystring2 => 'Dummy text', + Chef::CookbookSiteStreamingUploader.make_request(:put, @uri, "bill", @secret_filename, { + :myfile1 => File.new(File.join(CHEF_SPEC_DATA, "config.rb")), + :mystring1 => "Lorem ipsum", + :myfile2 => File.new(File.join(CHEF_SPEC_DATA, "config.rb")), + :mystring2 => "Dummy text", }) end @@ -125,7 +125,7 @@ describe Chef::CookbookSiteStreamingUploader do describe "StreamPart" do before(:each) do - @file = File.new(File.join(CHEF_SPEC_DATA, 'config.rb')) + @file = File.new(File.join(CHEF_SPEC_DATA, "config.rb")) @stream_part = Chef::CookbookSiteStreamingUploader::StreamPart.new(@file, File.size(@file)) end @@ -147,7 +147,7 @@ describe Chef::CookbookSiteStreamingUploader do describe "StringPart" do before(:each) do - @str = 'What a boring string' + @str = "What a boring string" @string_part = Chef::CookbookSiteStreamingUploader::StringPart.new(@str) end @@ -189,7 +189,7 @@ describe Chef::CookbookSiteStreamingUploader do end it "should read receiving destination buffer as second argument (CHEF-4456: Ruby 2 compat)" do - dst_buf = '' + dst_buf = "" @multipart_stream.read(10, dst_buf) expect(dst_buf).to eql("#{@string1}#{@string2}"[0, 10]) end diff --git a/spec/unit/cookbook_spec.rb b/spec/unit/cookbook_spec.rb index f36b031309..dac65a4bf4 100644 --- a/spec/unit/cookbook_spec.rb +++ b/spec/unit/cookbook_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::CookbookVersion do # COOKBOOK_PATH = File.expand_path(File.join(File.dirname(__FILE__), "..", "data", "cookbooks", "openldap")) diff --git a/spec/unit/cookbook_uploader_spec.rb b/spec/unit/cookbook_uploader_spec.rb index b74d08f620..19fce12a52 100644 --- a/spec/unit/cookbook_uploader_spec.rb +++ b/spec/unit/cookbook_uploader_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::CookbookUploader do diff --git a/spec/unit/cookbook_version_file_specificity_spec.rb b/spec/unit/cookbook_version_file_specificity_spec.rb index ff79573113..6aaf68b251 100644 --- a/spec/unit/cookbook_version_file_specificity_spec.rb +++ b/spec/unit/cookbook_version_file_specificity_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::CookbookVersion, "file specificity" do before(:each) do @@ -444,7 +444,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.host', 'anotherfile2.rb.host']) + expect(filenames.sort).to eq(["anotherfile1.rb.host", "anotherfile2.rb.host"]) end it "should return a list of relative paths based on priority preference: platform & full version" do @@ -457,7 +457,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.platform-full-version', 'anotherfile2.rb.platform-full-version']) + expect(filenames.sort).to eq(["anotherfile1.rb.platform-full-version", "anotherfile2.rb.platform-full-version"]) end it "should return a list of relative paths based on priority preference: platform & partial version" do @@ -470,7 +470,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.platform-partial-version', 'anotherfile2.rb.platform-partial-version']) + expect(filenames.sort).to eq(["anotherfile1.rb.platform-partial-version", "anotherfile2.rb.platform-partial-version"]) end it "should return a list of relative paths based on priority preference: platform only" do @@ -483,7 +483,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.platform', 'anotherfile2.rb.platform']) + expect(filenames.sort).to eq(["anotherfile1.rb.platform", "anotherfile2.rb.platform"]) end it "should return a list of relative paths based on priority preference: default" do @@ -496,7 +496,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.default', 'anotherfile2.rb.default']) + expect(filenames.sort).to eq(["anotherfile1.rb.default", "anotherfile2.rb.default"]) end it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 1" do @@ -509,7 +509,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.platform-full-version', 'anotherfile2.rb.platform-full-version']) + expect(filenames.sort).to eq(["anotherfile1.rb.platform-full-version", "anotherfile2.rb.platform-full-version"]) end it "should return a list of relative paths based on priority preference: platform & partial version - platform_version variant 1" do @@ -522,7 +522,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.platform-partial-version', 'anotherfile2.rb.platform-partial-version']) + expect(filenames.sort).to eq(["anotherfile1.rb.platform-partial-version", "anotherfile2.rb.platform-partial-version"]) end it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 2" do @@ -535,7 +535,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.platform-full-version', 'anotherfile2.rb.platform-full-version']) + expect(filenames.sort).to eq(["anotherfile1.rb.platform-full-version", "anotherfile2.rb.platform-full-version"]) end it "should return a list of relative paths based on priority preference: platform & full version - platform_version variant 3" do @@ -548,7 +548,7 @@ describe Chef::CookbookVersion, "file specificity" do expect(filenames).not_to be_nil expect(filenames.size).to eq(2) - expect(filenames.sort).to eq(['anotherfile1.rb.platform-full-version', 'anotherfile2.rb.platform-full-version']) + expect(filenames.sort).to eq(["anotherfile1.rb.platform-full-version", "anotherfile2.rb.platform-full-version"]) end end end diff --git a/spec/unit/cookbook_version_spec.rb b/spec/unit/cookbook_version_spec.rb index e248267eab..856dc00006 100644 --- a/spec/unit/cookbook_version_spec.rb +++ b/spec/unit/cookbook_version_spec.rb @@ -15,16 +15,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" describe Chef::CookbookVersion do describe "when first created" do before do - @cookbook_version = Chef::CookbookVersion.new("tatft", '/tmp/blah') + @cookbook_version = Chef::CookbookVersion.new("tatft", "/tmp/blah") end it "has a name" do - expect(@cookbook_version.name).to eq('tatft') + expect(@cookbook_version.name).to eq("tatft") end it "has no attribute files" do @@ -80,26 +80,26 @@ describe Chef::CookbookVersion do before do @cookbook = Hash.new { |hash, key| hash[key] = [] } - @cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'tatft') + @cookbook_root = File.join(CHEF_SPEC_DATA, "cb_version_cookbooks", "tatft") # Dunno if the paths here are representitive of what is set by CookbookLoader... - @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, 'attributes', '**', '*.rb')] - @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, 'definitions', '**', '*.rb')] - @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, 'files', '**', '*.tgz')] - @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, 'recipes', '**', '*.rb')] - @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, 'templates', '**', '*.erb')] - @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, 'libraries', '**', '*.rb')] - @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, 'resources', '**', '*.rb')] - @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, 'providers', '**', '*.rb')] - @cookbook[:root_filenames] = Array(File.join(@cookbook_root, 'README.rdoc')) - @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, 'metadata.json')) + @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, "attributes", "**", "*.rb")] + @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, "definitions", "**", "*.rb")] + @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, "files", "**", "*.tgz")] + @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, "recipes", "**", "*.rb")] + @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, "templates", "**", "*.erb")] + @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, "libraries", "**", "*.rb")] + @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, "resources", "**", "*.rb")] + @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, "providers", "**", "*.rb")] + @cookbook[:root_filenames] = Array(File.join(@cookbook_root, "README.rdoc")) + @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, "metadata.json")) end describe "and a cookbook with the same name" do before do # Currently the cookbook loader finds all the files then tells CookbookVersion # where they are. - @cookbook_version = Chef::CookbookVersion.new('tatft', @cookbook_root) + @cookbook_version = Chef::CookbookVersion.new("tatft", @cookbook_root) @cookbook_version.attribute_filenames = @cookbook[:attribute_filenames] @cookbook_version.definition_filenames = @cookbook[:definition_filenames] @@ -154,25 +154,25 @@ describe Chef::CookbookVersion do end - describe 'with a cookbook directory named cookbook2 that has unscoped files' do + describe "with a cookbook directory named cookbook2 that has unscoped files" do before do @cookbook = Hash.new { |hash, key| hash[key] = [] } - @cookbook_root = File.join(CHEF_SPEC_DATA, 'cb_version_cookbooks', 'cookbook2') + @cookbook_root = File.join(CHEF_SPEC_DATA, "cb_version_cookbooks", "cookbook2") # Dunno if the paths here are representitive of what is set by CookbookLoader... - @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, 'attributes', '**', '*.rb')] - @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, 'definitions', '**', '*.rb')] - @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, 'files', '**', '*.*')] - @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, 'recipes', '**', '*.rb')] - @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, 'templates', '**', '*.*')] - @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, 'libraries', '**', '*.rb')] - @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, 'resources', '**', '*.rb')] - @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, 'providers', '**', '*.rb')] - @cookbook[:root_filenames] = Array(File.join(@cookbook_root, 'README.rdoc')) - @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, 'metadata.json')) - - @cookbook_version = Chef::CookbookVersion.new('cookbook2', @cookbook_root) + @cookbook[:attribute_filenames] = Dir[File.join(@cookbook_root, "attributes", "**", "*.rb")] + @cookbook[:definition_filenames] = Dir[File.join(@cookbook_root, "definitions", "**", "*.rb")] + @cookbook[:file_filenames] = Dir[File.join(@cookbook_root, "files", "**", "*.*")] + @cookbook[:recipe_filenames] = Dir[File.join(@cookbook_root, "recipes", "**", "*.rb")] + @cookbook[:template_filenames] = Dir[File.join(@cookbook_root, "templates", "**", "*.*")] + @cookbook[:library_filenames] = Dir[File.join(@cookbook_root, "libraries", "**", "*.rb")] + @cookbook[:resource_filenames] = Dir[File.join(@cookbook_root, "resources", "**", "*.rb")] + @cookbook[:provider_filenames] = Dir[File.join(@cookbook_root, "providers", "**", "*.rb")] + @cookbook[:root_filenames] = Array(File.join(@cookbook_root, "README.rdoc")) + @cookbook[:metadata_filenames] = Array(File.join(@cookbook_root, "metadata.json")) + + @cookbook_version = Chef::CookbookVersion.new("cookbook2", @cookbook_root) @cookbook_version.attribute_filenames = @cookbook[:attribute_filenames] @cookbook_version.definition_filenames = @cookbook[:definition_filenames] @cookbook_version.recipe_filenames = @cookbook[:recipe_filenames] @@ -252,8 +252,8 @@ describe Chef::CookbookVersion do ["1.2", "2.1"], ] examples.each do |smaller, larger| - sm = Chef::CookbookVersion.new("foo", '/tmp/blah') - lg = Chef::CookbookVersion.new("foo", '/tmp/blah') + sm = Chef::CookbookVersion.new("foo", "/tmp/blah") + lg = Chef::CookbookVersion.new("foo", "/tmp/blah") sm.version = smaller lg.version = larger expect(sm).to be < lg @@ -263,8 +263,8 @@ describe Chef::CookbookVersion do end it "should equate versions 1.2 and 1.2.0" do - a = Chef::CookbookVersion.new("foo", '/tmp/blah') - b = Chef::CookbookVersion.new("foo", '/tmp/blah') + a = Chef::CookbookVersion.new("foo", "/tmp/blah") + b = Chef::CookbookVersion.new("foo", "/tmp/blah") a.version = "1.2" b.version = "1.2.0" expect(a).to eq(b) @@ -272,9 +272,9 @@ describe Chef::CookbookVersion do it "should not allow you to sort cookbooks with different names" do - apt = Chef::CookbookVersion.new "apt", '/tmp/blah' + apt = Chef::CookbookVersion.new "apt", "/tmp/blah" apt.version = "1.0" - god = Chef::CookbookVersion.new "god", '/tmp/blah' + god = Chef::CookbookVersion.new "god", "/tmp/blah" god.version = "2.0" expect {apt <=> god}.to raise_error(Chef::Exceptions::CookbookVersionNameMismatch) end @@ -282,7 +282,7 @@ describe Chef::CookbookVersion do describe "when you set a version" do before do - @cbv = Chef::CookbookVersion.new("version validation", '/tmp/blah') + @cbv = Chef::CookbookVersion.new("version validation", "/tmp/blah") end it "should accept valid cookbook versions" do good_versions = %w(1.2 1.2.3 1000.80.50000 0.300.25) @@ -304,7 +304,7 @@ describe Chef::CookbookVersion do describe "when deprecation warnings are errors" do - subject(:cbv) { Chef::CookbookVersion.new("version validation", '/tmp/blah') } + subject(:cbv) { Chef::CookbookVersion.new("version validation", "/tmp/blah") } it "errors on #status and #status=" do expect { cbv.status = :wat }.to raise_error(Chef::Exceptions::DeprecatedFeatureError) @@ -315,7 +315,7 @@ describe Chef::CookbookVersion do describe "deprecated features" do - subject(:cbv) { Chef::CookbookVersion.new("tatft", '/tmp/blah').tap { |c| c.version = "1.2.3" } } + subject(:cbv) { Chef::CookbookVersion.new("tatft", "/tmp/blah").tap { |c| c.version = "1.2.3" } } before do Chef::Config[:treat_deprecation_warnings_as_errors] = false @@ -337,7 +337,7 @@ describe Chef::CookbookVersion do include_examples "to_json equivalent to Chef::JSONCompat.to_json" do - let(:jsonable) { Chef::CookbookVersion.new("tatft", '/tmp/blah') } + let(:jsonable) { Chef::CookbookVersion.new("tatft", "/tmp/blah") } end end diff --git a/spec/unit/daemon_spec.rb b/spec/unit/daemon_spec.rb index e020576a23..267fda77b5 100644 --- a/spec/unit/daemon_spec.rb +++ b/spec/unit/daemon_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Daemon do before do @@ -74,7 +74,7 @@ describe Chef::Daemon do before do allow(Chef::Application).to receive(:fatal!).and_return(true) - Chef::Config[:user] = 'aj' + Chef::Config[:user] = "aj" allow(Dir).to receive(:chdir) end @@ -86,7 +86,7 @@ describe Chef::Daemon do describe "when the user and group options are supplied" do before do - Chef::Config[:group] = 'staff' + Chef::Config[:group] = "staff" end it "should log an appropriate info message" do diff --git a/spec/unit/data_bag_item_spec.rb b/spec/unit/data_bag_item_spec.rb index 47042aa7ba..0329264718 100644 --- a/spec/unit/data_bag_item_spec.rb +++ b/spec/unit/data_bag_item_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/data_bag_item' +require "spec_helper" +require "chef/data_bag_item" describe Chef::DataBagItem do let(:data_bag_item) { Chef::DataBagItem.new } @@ -169,7 +169,7 @@ describe Chef::DataBagItem do describe "when deserializing from JSON" do let(:data_bag_item) { data_bag_item = Chef::DataBagItem.new - data_bag_item.data_bag('mars_volta') + data_bag_item.data_bag("mars_volta") data_bag_item.raw_data = { "id" => "octahedron", "snooze" => { "finally" => :world_will } } data_bag_item } @@ -200,8 +200,8 @@ describe Chef::DataBagItem do describe "when converting to a string" do it "converts to a string in the form data_bag_item[ID]" do - data_bag_item['id'] = "heart of darkness" - expect(data_bag_item.to_s).to eq('data_bag_item[heart of darkness]') + data_bag_item["id"] = "heart of darkness" + expect(data_bag_item.to_s).to eq("data_bag_item[heart of darkness]") end it "inspects as data_bag_item[BAG, ID, RAW_DATA]" do @@ -218,7 +218,7 @@ describe Chef::DataBagItem do let(:data_bag_item) { data_bag_item = Chef::DataBagItem.new - data_bag_item['id'] = "heart of darkness" + data_bag_item["id"] = "heart of darkness" data_bag_item.raw_data = {"id" => "heart_of_darkness", "author" => "Conrad"} data_bag_item.data_bag("books") data_bag_item @@ -263,7 +263,7 @@ describe Chef::DataBagItem do let(:data_bag_item) { data_bag_item = Chef::DataBagItem.new - data_bag_item.data_bag('a_baggy_bag') + data_bag_item.data_bag("a_baggy_bag") data_bag_item.raw_data = { "id" => "some_id" } data_bag_item } @@ -314,8 +314,8 @@ describe Chef::DataBagItem do end it "converts the raw data to a data bag item" do - expect(Chef::DataBag).to receive(:load).with('users').and_return({'charlie' => data_bag_item.to_hash}) - item = Chef::DataBagItem.load('users', 'charlie') + expect(Chef::DataBag).to receive(:load).with("users").and_return({"charlie" => data_bag_item.to_hash}) + item = Chef::DataBagItem.load("users", "charlie") expect(item).to be_a_kind_of(Chef::DataBagItem) expect(item).to eq(data_bag_item) end diff --git a/spec/unit/data_bag_spec.rb b/spec/unit/data_bag_spec.rb index a325b1260f..4e06a31911 100644 --- a/spec/unit/data_bag_spec.rb +++ b/spec/unit/data_bag_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/data_bag' +require "spec_helper" +require "chef/data_bag" describe Chef::DataBag do before(:each) do @@ -58,7 +58,7 @@ describe Chef::DataBag do describe "deserialize" do before(:each) do - @data_bag.name('mars_volta') + @data_bag.name("mars_volta") @deserial = Chef::JSONCompat.from_json(Chef::JSONCompat.to_json(@data_bag)) end @@ -82,7 +82,7 @@ describe Chef::DataBag do describe "when saving" do before do - @data_bag.name('piggly_wiggly') + @data_bag.name("piggly_wiggly") @rest = double("Chef::ServerAPI") allow(Chef::ServerAPI).to receive(:new).and_return(@rest) end @@ -115,21 +115,21 @@ describe Chef::DataBag do describe "when loading" do describe "from an API call" do before do - Chef::Config[:chef_server_url] = 'https://myserver.example.com' - @http_client = double('Chef::ServerAPI') + Chef::Config[:chef_server_url] = "https://myserver.example.com" + @http_client = double("Chef::ServerAPI") end it "should get the data bag from the server" do - expect(Chef::ServerAPI).to receive(:new).with('https://myserver.example.com').and_return(@http_client) - expect(@http_client).to receive(:get).with('data/foo') - Chef::DataBag.load('foo') + expect(Chef::ServerAPI).to receive(:new).with("https://myserver.example.com").and_return(@http_client) + expect(@http_client).to receive(:get).with("data/foo") + Chef::DataBag.load("foo") end it "should return the data bag" do allow(Chef::ServerAPI).to receive(:new).and_return(@http_client) - expect(@http_client).to receive(:get).with('data/foo').and_return({'bar' => 'https://myserver.example.com/data/foo/bar'}) - data_bag = Chef::DataBag.load('foo') - expect(data_bag).to eq({'bar' => 'https://myserver.example.com/data/foo/bar'}) + expect(@http_client).to receive(:get).with("data/foo").and_return({"bar" => "https://myserver.example.com/data/foo/bar"}) + data_bag = Chef::DataBag.load("foo") + expect(data_bag).to eq({"bar" => "https://myserver.example.com/data/foo/bar"}) end end @@ -138,7 +138,7 @@ describe Chef::DataBag do end def dir_glob_stub(path, returns = []) - expect(Dir).to receive(:glob).with(File.join(path, 'foo/*.json')).and_return(returns) + expect(Dir).to receive(:glob).with(File.join(path, "foo/*.json")).and_return(returns) end shared_examples_for "data bag in solo mode" do |data_bag_path| @@ -157,7 +157,7 @@ describe Chef::DataBag do file_dir_stub(path) dir_glob_stub(path) end - Chef::DataBag.load('foo') + Chef::DataBag.load("foo") end it "should get the data bag from the data_bag_path by symbolic name" do @@ -172,57 +172,57 @@ describe Chef::DataBag do @paths.each do |path| file_dir_stub(path) if path == @paths.first - dir_glob_stub(path, [File.join(path, 'foo/bar.json'), File.join(path, 'foo/baz.json')]) + dir_glob_stub(path, [File.join(path, "foo/bar.json"), File.join(path, "foo/baz.json")]) else dir_glob_stub(path) end end - expect(IO).to receive(:read).with(File.join(@paths.first, 'foo/bar.json')).and_return('{"id": "bar", "name": "Bob Bar" }') - expect(IO).to receive(:read).with(File.join(@paths.first, 'foo/baz.json')).and_return('{"id": "baz", "name": "John Baz" }') - data_bag = Chef::DataBag.load('foo') - expect(data_bag).to eq({ 'bar' => { 'id' => 'bar', 'name' => 'Bob Bar' }, 'baz' => { 'id' => 'baz', 'name' => 'John Baz' }}) + expect(IO).to receive(:read).with(File.join(@paths.first, "foo/bar.json")).and_return('{"id": "bar", "name": "Bob Bar" }') + expect(IO).to receive(:read).with(File.join(@paths.first, "foo/baz.json")).and_return('{"id": "baz", "name": "John Baz" }') + data_bag = Chef::DataBag.load("foo") + expect(data_bag).to eq({ "bar" => { "id" => "bar", "name" => "Bob Bar" }, "baz" => { "id" => "baz", "name" => "John Baz" }}) end it "should raise if data bag has items with similar names but different content" do @paths.each do |path| file_dir_stub(path) item_with_different_content = "{\"id\": \"bar\", \"name\": \"Bob Bar\", \"path\": \"#{path}\"}" - expect(IO).to receive(:read).with(File.join(path, 'foo/bar.json')).and_return(item_with_different_content) + expect(IO).to receive(:read).with(File.join(path, "foo/bar.json")).and_return(item_with_different_content) if data_bag_path.is_a?(String) - dir_glob_stub(path, [File.join(path, 'foo/bar.json'), File.join(path, 'foo/baz.json')]) + dir_glob_stub(path, [File.join(path, "foo/bar.json"), File.join(path, "foo/baz.json")]) item_2_with_different_content = '{"id": "bar", "name": "John Baz"}' - expect(IO).to receive(:read).with(File.join(path, 'foo/baz.json')).and_return(item_2_with_different_content) + expect(IO).to receive(:read).with(File.join(path, "foo/baz.json")).and_return(item_2_with_different_content) else - dir_glob_stub(path, [File.join(path, 'foo/bar.json')]) + dir_glob_stub(path, [File.join(path, "foo/bar.json")]) end end - expect { Chef::DataBag.load('foo') }.to raise_error(Chef::Exceptions::DuplicateDataBagItem) + expect { Chef::DataBag.load("foo") }.to raise_error(Chef::Exceptions::DuplicateDataBagItem) end it "should return data bag if it has items with similar names and the same content" do @paths.each do |path| file_dir_stub(path) - dir_glob_stub(path, [File.join(path, 'foo/bar.json'), File.join(path, 'foo/baz.json')]) + dir_glob_stub(path, [File.join(path, "foo/bar.json"), File.join(path, "foo/baz.json")]) item_with_same_content = '{"id": "bar", "name": "Bob Bar"}' - expect(IO).to receive(:read).with(File.join(path, 'foo/bar.json')).and_return(item_with_same_content) - expect(IO).to receive(:read).with(File.join(path, 'foo/baz.json')).and_return(item_with_same_content) + expect(IO).to receive(:read).with(File.join(path, "foo/bar.json")).and_return(item_with_same_content) + expect(IO).to receive(:read).with(File.join(path, "foo/baz.json")).and_return(item_with_same_content) end - data_bag = Chef::DataBag.load('foo') - test_data_bag = { 'bar' => { 'id' => 'bar', 'name' => 'Bob Bar'} } + data_bag = Chef::DataBag.load("foo") + test_data_bag = { "bar" => { "id" => "bar", "name" => "Bob Bar"} } expect(data_bag).to eq(test_data_bag) end it "should merge data bag items if there are no conflicts" do @paths.each_with_index do |path, index| file_dir_stub(path) - dir_glob_stub(path, [File.join(path, 'foo/bar.json'), File.join(path, 'foo/baz.json')]) + dir_glob_stub(path, [File.join(path, "foo/bar.json"), File.join(path, "foo/baz.json")]) test_item_with_same_content = '{"id": "bar", "name": "Bob Bar"}' - expect(IO).to receive(:read).with(File.join(path, 'foo/bar.json')).and_return(test_item_with_same_content) + expect(IO).to receive(:read).with(File.join(path, "foo/bar.json")).and_return(test_item_with_same_content) test_uniq_item = "{\"id\": \"baz_#{index}\", \"name\": \"John Baz\", \"path\": \"#{path}\"}" - expect(IO).to receive(:read).with(File.join(path, 'foo/baz.json')).and_return(test_uniq_item) + expect(IO).to receive(:read).with(File.join(path, "foo/baz.json")).and_return(test_uniq_item) end - data_bag = Chef::DataBag.load('foo') - test_data_bag = { 'bar' => { 'id' => 'bar', 'name' => 'Bob Bar'} } + data_bag = Chef::DataBag.load("foo") + test_data_bag = { "bar" => { "id" => "bar", "name" => "Bob Bar"} } @paths.each_with_index do |path, index| test_data_bag["baz_#{index}"] = { "id" => "baz_#{index}", "name" => "John Baz", "path" => path } end @@ -232,17 +232,17 @@ describe Chef::DataBag do it "should return the data bag list" do @paths.each do |path| file_dir_stub(path) - expect(Dir).to receive(:glob).and_return([File.join(path, 'foo'), File.join(path, 'bar')]) + expect(Dir).to receive(:glob).and_return([File.join(path, "foo"), File.join(path, "bar")]) end data_bag_list = Chef::DataBag.list - expect(data_bag_list).to eq({ 'bar' => 'bar', 'foo' => 'foo' }) + expect(data_bag_list).to eq({ "bar" => "bar", "foo" => "foo" }) end - it 'should raise an error if the configured data_bag_path is invalid' do + it "should raise an error if the configured data_bag_path is invalid" do file_dir_stub(@paths.first, false) expect { - Chef::DataBag.load('foo') + Chef::DataBag.load("foo") }.to raise_error Chef::Exceptions::InvalidDataBagPath, "Data bag path '/var/chef/data_bags' is invalid" end diff --git a/spec/unit/deprecation_spec.rb b/spec/unit/deprecation_spec.rb index 674de5ec1d..f2f99e9ba6 100644 --- a/spec/unit/deprecation_spec.rb +++ b/spec/unit/deprecation_spec.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/deprecation/warnings' +require "spec_helper" +require "chef/deprecation/warnings" describe Chef::Deprecation do # Support code for Chef::Deprecation def self.class_from_string(str) - str.split('::').inject(Object) do |mod, class_name| + str.split("::").inject(Object) do |mod, class_name| mod.const_get(class_name) end end @@ -59,33 +59,33 @@ describe Chef::Deprecation do end end - context 'when Chef::Config[:treat_deprecation_warnings_as_errors] is off' do + context "when Chef::Config[:treat_deprecation_warnings_as_errors] is off" do before do Chef::Config[:treat_deprecation_warnings_as_errors] = false end - context 'deprecation warning messages' do + context "deprecation warning messages" do RSpec::Matchers.define_negated_matcher :a_non_empty_array, :be_empty - it 'should be enabled for deprecated methods' do + it "should be enabled for deprecated methods" do expect(Chef::Log).to receive(:warn).with(a_non_empty_array) TestClass.new.deprecated_method(10) end - it 'should contain stack trace' do + it "should contain stack trace" do expect(Chef::Log).to receive(:warn).with(a_string_including(".rb")) TestClass.new.deprecated_method(10) end end - it 'deprecated methods should still be called' do + it "deprecated methods should still be called" do test_instance = TestClass.new test_instance.deprecated_method(10) expect(test_instance.get_value).to eq(10) end end - it 'should raise when deprecation warnings are treated as errors' do + it "should raise when deprecation warnings are treated as errors" do # rspec should set this expect(Chef::Config[:treat_deprecation_warnings_as_errors]).to be true test_instance = TestClass.new diff --git a/spec/unit/digester_spec.rb b/spec/unit/digester_spec.rb index 51bcfbdde5..2dbbb5b25f 100644 --- a/spec/unit/digester_spec.rb +++ b/spec/unit/digester_spec.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Digester do before(:each) do @@ -40,7 +40,7 @@ describe Chef::Digester do it "generates a checksum from a non-file IO object" do io = StringIO.new("riseofthemachines\nriseofthechefs\n") - expected_md5 = '0e157ac1e2dd73191b76067fb6b4bceb' + expected_md5 = "0e157ac1e2dd73191b76067fb6b4bceb" expect(@cache.generate_md5_checksum(io)).to eq(expected_md5) end diff --git a/spec/unit/dsl/audit_spec.rb b/spec/unit/dsl/audit_spec.rb index 28b28e0a7c..df8dbc95c0 100644 --- a/spec/unit/dsl/audit_spec.rb +++ b/spec/unit/dsl/audit_spec.rb @@ -1,6 +1,6 @@ -require 'spec_helper' -require 'chef/dsl/audit' +require "spec_helper" +require "chef/dsl/audit" class AuditDSLTester < Chef::Recipe include Chef::DSL::Audit diff --git a/spec/unit/dsl/data_query_spec.rb b/spec/unit/dsl/data_query_spec.rb index 7bca47af3e..34d4cfdba3 100644 --- a/spec/unit/dsl/data_query_spec.rb +++ b/spec/unit/dsl/data_query_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/dsl/data_query' +require "spec_helper" +require "chef/dsl/data_query" class DataQueryDSLTester include Chef::DSL::DataQuery diff --git a/spec/unit/dsl/platform_introspection_spec.rb b/spec/unit/dsl/platform_introspection_spec.rb index 438dde126e..61a7d8ca82 100644 --- a/spec/unit/dsl/platform_introspection_spec.rb +++ b/spec/unit/dsl/platform_introspection_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/dsl/platform_introspection' +require "spec_helper" +require "chef/dsl/platform_introspection" class LanguageTester attr_reader :node @@ -39,16 +39,16 @@ end describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do before do platform_hash = { - :openbsd => {:default => 'free, functional, secure'}, + :openbsd => {:default => "free, functional, secure"}, [:redhat, :centos, :fedora, :scientific] => {:default => '"stable"'}, - :ubuntu => {'10.04' => 'using upstart more', :default => 'using init more'}, - :default => 'bork da bork', + :ubuntu => {"10.04" => "using upstart more", :default => "using init more"}, + :default => "bork da bork", } @platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new(platform_hash) end it "returns the default value when the platform doesn't match" do - expect(@platform_specific_value.value_for_node(:platform => :dos)).to eq('bork da bork') + expect(@platform_specific_value.value_for_node(:platform => :dos)).to eq("bork da bork") end it "returns a value for a platform set as a group" do @@ -60,20 +60,20 @@ describe Chef::DSL::PlatformIntrospection::PlatformDependentValue do end it "returns a value for a specific platform version" do - node = {:platform => 'ubuntu', :platform_version => '10.04'} - expect(@platform_specific_value.value_for_node(node)).to eq('using upstart more') + node = {:platform => "ubuntu", :platform_version => "10.04"} + expect(@platform_specific_value.value_for_node(node)).to eq("using upstart more") end it "returns a platform-default value if the platform version doesn't match an explicit one" do - node = {:platform => 'ubuntu', :platform_version => '9.10' } - expect(@platform_specific_value.value_for_node(node)).to eq('using init more') + node = {:platform => "ubuntu", :platform_version => "9.10" } + expect(@platform_specific_value.value_for_node(node)).to eq("using init more") end it "returns nil if there is no default and no platforms match" do # this matches the behavior in the original implementation. # whether or not it's correct is another matter. platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformDependentValue.new({}) - expect(platform_specific_value.value_for_node(:platform => 'foo')).to be_nil + expect(platform_specific_value.value_for_node(:platform => "foo")).to be_nil end it "raises an argument error if the platform hash is not correctly structured" do @@ -98,7 +98,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do end it "returns the default value when the platform family doesn't match" do - expect(@platform_family_value.value_for_node(:platform_family => :os2)).to eq('default value') + expect(@platform_family_value.value_for_node(:platform_family => :os2)).to eq("default value") end @@ -124,7 +124,7 @@ describe Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue do it "returns nil if there is no default and no platforms match" do platform_specific_value = Chef::DSL::PlatformIntrospection::PlatformFamilyDependentValue.new({}) - expect(platform_specific_value.value_for_node(:platform_family => 'foo')).to be_nil + expect(platform_specific_value.value_for_node(:platform_family => "foo")).to be_nil end end diff --git a/spec/unit/dsl/reboot_pending_spec.rb b/spec/unit/dsl/reboot_pending_spec.rb index 6705820e17..49696f7cc3 100644 --- a/spec/unit/dsl/reboot_pending_spec.rb +++ b/spec/unit/dsl/reboot_pending_spec.rb @@ -30,13 +30,13 @@ describe Chef::DSL::RebootPending do context "platform is windows" do before do - allow(recipe).to receive(:platform?).with('windows').and_return(true) + allow(recipe).to receive(:platform?).with("windows").and_return(true) allow(recipe).to receive(:registry_key_exists?).and_return(false) allow(recipe).to receive(:registry_value_exists?).and_return(false) end it 'should return true if "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations" exists' do - allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => 'PendingFileRenameOperations' }).and_return(true) + allow(recipe).to receive(:registry_value_exists?).with('HKLM\SYSTEM\CurrentControlSet\Control\Session Manager', { :name => "PendingFileRenameOperations" }).and_return(true) expect(recipe.reboot_pending?).to be_truthy end @@ -66,16 +66,16 @@ describe Chef::DSL::RebootPending do context "platform is ubuntu" do before do - allow(recipe).to receive(:platform?).with('ubuntu').and_return(true) + allow(recipe).to receive(:platform?).with("ubuntu").and_return(true) end - it 'should return true if /var/run/reboot-required exists' do - allow(File).to receive(:exists?).with('/var/run/reboot-required').and_return(true) + it "should return true if /var/run/reboot-required exists" do + allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(true) expect(recipe.reboot_pending?).to be_truthy end - it 'should return false if /var/run/reboot-required does not exist' do - allow(File).to receive(:exists?).with('/var/run/reboot-required').and_return(false) + it "should return false if /var/run/reboot-required does not exist" do + allow(File).to receive(:exists?).with("/var/run/reboot-required").and_return(false) expect(recipe.reboot_pending?).to be_falsey end end diff --git a/spec/unit/dsl/recipe_spec.rb b/spec/unit/dsl/recipe_spec.rb index dfaad0b73e..108fe81d2b 100644 --- a/spec/unit/dsl/recipe_spec.rb +++ b/spec/unit/dsl/recipe_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/dsl/recipe' +require "spec_helper" +require "chef/dsl/recipe" RecipeDSLExampleClass = Struct.new(:cookbook_name, :recipe_name) diff --git a/spec/unit/dsl/regsitry_helper_spec.rb b/spec/unit/dsl/regsitry_helper_spec.rb index 6508a12b6f..8647b79020 100644 --- a/spec/unit/dsl/regsitry_helper_spec.rb +++ b/spec/unit/dsl/regsitry_helper_spec.rb @@ -33,22 +33,22 @@ describe Chef::Resource::RegistryKey do context "tests registry dsl" do it "resource can access registry_helper method registry_key_exists" do - expect(@resource.respond_to?('registry_key_exists?')).to eq(true) + expect(@resource.respond_to?("registry_key_exists?")).to eq(true) end it "resource can access registry_helper method registry_get_values" do - expect(@resource.respond_to?('registry_get_values')).to eq(true) + expect(@resource.respond_to?("registry_get_values")).to eq(true) end it "resource can access registry_helper method registry_has_subkey" do - expect(@resource.respond_to?('registry_has_subkeys?')).to eq(true) + expect(@resource.respond_to?("registry_has_subkeys?")).to eq(true) end it "resource can access registry_helper method registry_get_subkeys" do - expect(@resource.respond_to?('registry_get_subkeys')).to eq(true) + expect(@resource.respond_to?("registry_get_subkeys")).to eq(true) end it "resource can access registry_helper method registry_value_exists" do - expect(@resource.respond_to?('registry_value_exists?')).to eq(true) + expect(@resource.respond_to?("registry_value_exists?")).to eq(true) end it "resource can access registry_helper method data_value_exists" do - expect(@resource.respond_to?('registry_data_exists?')).to eq(true) + expect(@resource.respond_to?("registry_data_exists?")).to eq(true) end end end diff --git a/spec/unit/dsl/resources_spec.rb b/spec/unit/dsl/resources_spec.rb index 581c835290..72ee23c8c9 100644 --- a/spec/unit/dsl/resources_spec.rb +++ b/spec/unit/dsl/resources_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/dsl/resources' +require "spec_helper" +require "chef/dsl/resources" describe Chef::DSL::Resources do let(:declared_resources) { [] } @@ -36,21 +36,21 @@ describe Chef::DSL::Resources do described_class.remove_resource_dsl(:test_resource) end - context 'with a resource added' do + context "with a resource added" do before do Chef::DSL::Resources.add_resource_dsl(:test_resource) test_class.new.instance_eval do - test_resource 'test_name' do + test_resource "test_name" do end end end - it { is_expected.to eq [[:test_resource, 'test_name']]} + it { is_expected.to eq [[:test_resource, "test_name"]]} end - context 'with no resource added' do + context "with no resource added" do subject do test_class.new.instance_eval do - test_resource 'test_name' do + test_resource "test_name" do end end end @@ -58,14 +58,14 @@ describe Chef::DSL::Resources do it { expect { subject }.to raise_error NoMethodError } end - context 'with a resource added and removed' do + context "with a resource added and removed" do before do Chef::DSL::Resources.add_resource_dsl(:test_resource) Chef::DSL::Resources.remove_resource_dsl(:test_resource) end subject do test_class.new.instance_eval do - test_resource 'test_name' do + test_resource "test_name" do end end end @@ -73,7 +73,7 @@ describe Chef::DSL::Resources do it { expect { subject }.to raise_error NoMethodError } end - context 'with a nameless resource' do + context "with a nameless resource" do before do Chef::DSL::Resources.add_resource_dsl(:test_resource) test_class.new.instance_eval do diff --git a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb index 1090f46745..fc5a7276fb 100644 --- a/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb +++ b/spec/unit/encrypted_data_bag_item/check_encrypted_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/encrypted_data_bag_item/check_encrypted' +require "spec_helper" +require "chef/encrypted_data_bag_item/check_encrypted" class CheckEncryptedTester include Chef::EncryptedDataBagItem::CheckEncrypted diff --git a/spec/unit/encrypted_data_bag_item_spec.rb b/spec/unit/encrypted_data_bag_item_spec.rb index 26501684c8..796ad8ff5b 100644 --- a/spec/unit/encrypted_data_bag_item_spec.rb +++ b/spec/unit/encrypted_data_bag_item_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/encrypted_data_bag_item' +require "spec_helper" +require "chef/encrypted_data_bag_item" module Version0Encryptor def self.encrypt_value(plaintext_data, key) diff --git a/spec/unit/environment_spec.rb b/spec/unit/environment_spec.rb index 4a8f94e770..0f3ee17872 100644 --- a/spec/unit/environment_spec.rb +++ b/spec/unit/environment_spec.rb @@ -19,8 +19,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/environment' +require "spec_helper" +require "chef/environment" describe Chef::Environment do before(:each) do @@ -73,12 +73,12 @@ describe Chef::Environment do describe "default attributes" do it "should let you set the attributes hash explicitly" do - expect(@environment.default_attributes({ :one => 'two' })).to eq({ :one => 'two' }) + expect(@environment.default_attributes({ :one => "two" })).to eq({ :one => "two" }) end it "should let you return the attributes hash" do - @environment.default_attributes({ :one => 'two' }) - expect(@environment.default_attributes).to eq({ :one => 'two' }) + @environment.default_attributes({ :one => "two" }) + expect(@environment.default_attributes).to eq({ :one => "two" }) end it "should throw an ArgumentError if we aren't a kind of hash" do @@ -88,12 +88,12 @@ describe Chef::Environment do describe "override attributes" do it "should let you set the attributes hash explicitly" do - expect(@environment.override_attributes({ :one => 'two' })).to eq({ :one => 'two' }) + expect(@environment.override_attributes({ :one => "two" })).to eq({ :one => "two" }) end it "should let you return the attributes hash" do - @environment.override_attributes({ :one => 'two' }) - expect(@environment.override_attributes).to eq({ :one => 'two' }) + @environment.override_attributes({ :one => "two" }) + expect(@environment.override_attributes).to eq({ :one => "two" }) end it "should throw an ArgumentError if we aren't a kind of hash" do @@ -393,7 +393,7 @@ describe Chef::Environment do describe "in solo mode" do before do Chef::Config[:solo] = true - Chef::Config[:environment_path] = '/var/chef/environments' + Chef::Config[:environment_path] = "/var/chef/environments" end after do @@ -402,17 +402,17 @@ describe Chef::Environment do it "should get the environment from the environment_path" do expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true) - expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(false) - expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], 'foo.rb')).exactly(2).times.and_return(true) - expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], 'foo.rb')).and_return(true) + expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false) + expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(2).times.and_return(true) + expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true) role_dsl="name \"foo\"\ndescription \"desc\"\n" - expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], 'foo.rb')).and_return(role_dsl) - Chef::Environment.load('foo') + expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(role_dsl) + Chef::Environment.load("foo") end it "should return a Chef::Environment object from JSON" do expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true) - expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(true) + expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(true) environment_hash = { "name" => "foo", "default_attributes" => { @@ -424,44 +424,44 @@ describe Chef::Environment do "description" => "desc", "chef_type" => "environment", } - expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(Chef::JSONCompat.to_json(environment_hash)) - environment = Chef::Environment.load('foo') + expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(Chef::JSONCompat.to_json(environment_hash)) + environment = Chef::Environment.load("foo") expect(environment).to be_a_kind_of(Chef::Environment) - expect(environment.name).to eq(environment_hash['name']) - expect(environment.description).to eq(environment_hash['description']) - expect(environment.default_attributes).to eq(environment_hash['default_attributes']) + expect(environment.name).to eq(environment_hash["name"]) + expect(environment.description).to eq(environment_hash["description"]) + expect(environment.default_attributes).to eq(environment_hash["default_attributes"]) end it "should return a Chef::Environment object from Ruby DSL" do expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true) - expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(false) - expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], 'foo.rb')).exactly(2).times.and_return(true) - expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], 'foo.rb')).and_return(true) + expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false) + expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).exactly(2).times.and_return(true) + expect(File).to receive(:readable?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(true) role_dsl="name \"foo\"\ndescription \"desc\"\n" - expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], 'foo.rb')).and_return(role_dsl) - environment = Chef::Environment.load('foo') + expect(IO).to receive(:read).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(role_dsl) + environment = Chef::Environment.load("foo") expect(environment).to be_a_kind_of(Chef::Environment) - expect(environment.name).to eq('foo') - expect(environment.description).to eq('desc') + expect(environment.name).to eq("foo") + expect(environment.description).to eq("desc") end - it 'should raise an error if the configured environment_path is invalid' do + it "should raise an error if the configured environment_path is invalid" do expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(false) expect { - Chef::Environment.load('foo') + Chef::Environment.load("foo") }.to raise_error Chef::Exceptions::InvalidEnvironmentPath, "Environment path '/var/chef/environments' is invalid" end - it 'should raise an error if the file does not exist' do + it "should raise an error if the file does not exist" do expect(File).to receive(:directory?).with(Chef::Config[:environment_path]).and_return(true) - expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], 'foo.json')).and_return(false) - expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], 'foo.rb')).and_return(false) + expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.json")).and_return(false) + expect(File).to receive(:exists?).with(File.join(Chef::Config[:environment_path], "foo.rb")).and_return(false) expect { - Chef::Environment.load('foo') + Chef::Environment.load("foo") }.to raise_error Chef::Exceptions::EnvironmentNotFound, "Environment 'foo' could not be loaded from disk" end end diff --git a/spec/unit/event_dispatch/dispatcher_spec.rb b/spec/unit/event_dispatch/dispatcher_spec.rb index 5a06e1d6d1..eaeb164414 100644 --- a/spec/unit/event_dispatch/dispatcher_spec.rb +++ b/spec/unit/event_dispatch/dispatcher_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/event_dispatch/dispatcher' +require "spec_helper" +require "chef/event_dispatch/dispatcher" describe Chef::EventDispatch::Dispatcher do diff --git a/spec/unit/event_dispatch/dsl_spec.rb b/spec/unit/event_dispatch/dsl_spec.rb index 0f7adce7a8..7c74e6738c 100644 --- a/spec/unit/event_dispatch/dsl_spec.rb +++ b/spec/unit/event_dispatch/dsl_spec.rb @@ -16,8 +16,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' -require 'chef/event_dispatch/dsl' +require "spec_helper" +require "chef/event_dispatch/dsl" describe Chef::EventDispatch::DSL do let(:events) do @@ -32,25 +32,25 @@ describe Chef::EventDispatch::DSL do Chef.set_run_context(run_context) end - subject{ described_class.new('test') } + subject{ described_class.new("test") } - it 'set handler name' do + it "set handler name" do subject.on(:run_started) {} - expect(events.subscribers.first.name).to eq('test') + expect(events.subscribers.first.name).to eq("test") end - it 'raise error when invalid event type is supplied' do + it "raise error when invalid event type is supplied" do expect do subject.on(:foo_bar) {} end.to raise_error(Chef::Exceptions::InvalidEventType) end - it 'register user hooks against valid event type' do - subject.on(:run_failed) {'testhook'} - expect(events.subscribers.first.run_failed).to eq('testhook') + it "register user hooks against valid event type" do + subject.on(:run_failed) {"testhook"} + expect(events.subscribers.first.run_failed).to eq("testhook") end - it 'preserve state across event hooks' do + it "preserve state across event hooks" do calls = [] Chef.event_handler do on :resource_updated do @@ -60,13 +60,13 @@ describe Chef::EventDispatch::DSL do calls << :started end end - resource = Chef::Resource::RubyBlock.new('foo', run_context) + resource = Chef::Resource::RubyBlock.new("foo", run_context) resource.block { } resource.run_action(:run) expect(calls).to eq([:started, :updated]) end - it 'preserve instance variables across handler callbacks' do + it "preserve instance variables across handler callbacks" do Chef.event_handler do on :resource_action_start do @ivar = [1] @@ -75,7 +75,7 @@ describe Chef::EventDispatch::DSL do @ivar << 2 end end - resource = Chef::Resource::RubyBlock.new('foo', run_context) + resource = Chef::Resource::RubyBlock.new("foo", run_context) resource.block { } resource.run_action(:run) expect(events.subscribers.first.instance_variable_get(:@ivar)).to eq([1, 2]) diff --git a/spec/unit/exceptions_spec.rb b/spec/unit/exceptions_spec.rb index c738bcf840..881fad4c20 100644 --- a/spec/unit/exceptions_spec.rb +++ b/spec/unit/exceptions_spec.rb @@ -19,7 +19,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Exceptions do exception_to_super_class = { diff --git a/spec/unit/file_access_control_spec.rb b/spec/unit/file_access_control_spec.rb index 2c68792c63..724c2385c7 100644 --- a/spec/unit/file_access_control_spec.rb +++ b/spec/unit/file_access_control_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::FileAccessControl do describe "Unix" do @@ -27,14 +27,14 @@ describe Chef::FileAccessControl do # platform specific module is mixed in @node = Chef::Node.new load File.join(File.dirname(__FILE__), "..", "..", "lib", "chef", "file_access_control.rb") - @resource = Chef::Resource::File.new('/tmp/a_file.txt') - @resource.owner('toor') - @resource.group('wheel') - @resource.mode('0400') + @resource = Chef::Resource::File.new("/tmp/a_file.txt") + @resource.owner("toor") + @resource.group("wheel") + @resource.mode("0400") @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @current_resource = Chef::Resource::File.new('/tmp/different_file.txt') + @current_resource = Chef::Resource::File.new("/tmp/different_file.txt") @provider_requirements = Chef::Provider::ResourceRequirements.new(@resource, @run_context) @provider = double("File provider", :requirements => @provider_requirements, :manage_symlink_access? => false) @@ -42,7 +42,7 @@ describe Chef::FileAccessControl do end end - describe 'class methods' do + describe "class methods" do it 'responds to #writable?' do expect(Chef::FileAccessControl).to respond_to(:writable?) end @@ -53,7 +53,7 @@ describe Chef::FileAccessControl do end it "has a file to manage" do - expect(@fac.file).to eq('/tmp/different_file.txt') + expect(@fac.file).to eq("/tmp/different_file.txt") end it "is not modified yet" do @@ -61,12 +61,12 @@ describe Chef::FileAccessControl do end it "determines the uid of the owner specified by the resource" do - expect(Etc).to receive(:getpwnam).with('toor').and_return(OpenStruct.new(:uid => 2342)) + expect(Etc).to receive(:getpwnam).with("toor").and_return(OpenStruct.new(:uid => 2342)) expect(@fac.target_uid).to eq(2342) end it "raises a Chef::Exceptions::UserIDNotFound error when Etc can't find the user's name" do - expect(Etc).to receive(:getpwnam).with('toor').and_raise(ArgumentError) + expect(Etc).to receive(:getpwnam).with("toor").and_raise(ArgumentError) expect { @fac.target_uid ; @provider_requirements.run(:create) }.to raise_error(Chef::Exceptions::UserIDNotFound, "cannot determine user id for 'toor', does the user exist on this system?") end @@ -98,16 +98,16 @@ describe Chef::FileAccessControl do # complement (i.e., it wraps around the maximum size of C unsigned int) of these # uids. So we have to get ruby and negative uids to smoke the peace pipe # with each other. - @resource.owner('nobody') - expect(Etc).to receive(:getpwnam).with('nobody').and_return(OpenStruct.new(:uid => (4294967294))) + @resource.owner("nobody") + expect(Etc).to receive(:getpwnam).with("nobody").and_return(OpenStruct.new(:uid => (4294967294))) expect(@fac.target_uid).to eq(-2) end it "does not wrap uids to their negative complements beyond -9" do # More: when OSX userIDs are created by ActiveDirectory sync, it tends to use huge numbers # which had been incorrectly wrapped. It does not look like the OSX IDs go below -2 - @resource.owner('bigdude') - expect(Etc).to receive(:getpwnam).with('bigdude').and_return(OpenStruct.new(:uid => (4294967286))) + @resource.owner("bigdude") + expect(Etc).to receive(:getpwnam).with("bigdude").and_return(OpenStruct.new(:uid => (4294967286))) expect(@fac.target_uid).to eq(4294967286) end @@ -133,7 +133,7 @@ describe Chef::FileAccessControl do it "sets the file's owner as specified in the resource when the current owner is incorrect" do @resource.owner(2342) - expect(File).to receive(:chown).with(2342, nil, '/tmp/different_file.txt') + expect(File).to receive(:chown).with(2342, nil, "/tmp/different_file.txt") @fac.set_owner expect(@fac).to be_modified end @@ -153,7 +153,7 @@ describe Chef::FileAccessControl do end it "determines the gid of the group specified by the resource" do - expect(Etc).to receive(:getgrnam).with('wheel').and_return(OpenStruct.new(:gid => 2342)) + expect(Etc).to receive(:getgrnam).with("wheel").and_return(OpenStruct.new(:gid => 2342)) expect(@fac.target_gid).to eq(2342) end @@ -163,18 +163,18 @@ describe Chef::FileAccessControl do end it "raises a Chef::Exceptions::GroupIDNotFound error when Etc can't find the user's name" do - expect(Etc).to receive(:getgrnam).with('wheel').and_raise(ArgumentError) + expect(Etc).to receive(:getgrnam).with("wheel").and_raise(ArgumentError) expect { @fac.target_gid; @provider_requirements.run(:create) }.to raise_error(Chef::Exceptions::GroupIDNotFound, "cannot determine group id for 'wheel', does the group exist on this system?") end it "does not attempt to resolve a gid when none is supplied" do - resource = Chef::Resource::File.new('crab') + resource = Chef::Resource::File.new("crab") fac = Chef::FileAccessControl.new(@current_resource, resource, @provider) expect(fac.target_gid).to be_nil end it "does not want to update the group when no target group is specified" do - resource = Chef::Resource::File.new('crab') + resource = Chef::Resource::File.new("crab") fac = Chef::FileAccessControl.new(@current_resource, resource, @provider) expect(fac.should_update_group?).to be_falsey end @@ -197,7 +197,7 @@ describe Chef::FileAccessControl do end it "includes updating the group in the list of changes" do - resource = Chef::Resource::File.new('crab') + resource = Chef::Resource::File.new("crab") resource.group(2342) @current_resource.group(815) fac = Chef::FileAccessControl.new(@current_resource, resource, @provider) @@ -208,7 +208,7 @@ describe Chef::FileAccessControl do @resource.group(2342) @current_resource.group(815) - expect(File).to receive(:chown).with(nil, 2342, '/tmp/different_file.txt') + expect(File).to receive(:chown).with(nil, 2342, "/tmp/different_file.txt") @fac.set_group expect(@fac).to be_modified end @@ -230,7 +230,7 @@ describe Chef::FileAccessControl do end it "uses the supplied mode as octal when it's a string" do - @resource.mode('444') + @resource.mode("444") expect(@fac.target_mode).to eq(292) # octal 444 => decimal 292 end @@ -240,13 +240,13 @@ describe Chef::FileAccessControl do end it "does not try to determine the mode when none is given" do - resource = Chef::Resource::File.new('blahblah') + resource = Chef::Resource::File.new("blahblah") fac = Chef::FileAccessControl.new(@current_resource, resource, @provider) expect(fac.target_mode).to be_nil end it "doesn't want to update the mode when no target mode is given" do - resource = Chef::Resource::File.new('blahblah') + resource = Chef::Resource::File.new("blahblah") fac = Chef::FileAccessControl.new(@current_resource, resource, @provider) expect(fac.should_update_mode?).to be_falsey end @@ -264,7 +264,7 @@ describe Chef::FileAccessControl do end it "includes changing the mode in the list of desired changes" do - resource = Chef::Resource::File.new('blahblah') + resource = Chef::Resource::File.new("blahblah") resource.mode("0750") @current_resource.mode("0444") fac = Chef::FileAccessControl.new(@current_resource, resource, @provider) @@ -275,7 +275,7 @@ describe Chef::FileAccessControl do # stat returns modes like 0100644 (octal) => 33188 (decimal) #@fac.stub(:stat).and_return(OpenStruct.new(:mode => 33188)) @current_resource.mode("0644") - expect(File).to receive(:chmod).with(256, '/tmp/different_file.txt') + expect(File).to receive(:chmod).with(256, "/tmp/different_file.txt") @fac.set_mode expect(@fac).to be_modified end @@ -298,9 +298,9 @@ describe Chef::FileAccessControl do @resource.mode(0400) @resource.owner(0) @resource.group(0) - expect(File).to receive(:chmod).with(0400, '/tmp/different_file.txt') - expect(File).to receive(:chown).with(0, nil, '/tmp/different_file.txt') - expect(File).to receive(:chown).with(nil, 0, '/tmp/different_file.txt') + expect(File).to receive(:chmod).with(0400, "/tmp/different_file.txt") + expect(File).to receive(:chown).with(0, nil, "/tmp/different_file.txt") + expect(File).to receive(:chown).with(nil, 0, "/tmp/different_file.txt") @fac.set_all expect(@fac).to be_modified end diff --git a/spec/unit/file_cache_spec.rb b/spec/unit/file_cache_spec.rb index a24c3d3b97..1b273c9adf 100644 --- a/spec/unit/file_cache_spec.rb +++ b/spec/unit/file_cache_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::FileCache do before do @@ -32,11 +32,11 @@ describe Chef::FileCache do describe "when the relative path to the cache file doesn't exist" do it "creates intermediate directories as needed" do Chef::FileCache.store("whiz/bang", "I found a poop") - expect(File).to exist(File.join(@file_cache_path, 'whiz')) + expect(File).to exist(File.join(@file_cache_path, "whiz")) end it "creates the cached file at the correct relative path" do - expect(File).to receive(:open).with(File.join(@file_cache_path, 'whiz', 'bang'), "w",416).and_yield(@io) + expect(File).to receive(:open).with(File.join(@file_cache_path, "whiz", "bang"), "w",416).and_yield(@io) Chef::FileCache.store("whiz/bang", "borkborkbork") end @@ -56,35 +56,35 @@ describe Chef::FileCache do describe "when loading cached files" do it "finds and reads the cached file" do - FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz')) - File.open(File.join(@file_cache_path, 'whiz', 'bang'), 'w') { |f| f.print("borkborkbork") } - expect(Chef::FileCache.load('whiz/bang')).to eq('borkborkbork') + FileUtils.mkdir_p(File.join(@file_cache_path, "whiz")) + File.open(File.join(@file_cache_path, "whiz", "bang"), "w") { |f| f.print("borkborkbork") } + expect(Chef::FileCache.load("whiz/bang")).to eq("borkborkbork") end it "should raise a Chef::Exceptions::FileNotFound if the file doesn't exist" do - expect { Chef::FileCache.load('whiz/bang') }.to raise_error(Chef::Exceptions::FileNotFound) + expect { Chef::FileCache.load("whiz/bang") }.to raise_error(Chef::Exceptions::FileNotFound) end end describe "when deleting cached files" do before(:each) do - FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz')) - File.open(File.join(@file_cache_path, 'whiz', 'bang'), 'w') { |f| f.print("borkborkbork") } + FileUtils.mkdir_p(File.join(@file_cache_path, "whiz")) + File.open(File.join(@file_cache_path, "whiz", "bang"), "w") { |f| f.print("borkborkbork") } end it "unlinks the file" do Chef::FileCache.delete("whiz/bang") - expect(File).not_to exist(File.join(@file_cache_path, 'whiz', 'bang')) + expect(File).not_to exist(File.join(@file_cache_path, "whiz", "bang")) end end describe "when listing files in the cache" do before(:each) do - FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz')) - FileUtils.touch(File.join(@file_cache_path, 'whiz', 'bang')) - FileUtils.mkdir_p(File.join(@file_cache_path, 'snappy')) - FileUtils.touch(File.join(@file_cache_path, 'snappy', 'patter')) + FileUtils.mkdir_p(File.join(@file_cache_path, "whiz")) + FileUtils.touch(File.join(@file_cache_path, "whiz", "bang")) + FileUtils.mkdir_p(File.join(@file_cache_path, "snappy")) + FileUtils.touch(File.join(@file_cache_path, "snappy", "patter")) end it "should return the relative paths" do @@ -92,18 +92,18 @@ describe Chef::FileCache do end it "searches for cached files by globbing" do - expect(Chef::FileCache.find('snappy/**/*')).to eq(%w{snappy/patter}) + expect(Chef::FileCache.find("snappy/**/*")).to eq(%w{snappy/patter}) end end describe "when checking for the existence of a file" do before do - FileUtils.mkdir_p(File.join(@file_cache_path, 'whiz')) + FileUtils.mkdir_p(File.join(@file_cache_path, "whiz")) end it "has a key if the corresponding cache file exists" do - FileUtils.touch(File.join(@file_cache_path, 'whiz', 'bang')) + FileUtils.touch(File.join(@file_cache_path, "whiz", "bang")) expect(Chef::FileCache).to have_key("whiz/bang") end diff --git a/spec/unit/file_content_management/deploy/cp_spec.rb b/spec/unit/file_content_management/deploy/cp_spec.rb index 5c6583e8a6..d99839710a 100644 --- a/spec/unit/file_content_management/deploy/cp_spec.rb +++ b/spec/unit/file_content_management/deploy/cp_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::FileContentManagement::Deploy::Cp do diff --git a/spec/unit/file_content_management/deploy/mv_unix_spec.rb b/spec/unit/file_content_management/deploy/mv_unix_spec.rb index 4511f91180..bebde96295 100644 --- a/spec/unit/file_content_management/deploy/mv_unix_spec.rb +++ b/spec/unit/file_content_management/deploy/mv_unix_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::FileContentManagement::Deploy::MvUnix do diff --git a/spec/unit/file_content_management/deploy/mv_windows_spec.rb b/spec/unit/file_content_management/deploy/mv_windows_spec.rb index 2d1981befc..7deeacf7ea 100644 --- a/spec/unit/file_content_management/deploy/mv_windows_spec.rb +++ b/spec/unit/file_content_management/deploy/mv_windows_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" unless Chef::Platform.windows? class Chef @@ -31,7 +31,7 @@ unless Chef::Platform.windows? end end -require 'chef/file_content_management/deploy/mv_windows' +require "chef/file_content_management/deploy/mv_windows" describe Chef::FileContentManagement::Deploy::MvWindows do diff --git a/spec/unit/formatters/base_spec.rb b/spec/unit/formatters/base_spec.rb index 6a843ea775..9fe8109e98 100644 --- a/spec/unit/formatters/base_spec.rb +++ b/spec/unit/formatters/base_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Formatters::Base do let(:out) { double("out") } diff --git a/spec/unit/formatters/doc_spec.rb b/spec/unit/formatters/doc_spec.rb index b0be913304..d622b27bf9 100644 --- a/spec/unit/formatters/doc_spec.rb +++ b/spec/unit/formatters/doc_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Formatters::Base do diff --git a/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb b/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb index 6f90ea0b27..b417c76f8a 100644 --- a/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb +++ b/spec/unit/formatters/error_inspectors/api_error_formatting_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/formatters/error_inspectors/api_error_formatting' +require "spec_helper" +require "chef/formatters/error_inspectors/api_error_formatting" describe Chef::Formatters::APIErrorFormatting do let(:class_instance) { (Class.new { include Chef::Formatters::APIErrorFormatting }).new } @@ -43,7 +43,7 @@ describe Chef::Formatters::APIErrorFormatting do before do # mock out the header - allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(Chef::JSONCompat.to_json(return_hash)) + allow(response).to receive(:[]).with("x-ops-server-api-version").and_return(Chef::JSONCompat.to_json(return_hash)) end it "prints an error about client and server API version incompatibility with a min API version" do @@ -65,7 +65,7 @@ describe Chef::Formatters::APIErrorFormatting do context "when response.body['error'] != 'invalid-x-ops-server-api-version'" do before do - allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(nil) + allow(response).to receive(:[]).with("x-ops-server-api-version").and_return(nil) end it "forwards the error_description to describe_http_error" do diff --git a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb index 6cea22680b..d6138f4c11 100644 --- a/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/compile_error_inspector_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" BAD_RECIPE=<<-E # diff --git a/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb index 7e4d89f144..9c4d63a2e8 100644 --- a/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/cookbook_resolve_error_inspector_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Formatters::ErrorInspectors::CookbookResolveErrorInspector do diff --git a/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb index 775a1838f3..0fac218eb5 100644 --- a/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/cookbook_sync_error_inspector_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Formatters::ErrorInspectors::CookbookSyncErrorInspector do before do diff --git a/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb index d2bbffafee..8d882b045e 100644 --- a/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/node_load_error_inspector_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" # spec_helper loads the shared examples already. #require 'support/shared/unit/api_error_inspector_spec' diff --git a/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb index 4c21dadd82..0a8918d158 100644 --- a/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/registration_error_inspector_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" # spec_helper loads the shared examples already. #require 'support/shared/unit/api_error_inspector_spec' diff --git a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb index 5594d6e18a..d4185c2f5c 100644 --- a/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/resource_failure_inspector_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Formatters::ErrorInspectors::ResourceFailureInspector do include Chef::DSL::Recipe diff --git a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb index 1cd97596a7..786b3e0c37 100644 --- a/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb +++ b/spec/unit/formatters/error_inspectors/run_list_expansion_error_inspector_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Formatters::ErrorInspectors::RunListExpansionErrorInspector do before do diff --git a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb index acf1b15fd8..518610c13a 100644 --- a/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb +++ b/spec/unit/guard_interpreter/resource_guard_interpreter_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::GuardInterpreter::ResourceGuardInterpreter do let(:node) do @@ -24,7 +24,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do node.default["kernel"] = Hash.new node.default["kernel"][:machine] = :x86_64.to_s - node.automatic[:os] = 'windows' + node.automatic[:os] = "windows" node end @@ -52,7 +52,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do it "raises an exception if guard_interpreter is set to a resource not derived from Chef::Resource::Script" do parent_resource.guard_interpreter(:file) - expect { guard_interpreter }.to raise_error(ArgumentError, 'Specified guard interpreter class Chef::Resource::File must be a kind of Chef::Resource::Execute resource') + expect { guard_interpreter }.to raise_error(ArgumentError, "Specified guard interpreter class Chef::Resource::File must be a kind of Chef::Resource::Execute resource") end context "when the resource cannot be found for the platform" do @@ -62,7 +62,7 @@ describe Chef::GuardInterpreter::ResourceGuardInterpreter do it "raises an exception" do parent_resource.guard_interpreter(:foobar) - expect { guard_interpreter }.to raise_error(ArgumentError, 'Specified guard_interpreter resource foobar unknown for this platform') + expect { guard_interpreter }.to raise_error(ArgumentError, "Specified guard_interpreter resource foobar unknown for this platform") end end diff --git a/spec/unit/guard_interpreter_spec.rb b/spec/unit/guard_interpreter_spec.rb index a7fe064948..10084a156e 100644 --- a/spec/unit/guard_interpreter_spec.rb +++ b/spec/unit/guard_interpreter_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::GuardInterpreter do describe "#for_resource" do diff --git a/spec/unit/handler/json_file_spec.rb b/spec/unit/handler/json_file_spec.rb index f6c14a166e..76098e2522 100644 --- a/spec/unit/handler/json_file_spec.rb +++ b/spec/unit/handler/json_file_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Handler::JsonFile do before(:each) do - @handler = Chef::Handler::JsonFile.new(:the_sun => "will rise", :path => '/tmp/foobarbazqux') + @handler = Chef::Handler::JsonFile.new(:the_sun => "will rise", :path => "/tmp/foobarbazqux") end it "accepts arbitrary config options" do @@ -28,8 +28,8 @@ describe Chef::Handler::JsonFile do end it "creates the directory where the reports will be saved" do - expect(FileUtils).to receive(:mkdir_p).with('/tmp/foobarbazqux') - expect(File).to receive(:chmod).with(00700, '/tmp/foobarbazqux') + expect(FileUtils).to receive(:mkdir_p).with("/tmp/foobarbazqux") + expect(File).to receive(:chmod).with(00700, "/tmp/foobarbazqux") @handler.build_report_dir end @@ -54,10 +54,10 @@ describe Chef::Handler::JsonFile do expect(@handler).to receive(:build_report_dir) @handler.run_report_unsafe(@run_status) reported_data = Chef::JSONCompat.from_json(@file_mock.string) - expect(reported_data['exception']).to eq("Exception: Boy howdy!") - expect(reported_data['start_time']).to eq(@expected_time.to_s) - expect(reported_data['end_time']).to eq((@expected_time + 5).to_s) - expect(reported_data['elapsed_time']).to eq(5) + expect(reported_data["exception"]).to eq("Exception: Boy howdy!") + expect(reported_data["start_time"]).to eq(@expected_time.to_s) + expect(reported_data["end_time"]).to eq((@expected_time + 5).to_s) + expect(reported_data["elapsed_time"]).to eq(5) end end diff --git a/spec/unit/handler_spec.rb b/spec/unit/handler_spec.rb index e7f67405fc..f3e527b69d 100644 --- a/spec/unit/handler_spec.rb +++ b/spec/unit/handler_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Handler do before(:each) do @@ -36,7 +36,7 @@ describe Chef::Handler do @exception.set_backtrace(@backtrace) @run_status.exception = @exception @run_context = Chef::RunContext.new(@node, {}, @events) - @all_resources = [Chef::Resource::Cat.new('lolz'), Chef::Resource::ZenMaster.new('tzu')] + @all_resources = [Chef::Resource::Cat.new("lolz"), Chef::Resource::ZenMaster.new("tzu")] @all_resources.first.updated = true @run_context.resource_collection.all_resources.replace(@all_resources) @run_status.run_context = @run_context @@ -117,7 +117,7 @@ describe Chef::Handler do describe "when running a report handler" do before do @run_context = Chef::RunContext.new(@node, {}, @events) - @all_resources = [Chef::Resource::Cat.new('foo'), Chef::Resource::ZenMaster.new('moo')] + @all_resources = [Chef::Resource::Cat.new("foo"), Chef::Resource::ZenMaster.new("moo")] @all_resources.first.updated = true @run_context.resource_collection.all_resources.replace(@all_resources) @run_status.run_context = @run_context diff --git a/spec/unit/http/authenticator_spec.rb b/spec/unit/http/authenticator_spec.rb index 48bbdcf76c..1289ebb61e 100644 --- a/spec/unit/http/authenticator_spec.rb +++ b/spec/unit/http/authenticator_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/http/authenticator' +require "spec_helper" +require "chef/http/authenticator" describe Chef::HTTP::Authenticator do let(:class_instance) { Chef::HTTP::Authenticator.new } @@ -35,15 +35,15 @@ describe Chef::HTTP::Authenticator do it "merges the default version of X-Ops-Server-API-Version into the headers" do # headers returned expect(class_instance.handle_request(method, url, headers, data)[2]). - to include({'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}) + to include({"X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}) end context "when api_version is set to something other than the default" do - let(:class_instance) { Chef::HTTP::Authenticator.new({:api_version => '-10'}) } + let(:class_instance) { Chef::HTTP::Authenticator.new({:api_version => "-10"}) } it "merges the requested version of X-Ops-Server-API-Version into the headers" do expect(class_instance.handle_request(method, url, headers, data)[2]). - to include({'X-Ops-Server-API-Version' => '-10'}) + to include({"X-Ops-Server-API-Version" => "-10"}) end end end diff --git a/spec/unit/http/basic_client_spec.rb b/spec/unit/http/basic_client_spec.rb index 16f62f8d97..4abdb52620 100644 --- a/spec/unit/http/basic_client_spec.rb +++ b/spec/unit/http/basic_client_spec.rb @@ -15,8 +15,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/http/basic_client' +require "spec_helper" +require "chef/http/basic_client" describe "HTTP Connection" do diff --git a/spec/unit/http/http_request_spec.rb b/spec/unit/http/http_request_spec.rb index 3bba201963..33da210c36 100644 --- a/spec/unit/http/http_request_spec.rb +++ b/spec/unit/http/http_request_spec.rb @@ -16,40 +16,40 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::HTTP::HTTPRequest do context "with HTTP url scheme" do it "should not include port 80 in Host header" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com'), '') + request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com"), "") - expect(request.headers['Host']).to eql('dummy.com') + expect(request.headers["Host"]).to eql("dummy.com") end it "should not include explicit port 80 in Host header" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:80'), '') + request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:80"), "") - expect(request.headers['Host']).to eql('dummy.com') + expect(request.headers["Host"]).to eql("dummy.com") end it "should include explicit port 8000 in Host header" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '') + request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:8000"), "") - expect(request.headers['Host']).to eql('dummy.com:8000') + expect(request.headers["Host"]).to eql("dummy.com:8000") end it "should include explicit 443 port in Host header" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:443'), '') + request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:443"), "") - expect(request.headers['Host']).to eql('dummy.com:443') + expect(request.headers["Host"]).to eql("dummy.com:443") end it "should pass on explicit Host header unchanged" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '', { 'Host' => 'yourhost.com:8888' }) + request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:8000"), "", { "Host" => "yourhost.com:8888" }) - expect(request.headers['Host']).to eql('yourhost.com:8888') + expect(request.headers["Host"]).to eql("yourhost.com:8888") end end @@ -57,35 +57,35 @@ describe Chef::HTTP::HTTPRequest do context "with HTTPS url scheme" do it "should not include port 443 in Host header" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com'), '') + request = Chef::HTTP::HTTPRequest.new(:GET, URI("https://dummy.com"), "") - expect(request.headers['Host']).to eql('dummy.com') + expect(request.headers["Host"]).to eql("dummy.com") end it "should include explicit port 80 in Host header" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:80'), '') + request = Chef::HTTP::HTTPRequest.new(:GET, URI("https://dummy.com:80"), "") - expect(request.headers['Host']).to eql('dummy.com:80') + expect(request.headers["Host"]).to eql("dummy.com:80") end it "should include explicit port 8000 in Host header" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:8000'), '') + request = Chef::HTTP::HTTPRequest.new(:GET, URI("https://dummy.com:8000"), "") - expect(request.headers['Host']).to eql('dummy.com:8000') + expect(request.headers["Host"]).to eql("dummy.com:8000") end it "should not include explicit port 443 in Host header" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('https://dummy.com:443'), '') + request = Chef::HTTP::HTTPRequest.new(:GET, URI("https://dummy.com:443"), "") - expect(request.headers['Host']).to eql('dummy.com') + expect(request.headers["Host"]).to eql("dummy.com") end end it "should pass on explicit Host header unchanged" do - request = Chef::HTTP::HTTPRequest.new(:GET, URI('http://dummy.com:8000'), '', { 'Host' => 'myhost.com:80' }) + request = Chef::HTTP::HTTPRequest.new(:GET, URI("http://dummy.com:8000"), "", { "Host" => "myhost.com:80" }) - expect(request.headers['Host']).to eql('myhost.com:80') + expect(request.headers["Host"]).to eql("myhost.com:80") end end diff --git a/spec/unit/http/json_input_spec.rb b/spec/unit/http/json_input_spec.rb index fbf8f22503..6bc2bbf018 100644 --- a/spec/unit/http/json_input_spec.rb +++ b/spec/unit/http/json_input_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/http/json_input' +require "spec_helper" +require "chef/http/json_input" describe Chef::HTTP::JSONInput do diff --git a/spec/unit/http/simple_spec.rb b/spec/unit/http/simple_spec.rb index c8fb52e8b2..f132f1a890 100644 --- a/spec/unit/http/simple_spec.rb +++ b/spec/unit/http/simple_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::HTTP::Simple do it "should have content length validation middleware after compressor middleware" do diff --git a/spec/unit/http/socketless_chef_zero_client_spec.rb b/spec/unit/http/socketless_chef_zero_client_spec.rb index 963cc9e8c4..b65deafe53 100644 --- a/spec/unit/http/socketless_chef_zero_client_spec.rb +++ b/spec/unit/http/socketless_chef_zero_client_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'chef/http/socketless_chef_zero_client' +require "chef/http/socketless_chef_zero_client" describe Chef::HTTP::SocketlessChefZeroClient do diff --git a/spec/unit/http/ssl_policies_spec.rb b/spec/unit/http/ssl_policies_spec.rb index 5ebebf39b1..98f1fa9c37 100644 --- a/spec/unit/http/ssl_policies_spec.rb +++ b/spec/unit/http/ssl_policies_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/http/ssl_policies' +require "spec_helper" +require "chef/http/ssl_policies" describe "HTTP SSL Policy" do @@ -68,8 +68,8 @@ describe "HTTP SSL Policy" do end it "should set the CA file if that is set in the configuration" do - Chef::Config[:ssl_ca_file] = CHEF_SPEC_DATA + '/ssl/5e707473.0' - expect(http_client.ca_file).to eq(CHEF_SPEC_DATA + '/ssl/5e707473.0') + Chef::Config[:ssl_ca_file] = CHEF_SPEC_DATA + "/ssl/5e707473.0" + expect(http_client.ca_file).to eq(CHEF_SPEC_DATA + "/ssl/5e707473.0") end end @@ -89,12 +89,12 @@ describe "HTTP SSL Policy" do it "raises ConfigurationError if the certificate file doesn't exist" do Chef::Config[:ssl_client_cert] = "/dev/null/nothing_here" - Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + '/ssl/chef-rspec.key' + Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + "/ssl/chef-rspec.key" expect {http_client}.to raise_error(Chef::Exceptions::ConfigurationError) end it "raises ConfigurationError if the certificate file doesn't exist" do - Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + '/ssl/chef-rspec.cert' + Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + "/ssl/chef-rspec.cert" Chef::Config[:ssl_client_key] = "/dev/null/nothing_here" expect {http_client}.to raise_error(Chef::Exceptions::ConfigurationError) end @@ -106,10 +106,10 @@ describe "HTTP SSL Policy" do end it "configures the HTTP client's cert and private key" do - Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + '/ssl/chef-rspec.cert' - Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + '/ssl/chef-rspec.key' - expect(http_client.cert.to_s).to eq(OpenSSL::X509::Certificate.new(IO.read(CHEF_SPEC_DATA + '/ssl/chef-rspec.cert')).to_s) - expect(http_client.key.to_s).to eq(IO.read(CHEF_SPEC_DATA + '/ssl/chef-rspec.key')) + Chef::Config[:ssl_client_cert] = CHEF_SPEC_DATA + "/ssl/chef-rspec.cert" + Chef::Config[:ssl_client_key] = CHEF_SPEC_DATA + "/ssl/chef-rspec.key" + expect(http_client.cert.to_s).to eq(OpenSSL::X509::Certificate.new(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.cert")).to_s) + expect(http_client.key.to_s).to eq(IO.read(CHEF_SPEC_DATA + "/ssl/chef-rspec.key")) end end diff --git a/spec/unit/http/validate_content_length_spec.rb b/spec/unit/http/validate_content_length_spec.rb index 16eede1859..18b0bead70 100644 --- a/spec/unit/http/validate_content_length_spec.rb +++ b/spec/unit/http/validate_content_length_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'stringio' +require "spec_helper" +require "stringio" describe Chef::HTTP::ValidateContentLength do class TestClient < Chef::HTTP @@ -44,7 +44,7 @@ describe Chef::HTTP::ValidateContentLength do } let(:response) { - m = double('HttpResponse', :body => response_body) + m = double("HttpResponse", :body => response_body) allow(m).to receive(:[]) do |key| response_headers[key] end diff --git a/spec/unit/http_spec.rb b/spec/unit/http_spec.rb index ebb96d25e1..c35f8baaeb 100644 --- a/spec/unit/http_spec.rb +++ b/spec/unit/http_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/http' -require 'chef/http/basic_client' -require 'chef/http/socketless_chef_zero_client' +require "chef/http" +require "chef/http/basic_client" +require "chef/http/socketless_chef_zero_client" class Chef::HTTP public :create_url @@ -43,26 +43,26 @@ describe Chef::HTTP do describe "create_url" do - it 'should return a correctly formatted url 1/3 CHEF-5261' do - http = Chef::HTTP.new('http://www.getchef.com') - expect(http.create_url('api/endpoint')).to eql(URI.parse('http://www.getchef.com/api/endpoint')) + it "should return a correctly formatted url 1/3 CHEF-5261" do + http = Chef::HTTP.new("http://www.getchef.com") + expect(http.create_url("api/endpoint")).to eql(URI.parse("http://www.getchef.com/api/endpoint")) end - it 'should return a correctly formatted url 2/3 CHEF-5261' do - http = Chef::HTTP.new('http://www.getchef.com/') - expect(http.create_url('/organization/org/api/endpoint/')).to eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint/')) + it "should return a correctly formatted url 2/3 CHEF-5261" do + http = Chef::HTTP.new("http://www.getchef.com/") + expect(http.create_url("/organization/org/api/endpoint/")).to eql(URI.parse("http://www.getchef.com/organization/org/api/endpoint/")) end - it 'should return a correctly formatted url 3/3 CHEF-5261' do - http = Chef::HTTP.new('http://www.getchef.com/organization/org///') - expect(http.create_url('///api/endpoint?url=http://foo.bar')).to eql(URI.parse('http://www.getchef.com/organization/org/api/endpoint?url=http://foo.bar')) + it "should return a correctly formatted url 3/3 CHEF-5261" do + http = Chef::HTTP.new("http://www.getchef.com/organization/org///") + expect(http.create_url("///api/endpoint?url=http://foo.bar")).to eql(URI.parse("http://www.getchef.com/organization/org/api/endpoint?url=http://foo.bar")) end # As per: https://github.com/opscode/chef/issues/2500 - it 'should treat scheme part of the URI in a case-insensitive manner' do + it "should treat scheme part of the URI in a case-insensitive manner" do http = Chef::HTTP.allocate # Calling Chef::HTTP::new sets @url, don't want that. - expect { http.create_url('HTTP://www1.chef.io/') }.not_to raise_error - expect(http.create_url('HTTP://www2.chef.io/')).to eql(URI.parse('http://www2.chef.io/')) + expect { http.create_url("HTTP://www1.chef.io/") }.not_to raise_error + expect(http.create_url("HTTP://www2.chef.io/")).to eql(URI.parse("http://www2.chef.io/")) end end # create_url @@ -117,7 +117,7 @@ describe Chef::HTTP do end it "retries the request 5 times" do - http.get('/') + http.get("/") end end diff --git a/spec/unit/json_compat_spec.rb b/spec/unit/json_compat_spec.rb index fd6469c146..524b71f09a 100644 --- a/spec/unit/json_compat_spec.rb +++ b/spec/unit/json_compat_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require File.expand_path('../../spec_helper', __FILE__) -require 'chef/json_compat' +require File.expand_path("../../spec_helper", __FILE__) +require "chef/json_compat" describe Chef::JSONCompat do @@ -46,7 +46,7 @@ describe Chef::JSONCompat do end describe 'with JSON containing "Chef::Sandbox" as a json_class value' do - require 'chef/sandbox' # Only needed for this test + require "chef/sandbox" # Only needed for this test let(:json) { '{"json_class": "Chef::Sandbox", "arbitrary": "data"}' } @@ -58,7 +58,7 @@ describe Chef::JSONCompat do describe "when pretty printing an object that defines #to_json" do class Foo def to_json(*a) - Chef::JSONCompat.to_json({'foo' => 1234, 'bar' => {'baz' => 5678}}, *a) + Chef::JSONCompat.to_json({"foo" => 1234, "bar" => {"baz" => 5678}}, *a) end end @@ -73,7 +73,7 @@ describe Chef::JSONCompat do end describe "with the file with 252 or less nested entries" do - let(:json) { IO.read(File.join(CHEF_SPEC_DATA, 'nested.json')) } + let(:json) { IO.read(File.join(CHEF_SPEC_DATA, "nested.json")) } let(:hash) { Chef::JSONCompat.from_json(json) } describe "when the 252 json file is loaded" do @@ -83,9 +83,9 @@ describe Chef::JSONCompat do it "should has 'test' as a 252 nested value" do v = 252.times.inject(hash) do |memo, _| - memo['key'] + memo["key"] end - expect(v).to eq('test') + expect(v).to eq("test") end end end diff --git a/spec/unit/key_spec.rb b/spec/unit/key_spec.rb index 64601cfbab..95124b5e8f 100644 --- a/spec/unit/key_spec.rb +++ b/spec/unit/key_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/key' +require "chef/key" describe Chef::Key do # whether user or client irrelevent to these tests @@ -341,7 +341,7 @@ EOS let(:rest) do Chef::Config[:chef_server_root] = "http://www.example.com" Chef::Config[:chef_server_url] = "http://www.example.com/organizations/test_org" - r = double('rest') + r = double("rest") allow(Chef::ServerAPI).to receive(:new).and_return(r) r end diff --git a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb index 75e0ff6b00..4bdd994906 100644 --- a/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb +++ b/spec/unit/knife/bootstrap/chef_vault_handler_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::Bootstrap::ChefVaultHandler do @@ -57,29 +57,29 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do context "from knife_config[:bootstrap_vault_item]" do it "sets a single item as a scalar" do - knife_config[:bootstrap_vault_item] = { 'vault' => 'item1' } - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) + knife_config[:bootstrap_vault_item] = { "vault" => "item1" } + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets a single item as an array" do - knife_config[:bootstrap_vault_item] = { 'vault' => [ 'item1' ] } - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) + knife_config[:bootstrap_vault_item] = { "vault" => [ "item1" ] } + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two items as an array" do - knife_config[:bootstrap_vault_item] = { 'vault' => [ 'item1', 'item2' ] } - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item) + knife_config[:bootstrap_vault_item] = { "vault" => [ "item1", "item2" ] } + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two vaults from different hash keys" do - knife_config[:bootstrap_vault_item] = { 'vault' => [ 'item1', 'item2' ], 'vault2' => [ 'item3' ] } - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault2', 'item3').and_return(bootstrap_vault_item) + knife_config[:bootstrap_vault_item] = { "vault" => [ "item1", "item2" ], "vault2" => [ "item3" ] } + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end end @@ -87,28 +87,28 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do context "from knife_config[:bootstrap_vault_json]" do it "sets a single item as a scalar" do knife_config[:bootstrap_vault_json] = '{ "vault": "item1" }' - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets a single item as an array" do knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1" ] }' - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two items as an array" do knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1", "item2" ] }' - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two vaults from different hash keys" do knife_config[:bootstrap_vault_json] = '{ "vault": [ "item1", "item2" ], "vault2": [ "item3" ] }' - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault2', 'item3').and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end end @@ -123,28 +123,28 @@ describe Chef::Knife::Bootstrap::ChefVaultHandler do it "sets a single item as a scalar" do setup_file_contents('{ "vault": "item1" }') - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets a single item as an array" do setup_file_contents('{ "vault": [ "item1" ] }') - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two items as an array" do setup_file_contents('{ "vault": [ "item1", "item2" ] }') - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end it "sets two vaults from different hash keys" do setup_file_contents('{ "vault": [ "item1", "item2" ], "vault2": [ "item3" ] }') - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item1').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault', 'item2').and_return(bootstrap_vault_item) - expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with('vault2', 'item3').and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item1").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault", "item2").and_return(bootstrap_vault_item) + expect(chef_vault_handler).to receive(:load_chef_bootstrap_vault_item).with("vault2", "item3").and_return(bootstrap_vault_item) chef_vault_handler.run(client) end end diff --git a/spec/unit/knife/bootstrap/client_builder_spec.rb b/spec/unit/knife/bootstrap/client_builder_spec.rb index 6812a24c91..791b84b9c3 100644 --- a/spec/unit/knife/bootstrap/client_builder_spec.rb +++ b/spec/unit/knife/bootstrap/client_builder_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::Bootstrap::ClientBuilder do @@ -42,7 +42,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do } context "#sanity_check!" do - let(:response_404) { OpenStruct.new(:code => '404') } + let(:response_404) { OpenStruct.new(:code => "404") } let(:exception_404) { Net::HTTPServerException.new("404 not found", response_404) } context "in cases where the prompting fails" do @@ -54,14 +54,14 @@ describe Chef::Knife::Bootstrap::ClientBuilder do it "exits when the node exists and the user does not want to delete" do expect(rest).to receive(:get).with("nodes/#{node_name}") - expect(ui.stdin).to receive(:readline).and_return('n') + expect(ui.stdin).to receive(:readline).and_return("n") expect { client_builder.run }.to raise_error(SystemExit) end it "exits when the client exists and the user does not want to delete" do expect(rest).to receive(:get).with("nodes/#{node_name}").and_raise(exception_404) expect(rest).to receive(:get).with("clients/#{node_name}") - expect(ui.stdin).to receive(:readline).and_return('n') + expect(ui.stdin).to receive(:readline).and_return("n") expect { client_builder.run }.to raise_error(SystemExit) end end @@ -81,7 +81,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do it "when we are allowed to delete an old node" do expect(rest).to receive(:get).with("nodes/#{node_name}") - expect(ui.stdin).to receive(:readline).and_return('y') + expect(ui.stdin).to receive(:readline).and_return("y") expect(rest).to receive(:get).with("clients/#{node_name}").and_raise(exception_404) expect(rest).to receive(:delete).with("nodes/#{node_name}") expect { client_builder.run }.not_to raise_error @@ -90,7 +90,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do it "when we are allowed to delete an old client" do expect(rest).to receive(:get).with("nodes/#{node_name}").and_raise(exception_404) expect(rest).to receive(:get).with("clients/#{node_name}") - expect(ui.stdin).to receive(:readline).and_return('y') + expect(ui.stdin).to receive(:readline).and_return("y") expect(rest).to receive(:delete).with("clients/#{node_name}") expect { client_builder.run }.not_to raise_error end @@ -98,7 +98,7 @@ describe Chef::Knife::Bootstrap::ClientBuilder do it "when we are are allowed to delete both an old client and node" do expect(rest).to receive(:get).with("nodes/#{node_name}") expect(rest).to receive(:get).with("clients/#{node_name}") - expect(ui.stdin).to receive(:readline).twice.and_return('y') + expect(ui.stdin).to receive(:readline).twice.and_return("y") expect(rest).to receive(:delete).with("nodes/#{node_name}") expect(rest).to receive(:delete).with("clients/#{node_name}") expect { client_builder.run }.not_to raise_error diff --git a/spec/unit/knife/bootstrap_spec.rb b/spec/unit/knife/bootstrap_spec.rb index b4babdc14f..c64b2e49ea 100644 --- a/spec/unit/knife/bootstrap_spec.rb +++ b/spec/unit/knife/bootstrap_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::Bootstrap.load_deps -require 'net/ssh' +require "net/ssh" describe Chef::Knife::Bootstrap do before do @@ -102,7 +102,7 @@ describe Chef::Knife::Bootstrap do context "when :bootstrap_template config is set to a template name" do let(:bootstrap_template) { "example" } - let(:builtin_template_path) { File.expand_path(File.join(File.dirname(__FILE__), '../../../lib/chef/knife/bootstrap/templates', "example.erb"))} + let(:builtin_template_path) { File.expand_path(File.join(File.dirname(__FILE__), "../../../lib/chef/knife/bootstrap/templates", "example.erb"))} let(:chef_config_dir_template_path) { "/knife/chef/config/bootstrap/example.erb" } @@ -237,7 +237,7 @@ describe Chef::Knife::Bootstrap do context "with bootstrap_attribute options" do let(:jsonfile) { - file = Tempfile.new (['node', '.json']) + file = Tempfile.new (["node", ".json"]) File.open(file.path, "w") {|f| f.puts '{"foo":{"bar":"baz"}}' } file } @@ -385,7 +385,7 @@ describe Chef::Knife::Bootstrap do end describe "when transferring trusted certificates" do - let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(File.dirname(__FILE__), '../../data/trusted_certs')) } + let(:trusted_certs_dir) { Chef::Util::PathHelper.cleanpath(File.join(File.dirname(__FILE__), "../../data/trusted_certs")) } let(:rendered_template) do knife.merge_configs @@ -509,15 +509,15 @@ describe Chef::Knife::Bootstrap do end it "configures the ssh user" do - expect(knife_ssh.config[:ssh_user]).to eq('rooty') + expect(knife_ssh.config[:ssh_user]).to eq("rooty") end it "configures the ssh password" do - expect(knife_ssh.config[:ssh_password]).to eq('open_sesame') + expect(knife_ssh.config[:ssh_password]).to eq("open_sesame") end it "configures the ssh port" do - expect(knife_ssh.config[:ssh_port]).to eq('4001') + expect(knife_ssh.config[:ssh_port]).to eq("4001") end it "configures the ssh agent forwarding" do @@ -525,7 +525,7 @@ describe Chef::Knife::Bootstrap do end it "configures the ssh identity file" do - expect(knife_ssh.config[:ssh_identity_file]).to eq('~/.ssh/me.rsa') + expect(knife_ssh.config[:ssh_identity_file]).to eq("~/.ssh/me.rsa") end end @@ -537,8 +537,8 @@ describe Chef::Knife::Bootstrap do it "use_sudo_password contains description and long params for help" do expect(knife.options).to have_key(:use_sudo_password) \ - and expect(knife.options[:use_sudo_password][:description].to_s).not_to eq('')\ - and expect(knife.options[:use_sudo_password][:long].to_s).not_to eq('') + and expect(knife.options[:use_sudo_password][:description].to_s).not_to eq("")\ + and expect(knife.options[:use_sudo_password][:long].to_s).not_to eq("") end it "uses the password from --ssh-password for sudo when --use-sudo-password is set" do @@ -570,11 +570,11 @@ describe Chef::Knife::Bootstrap do end it "configures the ssh user" do - expect(knife_ssh.config[:ssh_user]).to eq('curiosity') + expect(knife_ssh.config[:ssh_user]).to eq("curiosity") end it "configures the ssh port" do - expect(knife_ssh.config[:ssh_port]).to eq('2430') + expect(knife_ssh.config[:ssh_port]).to eq("2430") end it "configures the ssh agent forwarding" do @@ -582,11 +582,11 @@ describe Chef::Knife::Bootstrap do end it "configures the ssh identity file" do - expect(knife_ssh.config[:ssh_identity_file]).to eq('~/.ssh/you.rsa') + expect(knife_ssh.config[:ssh_identity_file]).to eq("~/.ssh/you.rsa") end it "configures the ssh gateway" do - expect(knife_ssh.config[:ssh_gateway]).to eq('towel.blinkenlights.nl') + expect(knife_ssh.config[:ssh_gateway]).to eq("towel.blinkenlights.nl") end it "configures the host key verify mode" do @@ -601,13 +601,13 @@ describe Chef::Knife::Bootstrap do knife.config[:ssh_identity_file] = "~/.ssh/me.rsa" allow(knife).to receive(:render_template).and_return("") k = knife.knife_ssh - allow(k).to receive(:get_password).and_return('typed_in_password') + allow(k).to receive(:get_password).and_return("typed_in_password") allow(knife).to receive(:knife_ssh).and_return(k) knife.knife_ssh_with_password_auth end it "prompts the user for a password " do - expect(knife_ssh_with_password_auth.config[:ssh_password]).to eq('typed_in_password') + expect(knife_ssh_with_password_auth.config[:ssh_password]).to eq("typed_in_password") end it "configures knife not to use the identity file that didn't work previously" do diff --git a/spec/unit/knife/client_bulk_delete_spec.rb b/spec/unit/knife/client_bulk_delete_spec.rb index 1a6317ac00..30bd8b5b97 100644 --- a/spec/unit/knife/client_bulk_delete_spec.rb +++ b/spec/unit/knife/client_bulk_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::ClientBulkDelete do let(:stdout_io) { StringIO.new } diff --git a/spec/unit/knife/client_create_spec.rb b/spec/unit/knife/client_create_spec.rb index 9066505dfd..359271672e 100644 --- a/spec/unit/knife/client_create_spec.rb +++ b/spec/unit/knife/client_create_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::ClientCreate.load_deps @@ -61,13 +61,13 @@ describe Chef::Knife::ClientCreate do # from spec/support/shared/unit/knife_shared.rb it_should_behave_like "mandatory field missing" do let(:name_args) { [] } - let(:fieldname) { 'client name' } + let(:fieldname) { "client name" } end end context "when clientname is passed" do before do - knife.name_args = ['adam'] + knife.name_args = ["adam"] end context "when public_key and prevent_keygen are passed" do @@ -131,7 +131,7 @@ describe Chef::Knife::ClientCreate do it "should write the private key to a file" do knife.config[:file] = "/tmp/monkeypants" filehandle = double("Filehandle") - expect(filehandle).to receive(:print).with('woot') + expect(filehandle).to receive(:print).with("woot") expect(File).to receive(:open).with("/tmp/monkeypants", "w").and_yield(filehandle) knife.run end @@ -150,14 +150,14 @@ describe Chef::Knife::ClientCreate do describe "with -p or --public-key" do before do - knife.config[:public_key] = 'some_key' - allow(File).to receive(:read).and_return('some_key') + knife.config[:public_key] = "some_key" + allow(File).to receive(:read).and_return("some_key") allow(File).to receive(:expand_path) end it "sets the public key" do knife.run - expect(client.public_key).to eq('some_key') + expect(client.public_key).to eq("some_key") end end diff --git a/spec/unit/knife/client_delete_spec.rb b/spec/unit/knife/client_delete_spec.rb index 619009979b..e08a9c59c8 100644 --- a/spec/unit/knife/client_delete_spec.rb +++ b/spec/unit/knife/client_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::ClientDelete do before(:each) do @@ -25,16 +25,16 @@ describe Chef::Knife::ClientDelete do @knife.config = { :delete_validators => false } - @knife.name_args = [ 'adam' ] + @knife.name_args = [ "adam" ] end - describe 'run' do - it 'should delete the client' do - expect(@knife).to receive(:delete_object).with(Chef::ApiClientV1, 'adam', 'client') + describe "run" do + it "should delete the client" do + expect(@knife).to receive(:delete_object).with(Chef::ApiClientV1, "adam", "client") @knife.run end - it 'should print usage and exit when a client name is not provided' do + it "should print usage and exit when a client name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) @@ -42,7 +42,7 @@ describe Chef::Knife::ClientDelete do end end - describe 'with a validator' do + describe "with a validator" do before(:each) do allow(Chef::Knife::UI).to receive(:confirm).and_return(true) allow(@knife).to receive(:confirm).and_return(true) @@ -50,7 +50,7 @@ describe Chef::Knife::ClientDelete do expect(Chef::ApiClientV1).to receive(:load).and_return(@client) end - it 'should delete non-validator client if --delete-validators is not set' do + it "should delete non-validator client if --delete-validators is not set" do @knife.config[:delete_validators] = false expect(@client).to receive(:destroy).and_return(@client) expect(@knife).to receive(:msg) @@ -58,7 +58,7 @@ describe Chef::Knife::ClientDelete do @knife.run end - it 'should delete non-validator client if --delete-validators is set' do + it "should delete non-validator client if --delete-validators is set" do @knife.config[:delete_validators] = true expect(@client).to receive(:destroy).and_return(@client) expect(@knife).to receive(:msg) @@ -66,13 +66,13 @@ describe Chef::Knife::ClientDelete do @knife.run end - it 'should not delete validator client if --delete-validators is not set' do + it "should not delete validator client if --delete-validators is not set" do @client.validator(true) expect(@knife.ui).to receive(:fatal) expect { @knife.run}.to raise_error(SystemExit) end - it 'should delete validator client if --delete-validators is set' do + it "should delete validator client if --delete-validators is set" do @knife.config[:delete_validators] = true expect(@client).to receive(:destroy).and_return(@client) expect(@knife).to receive(:msg) diff --git a/spec/unit/knife/client_edit_spec.rb b/spec/unit/knife/client_edit_spec.rb index 75b0ef8c92..876dfc5770 100644 --- a/spec/unit/knife/client_edit_spec.rb +++ b/spec/unit/knife/client_edit_spec.rb @@ -16,17 +16,17 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/api_client_v1' +require "spec_helper" +require "chef/api_client_v1" describe Chef::Knife::ClientEdit do before(:each) do @knife = Chef::Knife::ClientEdit.new - @knife.name_args = [ 'adam' ] + @knife.name_args = [ "adam" ] @knife.config[:disable_editing] = true end - describe 'run' do + describe "run" do let(:data) { { "name" => "adam", @@ -37,13 +37,13 @@ describe Chef::Knife::ClientEdit do } } - it 'should edit the client' do - allow(Chef::ApiClientV1).to receive(:load).with('adam').and_return(data) + it "should edit the client" do + allow(Chef::ApiClientV1).to receive(:load).with("adam").and_return(data) expect(@knife).to receive(:edit_data).with(data).and_return(data) @knife.run end - it 'should print usage and exit when a client name is not provided' do + it "should print usage and exit when a client name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) diff --git a/spec/unit/knife/client_list_spec.rb b/spec/unit/knife/client_list_spec.rb index ce0fa4f5e8..03d87022db 100644 --- a/spec/unit/knife/client_list_spec.rb +++ b/spec/unit/knife/client_list_spec.rb @@ -16,16 +16,16 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::ClientList do before(:each) do @knife = Chef::Knife::ClientList.new - @knife.name_args = [ 'adam' ] + @knife.name_args = [ "adam" ] end - describe 'run' do - it 'should list the clients' do + describe "run" do + it "should list the clients" do expect(Chef::ApiClientV1).to receive(:list) expect(@knife).to receive(:format_list_for_display) @knife.run diff --git a/spec/unit/knife/client_reregister_spec.rb b/spec/unit/knife/client_reregister_spec.rb index 7e763242e4..da1f4314b6 100644 --- a/spec/unit/knife/client_reregister_spec.rb +++ b/spec/unit/knife/client_reregister_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::ClientReregister do before(:each) do @knife = Chef::Knife::ClientReregister.new - @knife.name_args = [ 'adam' ] - @client_mock = double('client_mock', :private_key => "foo_key") + @knife.name_args = [ "adam" ] + @client_mock = double("client_mock", :private_key => "foo_key") @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) end @@ -32,28 +32,28 @@ describe Chef::Knife::ClientReregister do @knife.name_args = [] end - it 'should print usage and exit when a client name is not provided' do + it "should print usage and exit when a client name is not provided" do expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) expect { @knife.run }.to raise_error(SystemExit) end end - context 'when not configured for file output' do - it 'reregisters the client and prints the key' do - expect(Chef::ApiClientV1).to receive(:reregister).with('adam').and_return(@client_mock) + context "when not configured for file output" do + it "reregisters the client and prints the key" do + expect(Chef::ApiClientV1).to receive(:reregister).with("adam").and_return(@client_mock) @knife.run expect(@stdout.string).to match( /foo_key/ ) end end - context 'when configured for file output' do - it 'should write the private key to a file' do - expect(Chef::ApiClientV1).to receive(:reregister).with('adam').and_return(@client_mock) + context "when configured for file output" do + it "should write the private key to a file" do + expect(Chef::ApiClientV1).to receive(:reregister).with("adam").and_return(@client_mock) - @knife.config[:file] = '/tmp/monkeypants' + @knife.config[:file] = "/tmp/monkeypants" filehandle = StringIO.new - expect(File).to receive(:open).with('/tmp/monkeypants', 'w').and_yield(filehandle) + expect(File).to receive(:open).with("/tmp/monkeypants", "w").and_yield(filehandle) @knife.run expect(filehandle.string).to eq("foo_key") end diff --git a/spec/unit/knife/client_show_spec.rb b/spec/unit/knife/client_show_spec.rb index 73a876cee0..96a7653d92 100644 --- a/spec/unit/knife/client_show_spec.rb +++ b/spec/unit/knife/client_show_spec.rb @@ -16,33 +16,33 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::ClientShow do before(:each) do @knife = Chef::Knife::ClientShow.new - @knife.name_args = [ 'adam' ] - @client_mock = double('client_mock') + @knife.name_args = [ "adam" ] + @client_mock = double("client_mock") end - describe 'run' do - it 'should list the client' do - expect(Chef::ApiClientV1).to receive(:load).with('adam').and_return(@client_mock) + describe "run" do + it "should list the client" do + expect(Chef::ApiClientV1).to receive(:load).with("adam").and_return(@client_mock) expect(@knife).to receive(:format_for_display).with(@client_mock) @knife.run end - it 'should pretty print json' do - @knife.config[:format] = 'json' + it "should pretty print json" do + @knife.config[:format] = "json" @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) fake_client_contents = {"foo"=>"bar", "baz"=>"qux"} - expect(Chef::ApiClientV1).to receive(:load).with('adam').and_return(fake_client_contents) + expect(Chef::ApiClientV1).to receive(:load).with("adam").and_return(fake_client_contents) @knife.run expect(@stdout.string).to eql("{\n \"foo\": \"bar\",\n \"baz\": \"qux\"\n}\n") end - it 'should print usage and exit when a client name is not provided' do + it "should print usage and exit when a client name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) diff --git a/spec/unit/knife/configure_client_spec.rb b/spec/unit/knife/configure_client_spec.rb index 363743f8cc..a825384785 100644 --- a/spec/unit/knife/configure_client_spec.rb +++ b/spec/unit/knife/configure_client_spec.rb @@ -16,21 +16,21 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::ConfigureClient do before do @knife = Chef::Knife::ConfigureClient.new - Chef::Config[:chef_server_url] = 'https://chef.example.com' - Chef::Config[:validation_client_name] = 'chef-validator' - Chef::Config[:validation_key] = '/etc/chef/validation.pem' + Chef::Config[:chef_server_url] = "https://chef.example.com" + Chef::Config[:validation_client_name] = "chef-validator" + Chef::Config[:validation_key] = "/etc/chef/validation.pem" @stderr = StringIO.new allow(@knife.ui).to receive(:stderr).and_return(@stderr) end - describe 'run' do - it 'should print usage and exit when a directory is not provided' do + describe "run" do + it "should print usage and exit when a directory is not provided" do expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal).with(/must provide the directory/) expect { @@ -38,24 +38,24 @@ describe Chef::Knife::ConfigureClient do }.to raise_error SystemExit end - describe 'when specifing a directory' do + describe "when specifing a directory" do before do - @knife.name_args = ['/home/bob/.chef'] + @knife.name_args = ["/home/bob/.chef"] @client_file = StringIO.new @validation_file = StringIO.new - expect(File).to receive(:open).with('/home/bob/.chef/client.rb', 'w'). + expect(File).to receive(:open).with("/home/bob/.chef/client.rb", "w"). and_yield(@client_file) - expect(File).to receive(:open).with('/home/bob/.chef/validation.pem', 'w'). + expect(File).to receive(:open).with("/home/bob/.chef/validation.pem", "w"). and_yield(@validation_file) - expect(IO).to receive(:read).and_return('foo_bar_baz') + expect(IO).to receive(:read).and_return("foo_bar_baz") end - it 'should recursively create the directory' do - expect(FileUtils).to receive(:mkdir_p).with('/home/bob/.chef') + it "should recursively create the directory" do + expect(FileUtils).to receive(:mkdir_p).with("/home/bob/.chef") @knife.run end - it 'should write out the config file' do + it "should write out the config file" do allow(FileUtils).to receive(:mkdir_p) @knife.run expect(@client_file.string).to match /log_level\s+\:info/ @@ -64,13 +64,13 @@ describe Chef::Knife::ConfigureClient do expect(@client_file.string).to match /validation_client_name\s+'chef-validator'/ end - it 'should write out the validation.pem file' do + it "should write out the validation.pem file" do allow(FileUtils).to receive(:mkdir_p) @knife.run expect(@validation_file.string).to match /foo_bar_baz/ end - it 'should print information on what is being configured' do + it "should print information on what is being configured" do allow(FileUtils).to receive(:mkdir_p) @knife.run expect(@stderr.string).to match /creating client configuration/i diff --git a/spec/unit/knife/configure_spec.rb b/spec/unit/knife/configure_spec.rb index 89874cfdf9..6c1d98c2f5 100644 --- a/spec/unit/knife/configure_spec.rb +++ b/spec/unit/knife/configure_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Chef::Knife::Configure do before do @@ -11,7 +11,7 @@ describe Chef::Knife::Configure do @out = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@out) - @knife.config[:config_file] = '/home/you/.chef/knife.rb' + @knife.config[:config_file] = "/home/you/.chef/knife.rb" @in = StringIO.new("\n" * 7) allow(@knife.ui).to receive(:stdin).and_return(@in) @@ -58,11 +58,11 @@ describe Chef::Knife::Configure do it "should not ask the user for the clientname they want for the new client if -i and --node_name are specified" do @knife.config[:initial] = true - @knife.config[:node_name] = 'testnode' + @knife.config[:node_name] = "testnode" allow(Etc).to receive(:getlogin).and_return("a-new-user") @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter a name for the new user")) - expect(@knife.new_client_name).to eq('testnode') + expect(@knife.new_client_name).to eq("testnode") end it "asks the user for the existing API username or clientname if -i is not specified" do @@ -76,21 +76,21 @@ describe Chef::Knife::Configure do @knife.config[:initial] = true @knife.ask_user_for_config expect(@out.string).to match(Regexp.escape("Please enter the existing admin name: [admin]")) - expect(@knife.admin_client_name).to eq('admin') + expect(@knife.admin_client_name).to eq("admin") end it "should not ask the user for the existing admin client's name if -i and --admin-client_name are specified" do @knife.config[:initial] = true - @knife.config[:admin_client_name] = 'my-webui' + @knife.config[:admin_client_name] = "my-webui" @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the existing admin:")) - expect(@knife.admin_client_name).to eq('my-webui') + expect(@knife.admin_client_name).to eq("my-webui") end it "should not ask the user for the existing admin client's name if -i is not specified" do @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the existing admin: [admin]")) - expect(@knife.admin_client_name).not_to eq('admin') + expect(@knife.admin_client_name).not_to eq("admin") end it "asks the user for the location of the existing admin key if -i is specified" do @@ -106,13 +106,13 @@ describe Chef::Knife::Configure do it "should not ask the user for the location of the existing admin key if -i and --admin_client_key are specified" do @knife.config[:initial] = true - @knife.config[:admin_client_key] = '/home/you/.chef/my-webui.pem' + @knife.config[:admin_client_key] = "/home/you/.chef/my-webui.pem" @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the location of the existing admin client's private key:")) if windows? expect(@knife.admin_client_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-webui\.pem$} else - expect(@knife.admin_client_key).to eq('/home/you/.chef/my-webui.pem') + expect(@knife.admin_client_key).to eq("/home/you/.chef/my-webui.pem") end end @@ -129,20 +129,20 @@ describe Chef::Knife::Configure do it "asks the user for the location of a chef repo" do @knife.ask_user_for_config expect(@out.string).to match(Regexp.escape("Please enter the path to a chef repository (or leave blank):")) - expect(@knife.chef_repo).to eq('') + expect(@knife.chef_repo).to eq("") end it "asks the users for the name of the validation client" do @knife.ask_user_for_config expect(@out.string).to match(Regexp.escape("Please enter the validation clientname: [chef-validator]")) - expect(@knife.validation_client_name).to eq('chef-validator') + expect(@knife.validation_client_name).to eq("chef-validator") end it "should not ask the users for the name of the validation client if --validation_client_name is specified" do - @knife.config[:validation_client_name] = 'my-validator' + @knife.config[:validation_client_name] = "my-validator" @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the validation clientname:")) - expect(@knife.validation_client_name).to eq('my-validator') + expect(@knife.validation_client_name).to eq("my-validator") end it "asks the users for the location of the validation key" do @@ -156,45 +156,45 @@ describe Chef::Knife::Configure do end it "should not ask the users for the location of the validation key if --validation_key is specified" do - @knife.config[:validation_key] = '/home/you/.chef/my-validation.pem' + @knife.config[:validation_key] = "/home/you/.chef/my-validation.pem" @knife.ask_user_for_config expect(@out.string).not_to match(Regexp.escape("Please enter the location of the validation key:")) if windows? expect(@knife.validation_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-validation\.pem$} else - expect(@knife.validation_key).to eq('/home/you/.chef/my-validation.pem') + expect(@knife.validation_key).to eq("/home/you/.chef/my-validation.pem") end end it "should not ask the user for anything if -i and all other properties are specified" do @knife.config[:initial] = true - @knife.config[:chef_server_url] = 'http://localhost:5000' - @knife.config[:node_name] = 'testnode' - @knife.config[:admin_client_name] = 'my-webui' - @knife.config[:admin_client_key] = '/home/you/.chef/my-webui.pem' - @knife.config[:validation_client_name] = 'my-validator' - @knife.config[:validation_key] = '/home/you/.chef/my-validation.pem' - @knife.config[:repository] = '' - @knife.config[:client_key] = '/home/you/a-new-user.pem' - allow(Etc).to receive(:getlogin).and_return('a-new-user') + @knife.config[:chef_server_url] = "http://localhost:5000" + @knife.config[:node_name] = "testnode" + @knife.config[:admin_client_name] = "my-webui" + @knife.config[:admin_client_key] = "/home/you/.chef/my-webui.pem" + @knife.config[:validation_client_name] = "my-validator" + @knife.config[:validation_key] = "/home/you/.chef/my-validation.pem" + @knife.config[:repository] = "" + @knife.config[:client_key] = "/home/you/a-new-user.pem" + allow(Etc).to receive(:getlogin).and_return("a-new-user") @knife.ask_user_for_config expect(@out.string).to match(/\s*/) - expect(@knife.new_client_name).to eq('testnode') - expect(@knife.chef_server).to eq('http://localhost:5000') - expect(@knife.admin_client_name).to eq('my-webui') + expect(@knife.new_client_name).to eq("testnode") + expect(@knife.chef_server).to eq("http://localhost:5000") + expect(@knife.admin_client_name).to eq("my-webui") if windows? expect(@knife.admin_client_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-webui\.pem$} expect(@knife.validation_key).to match %r{^[A-Za-z]:/home/you/\.chef/my-validation\.pem$} expect(@knife.new_client_key).to match %r{^[A-Za-z]:/home/you/a-new-user\.pem$} else - expect(@knife.admin_client_key).to eq('/home/you/.chef/my-webui.pem') - expect(@knife.validation_key).to eq('/home/you/.chef/my-validation.pem') - expect(@knife.new_client_key).to eq('/home/you/a-new-user.pem') + expect(@knife.admin_client_key).to eq("/home/you/.chef/my-webui.pem") + expect(@knife.validation_key).to eq("/home/you/.chef/my-validation.pem") + expect(@knife.new_client_key).to eq("/home/you/a-new-user.pem") end - expect(@knife.validation_client_name).to eq('my-validator') - expect(@knife.chef_repo).to eq('') + expect(@knife.validation_client_name).to eq("my-validator") + expect(@knife.chef_repo).to eq("") end it "writes the new data to a config file" do @@ -205,7 +205,7 @@ describe Chef::Knife::Configure do expect(FileUtils).to receive(:mkdir_p).with("/home/you/.chef") config_file = StringIO.new expect(::File).to receive(:open).with("/home/you/.chef/knife.rb", "w").and_yield config_file - @knife.config[:repository] = '/home/you/chef-repo' + @knife.config[:repository] = "/home/you/chef-repo" @knife.run expect(config_file.string).to match(/^node_name[\s]+'#{Etc.getlogin}'$/) expect(config_file.string).to match(%r{^client_key[\s]+'/home/you/.chef/#{Etc.getlogin}.pem'$}) diff --git a/spec/unit/knife/cookbook_bulk_delete_spec.rb b/spec/unit/knife/cookbook_bulk_delete_spec.rb index 7d6e851589..6ef01bc0bb 100644 --- a/spec/unit/knife/cookbook_bulk_delete_spec.rb +++ b/spec/unit/knife/cookbook_bulk_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::CookbookBulkDelete do before(:each) do @@ -48,12 +48,12 @@ describe Chef::Knife::CookbookBulkDelete do describe "when there are several cookbooks on the server" do before do - @cheezburger = {'cheezburger' => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-cheez", "version" => "1.0.0"}]}} - allow(@rest).to receive(:get).with('cookbooks/cheezburger').and_return(@cheezburger) - @pizza = {'pizza' => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-pizza", "version" => "2.0.0"}]}} - allow(@rest).to receive(:get).with('cookbooks/pizza').and_return(@pizza) - @lasagna = {'lasagna' => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-lasagna", "version" => "3.0.0"}]}} - allow(@rest).to receive(:get).with('cookbooks/lasagna').and_return(@lasagna) + @cheezburger = {"cheezburger" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-cheez", "version" => "1.0.0"}]}} + allow(@rest).to receive(:get).with("cookbooks/cheezburger").and_return(@cheezburger) + @pizza = {"pizza" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-pizza", "version" => "2.0.0"}]}} + allow(@rest).to receive(:get).with("cookbooks/pizza").and_return(@pizza) + @lasagna = {"lasagna" => {"url" => "file:///dev/null", "versions" => [{"url" => "file:///dev/null-lasagna", "version" => "3.0.0"}]}} + allow(@rest).to receive(:get).with("cookbooks/lasagna").and_return(@lasagna) end it "should print the cookbooks you are about to delete" do @@ -68,7 +68,7 @@ describe Chef::Knife::CookbookBulkDelete do end it "should delete each cookbook" do - {"cheezburger" => "1.0.0", "pizza" => "2.0.0", "lasagna" => '3.0.0'}.each do |cookbook_name, version| + {"cheezburger" => "1.0.0", "pizza" => "2.0.0", "lasagna" => "3.0.0"}.each do |cookbook_name, version| expect(@rest).to receive(:delete).with("cookbooks/#{cookbook_name}/#{version}") end @knife.run @@ -76,7 +76,7 @@ describe Chef::Knife::CookbookBulkDelete do it "should only delete cookbooks that match the regex" do @knife.name_args = ["cheezburger"] - expect(@rest).to receive(:delete).with('cookbooks/cheezburger/1.0.0') + expect(@rest).to receive(:delete).with("cookbooks/cheezburger/1.0.0") @knife.run end end diff --git a/spec/unit/knife/cookbook_create_spec.rb b/spec/unit/knife/cookbook_create_spec.rb index 8619c8f64b..27bdc303c2 100644 --- a/spec/unit/knife/cookbook_create_spec.rb +++ b/spec/unit/knife/cookbook_create_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tmpdir' +require "spec_helper" +require "tmpdir" describe Chef::Knife::CookbookCreate do before(:each) do diff --git a/spec/unit/knife/cookbook_delete_spec.rb b/spec/unit/knife/cookbook_delete_spec.rb index e9085e9512..aed5f197b9 100644 --- a/spec/unit/knife/cookbook_delete_spec.rb +++ b/spec/unit/knife/cookbook_delete_spec.rb @@ -16,51 +16,51 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::CookbookDelete do before(:each) do @knife = Chef::Knife::CookbookDelete.new - @knife.name_args = ['foobar'] - @knife.cookbook_name = 'foobar' + @knife.name_args = ["foobar"] + @knife.cookbook_name = "foobar" @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) @stderr = StringIO.new allow(@knife.ui).to receive(:stderr).and_return(@stderr) end - describe 'run' do - it 'should print usage and exit when a cookbook name is not provided' do + describe "run" do + it "should print usage and exit when a cookbook name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) expect { @knife.run }.to raise_error(SystemExit) end - describe 'when specifying a cookbook name' do - it 'should delete the cookbook without a specific version' do + describe "when specifying a cookbook name" do + it "should delete the cookbook without a specific version" do expect(@knife).to receive(:delete_without_explicit_version) @knife.run end - describe 'and a version' do - it 'should delete the specific version of the cookbook' do - @knife.name_args << '1.0.0' + describe "and a version" do + it "should delete the specific version of the cookbook" do + @knife.name_args << "1.0.0" expect(@knife).to receive(:delete_explicit_version) @knife.run end end - describe 'with -a or --all' do - it 'should delete all versions of the cookbook' do + describe "with -a or --all" do + it "should delete all versions of the cookbook" do @knife.config[:all] = true expect(@knife).to receive(:delete_all_versions) @knife.run end end - describe 'with -p or --purge' do - it 'should prompt to purge the files' do + describe "with -p or --purge" do + it "should prompt to purge the files" do @knife.config[:purge] = true expect(@knife).to receive(:confirm). with(/.+Are you sure you want to purge files.+/) @@ -71,30 +71,30 @@ describe Chef::Knife::CookbookDelete do end end - describe 'delete_explicit_version' do - it 'should delete the specific cookbook version' do - @knife.cookbook_name = 'foobar' - @knife.version = '1.0.0' + describe "delete_explicit_version" do + it "should delete the specific cookbook version" do + @knife.cookbook_name = "foobar" + @knife.version = "1.0.0" expect(@knife).to receive(:delete_object).with(Chef::CookbookVersion, - 'foobar version 1.0.0', - 'cookbook').and_yield() - expect(@knife).to receive(:delete_request).with('cookbooks/foobar/1.0.0') + "foobar version 1.0.0", + "cookbook").and_yield() + expect(@knife).to receive(:delete_request).with("cookbooks/foobar/1.0.0") @knife.delete_explicit_version end end - describe 'delete_all_versions' do - it 'should prompt to delete all versions of the cookbook' do - @knife.cookbook_name = 'foobar' - expect(@knife).to receive(:confirm).with('Do you really want to delete all versions of foobar') + describe "delete_all_versions" do + it "should prompt to delete all versions of the cookbook" do + @knife.cookbook_name = "foobar" + expect(@knife).to receive(:confirm).with("Do you really want to delete all versions of foobar") expect(@knife).to receive(:delete_all_without_confirmation) @knife.delete_all_versions end end - describe 'delete_all_without_confirmation' do - it 'should delete all versions without confirmation' do - versions = ['1.0.0', '1.1.0'] + describe "delete_all_without_confirmation" do + it "should delete all versions without confirmation" do + versions = ["1.0.0", "1.1.0"] expect(@knife).to receive(:available_versions).and_return(versions) versions.each do |v| expect(@knife).to receive(:delete_version_without_confirmation).with(v) @@ -103,43 +103,43 @@ describe Chef::Knife::CookbookDelete do end end - describe 'delete_without_explicit_version' do - it 'should exit if there are no available versions' do + describe "delete_without_explicit_version" do + it "should exit if there are no available versions" do expect(@knife).to receive(:available_versions).and_return(nil) expect { @knife.delete_without_explicit_version }.to raise_error(SystemExit) end - it 'should delete the version if only one is found' do - expect(@knife).to receive(:available_versions).at_least(:once).and_return(['1.0.0']) + it "should delete the version if only one is found" do + expect(@knife).to receive(:available_versions).at_least(:once).and_return(["1.0.0"]) expect(@knife).to receive(:delete_explicit_version) @knife.delete_without_explicit_version end - it 'should ask which version(s) to delete if multiple are found' do - expect(@knife).to receive(:available_versions).at_least(:once).and_return(['1.0.0', '1.1.0']) - expect(@knife).to receive(:ask_which_versions_to_delete).and_return(['1.0.0', '1.1.0']) - expect(@knife).to receive(:delete_versions_without_confirmation).with(['1.0.0', '1.1.0']) + it "should ask which version(s) to delete if multiple are found" do + expect(@knife).to receive(:available_versions).at_least(:once).and_return(["1.0.0", "1.1.0"]) + expect(@knife).to receive(:ask_which_versions_to_delete).and_return(["1.0.0", "1.1.0"]) + expect(@knife).to receive(:delete_versions_without_confirmation).with(["1.0.0", "1.1.0"]) @knife.delete_without_explicit_version end end - describe 'available_versions' do + describe "available_versions" do before(:each) do - @rest_mock = double('rest') + @rest_mock = double("rest") expect(@knife).to receive(:rest).and_return(@rest_mock) - @cookbook_data = { 'foobar' => { 'versions' => [{'version' => '1.0.0'}, - {'version' => '1.1.0'}, - {'version' => '2.0.0'} ]} + @cookbook_data = { "foobar" => { "versions" => [{"version" => "1.0.0"}, + {"version" => "1.1.0"}, + {"version" => "2.0.0"} ]} } end - it 'should return the list of versions of the cookbook' do - expect(@rest_mock).to receive(:get).with('cookbooks/foobar').and_return(@cookbook_data) - expect(@knife.available_versions).to eq(['1.0.0', '1.1.0', '2.0.0']) + it "should return the list of versions of the cookbook" do + expect(@rest_mock).to receive(:get).with("cookbooks/foobar").and_return(@cookbook_data) + expect(@knife.available_versions).to eq(["1.0.0", "1.1.0", "2.0.0"]) end - it 'should raise if an error other than HTTP 404 is returned' do - exception = Net::HTTPServerException.new('500 Internal Server Error', '500') + it "should raise if an error other than HTTP 404 is returned" do + exception = Net::HTTPServerException.new("500 Internal Server Error", "500") expect(@rest_mock).to receive(:get).and_raise(exception) expect { @knife.available_versions }.to raise_error Net::HTTPServerException end @@ -147,88 +147,88 @@ describe Chef::Knife::CookbookDelete do describe "if the cookbook can't be found" do before(:each) do expect(@rest_mock).to receive(:get). - and_raise(Net::HTTPServerException.new('404 Not Found', '404')) + and_raise(Net::HTTPServerException.new("404 Not Found", "404")) end - it 'should print an error' do + it "should print an error" do @knife.available_versions expect(@stderr.string).to match /error.+cannot find a cookbook named foobar/i end - it 'should return nil' do + it "should return nil" do expect(@knife.available_versions).to eq(nil) end end end - describe 'ask_which_version_to_delete' do + describe "ask_which_version_to_delete" do before(:each) do - allow(@knife).to receive(:available_versions).and_return(['1.0.0', '1.1.0', '2.0.0']) + allow(@knife).to receive(:available_versions).and_return(["1.0.0", "1.1.0", "2.0.0"]) end - it 'should prompt the user to select a version' do + it "should prompt the user to select a version" do prompt = /Which version\(s\) do you want to delete\?.+1\. foobar 1\.0\.0.+2\. foobar 1\.1\.0.+3\. foobar 2\.0\.0.+4\. All versions.+/m - expect(@knife).to receive(:ask_question).with(prompt).and_return('1') + expect(@knife).to receive(:ask_question).with(prompt).and_return("1") @knife.ask_which_versions_to_delete end it "should print an error and exit if a version wasn't specified" do - expect(@knife).to receive(:ask_question).and_return('') + expect(@knife).to receive(:ask_question).and_return("") expect(@knife.ui).to receive(:error).with(/no versions specified/i) expect { @knife.ask_which_versions_to_delete }.to raise_error(SystemExit) end - it 'should print an error if an invalid choice was selected' do - expect(@knife).to receive(:ask_question).and_return('100') + it "should print an error if an invalid choice was selected" do + expect(@knife).to receive(:ask_question).and_return("100") expect(@knife.ui).to receive(:error).with(/100 is not a valid choice/i) @knife.ask_which_versions_to_delete end - it 'should return the selected versions' do - expect(@knife).to receive(:ask_question).and_return('1, 3') - expect(@knife.ask_which_versions_to_delete).to eq(['1.0.0', '2.0.0']) + it "should return the selected versions" do + expect(@knife).to receive(:ask_question).and_return("1, 3") + expect(@knife.ask_which_versions_to_delete).to eq(["1.0.0", "2.0.0"]) end it "should return all of the versions if 'all' was selected" do - expect(@knife).to receive(:ask_question).and_return('4') + expect(@knife).to receive(:ask_question).and_return("4") expect(@knife.ask_which_versions_to_delete).to eq([:all]) end end - describe 'delete_version_without_confirmation' do - it 'should delete the cookbook version' do - expect(@knife).to receive(:delete_request).with('cookbooks/foobar/1.0.0') - @knife.delete_version_without_confirmation('1.0.0') + describe "delete_version_without_confirmation" do + it "should delete the cookbook version" do + expect(@knife).to receive(:delete_request).with("cookbooks/foobar/1.0.0") + @knife.delete_version_without_confirmation("1.0.0") end - it 'should output that the cookbook was deleted' do + it "should output that the cookbook was deleted" do allow(@knife).to receive(:delete_request) - @knife.delete_version_without_confirmation('1.0.0') + @knife.delete_version_without_confirmation("1.0.0") expect(@stderr.string).to match /deleted cookbook\[foobar\]\[1.0.0\]/im end - describe 'with --print-after' do - it 'should display the cookbook data' do - object = '' + describe "with --print-after" do + it "should display the cookbook data" do + object = "" @knife.config[:print_after] = true allow(@knife).to receive(:delete_request).and_return(object) expect(@knife).to receive(:format_for_display).with(object) - @knife.delete_version_without_confirmation('1.0.0') + @knife.delete_version_without_confirmation("1.0.0") end end end - describe 'delete_versions_without_confirmation' do - it 'should delete each version without confirmation' do - versions = ['1.0.0', '1.1.0'] + describe "delete_versions_without_confirmation" do + it "should delete each version without confirmation" do + versions = ["1.0.0", "1.1.0"] versions.each do |v| expect(@knife).to receive(:delete_version_without_confirmation).with(v) end @knife.delete_versions_without_confirmation(versions) end - describe 'with -a or --all' do - it 'should delete all versions without confirmation' do + describe "with -a or --all" do + it "should delete all versions without confirmation" do versions = [:all] expect(@knife).to receive(:delete_all_without_confirmation) @knife.delete_versions_without_confirmation(versions) diff --git a/spec/unit/knife/cookbook_download_spec.rb b/spec/unit/knife/cookbook_download_spec.rb index 64b754d173..baa8acc6f4 100644 --- a/spec/unit/knife/cookbook_download_spec.rb +++ b/spec/unit/knife/cookbook_download_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::CookbookDownload do before(:each) do @@ -25,66 +25,66 @@ describe Chef::Knife::CookbookDownload do allow(@knife.ui).to receive(:stderr).and_return(@stderr) end - describe 'run' do - it 'should print usage and exit when a cookbook name is not provided' do + describe "run" do + it "should print usage and exit when a cookbook name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal).with(/must specify a cookbook name/) expect { @knife.run }.to raise_error(SystemExit) end - it 'should exit with a fatal error when there is no cookbook on the server' do - @knife.name_args = ['foobar', nil] + it "should exit with a fatal error when there is no cookbook on the server" do + @knife.name_args = ["foobar", nil] expect(@knife).to receive(:determine_version).and_return(nil) - expect(@knife.ui).to receive(:fatal).with('No such cookbook found') + expect(@knife.ui).to receive(:fatal).with("No such cookbook found") expect { @knife.run }.to raise_error(SystemExit) end - describe 'with a cookbook name' do + describe "with a cookbook name" do before(:each) do - @knife.name_args = ['foobar'] - @knife.config[:download_directory] = '/var/tmp/chef' - @rest_mock = double('rest') + @knife.name_args = ["foobar"] + @knife.config[:download_directory] = "/var/tmp/chef" + @rest_mock = double("rest") allow(@knife).to receive(:rest).and_return(@rest_mock) @manifest_data = { :recipes => [ - {'path' => 'recipes/foo.rb', - 'url' => 'http://example.org/files/foo.rb'}, - {'path' => 'recipes/bar.rb', - 'url' => 'http://example.org/files/bar.rb'}, + {"path" => "recipes/foo.rb", + "url" => "http://example.org/files/foo.rb"}, + {"path" => "recipes/bar.rb", + "url" => "http://example.org/files/bar.rb"}, ], :templates => [ - {'path' => 'templates/default/foo.erb', - 'url' => 'http://example.org/files/foo.erb'}, - {'path' => 'templates/default/bar.erb', - 'url' => 'http://example.org/files/bar.erb'}, + {"path" => "templates/default/foo.erb", + "url" => "http://example.org/files/foo.erb"}, + {"path" => "templates/default/bar.erb", + "url" => "http://example.org/files/bar.erb"}, ], :attributes => [ - {'path' => 'attributes/default.rb', - 'url' => 'http://example.org/files/default.rb'}, + {"path" => "attributes/default.rb", + "url" => "http://example.org/files/default.rb"}, ], } - @cookbook_mock = double('cookbook') - allow(@cookbook_mock).to receive(:version).and_return('1.0.0') + @cookbook_mock = double("cookbook") + allow(@cookbook_mock).to receive(:version).and_return("1.0.0") allow(@cookbook_mock).to receive(:manifest).and_return(@manifest_data) expect(Chef::CookbookVersion).to receive(:load).with("foobar", "1.0.0"). and_return(@cookbook_mock) end - it 'should determine which version if one was not explicitly specified'do + it "should determine which version if one was not explicitly specified"do allow(@cookbook_mock).to receive(:manifest).and_return({}) - expect(@knife).to receive(:determine_version).and_return('1.0.0') - expect(File).to receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(false) + expect(@knife).to receive(:determine_version).and_return("1.0.0") + expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false) allow(Chef::CookbookVersion).to receive(:COOKBOOK_SEGEMENTS).and_return([]) @knife.run end - describe 'and a version' do + describe "and a version" do before(:each) do - @knife.name_args << '1.0.0' - @files = @manifest_data.values.map { |v| v.map { |i| i['path'] } }.flatten.uniq + @knife.name_args << "1.0.0" + @files = @manifest_data.values.map { |v| v.map { |i| i["path"] } }.flatten.uniq @files_mocks = {} @files.map { |f| File.basename(f) }.flatten.uniq.each do |f| @files_mocks[f] = double("#{f}_mock") @@ -92,13 +92,13 @@ describe Chef::Knife::CookbookDownload do end end - it 'should print an error and exit if the cookbook download directory already exists' do - expect(File).to receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(true) + it "should print an error and exit if the cookbook download directory already exists" do + expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true) expect(@knife.ui).to receive(:fatal).with(/\/var\/tmp\/chef\/foobar-1\.0\.0 exists/i) expect { @knife.run }.to raise_error(SystemExit) end - describe 'when downloading the cookbook' do + describe "when downloading the cookbook" do before(:each) do @files.map { |f| File.dirname(f) }.flatten.uniq.each do |dir| expect(FileUtils).to receive(:mkdir_p).with("/var/tmp/chef/foobar-1.0.0/#{dir}"). @@ -117,20 +117,20 @@ describe Chef::Knife::CookbookDownload do end it "should download the cookbook when the cookbook download directory doesn't exist" do - expect(File).to receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(false) + expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(false) @knife.run - ['attributes', 'recipes', 'templates'].each do |segment| + ["attributes", "recipes", "templates"].each do |segment| expect(@stderr.string).to match /downloading #{segment}/im end expect(@stderr.string).to match /downloading foobar cookbook version 1\.0\.0/im expect(@stderr.string).to match /cookbook downloaded to \/var\/tmp\/chef\/foobar-1\.0\.0/im end - describe 'with -f or --force' do - it 'should remove the existing the cookbook download directory if it exists' do + describe "with -f or --force" do + it "should remove the existing the cookbook download directory if it exists" do @knife.config[:force] = true - expect(File).to receive(:exists?).with('/var/tmp/chef/foobar-1.0.0').and_return(true) - expect(FileUtils).to receive(:rm_rf).with('/var/tmp/chef/foobar-1.0.0') + expect(File).to receive(:exists?).with("/var/tmp/chef/foobar-1.0.0").and_return(true) + expect(FileUtils).to receive(:rm_rf).with("/var/tmp/chef/foobar-1.0.0") @knife.run end end @@ -141,94 +141,94 @@ describe Chef::Knife::CookbookDownload do end - describe 'determine_version' do + describe "determine_version" do - it 'should return nil if there are no versions' do + it "should return nil if there are no versions" do expect(@knife).to receive(:available_versions).and_return(nil) expect(@knife.determine_version).to eq(nil) expect(@knife.version).to eq(nil) end - it 'should return and set the version if there is only one version' do - expect(@knife).to receive(:available_versions).at_least(:once).and_return(['1.0.0']) - expect(@knife.determine_version).to eq('1.0.0') - expect(@knife.version).to eq('1.0.0') + it "should return and set the version if there is only one version" do + expect(@knife).to receive(:available_versions).at_least(:once).and_return(["1.0.0"]) + expect(@knife.determine_version).to eq("1.0.0") + expect(@knife.version).to eq("1.0.0") end - it 'should ask which version to download and return it if there is more than one' do - expect(@knife).to receive(:available_versions).at_least(:once).and_return(['1.0.0', '2.0.0']) - expect(@knife).to receive(:ask_which_version).and_return('1.0.0') - expect(@knife.determine_version).to eq('1.0.0') + it "should ask which version to download and return it if there is more than one" do + expect(@knife).to receive(:available_versions).at_least(:once).and_return(["1.0.0", "2.0.0"]) + expect(@knife).to receive(:ask_which_version).and_return("1.0.0") + expect(@knife.determine_version).to eq("1.0.0") end - describe 'with -N or --latest' do - it 'should return and set the version to the latest version' do + describe "with -N or --latest" do + it "should return and set the version to the latest version" do @knife.config[:latest] = true expect(@knife).to receive(:available_versions).at_least(:once). - and_return(['1.0.0', '1.1.0', '2.0.0']) + and_return(["1.0.0", "1.1.0", "2.0.0"]) @knife.determine_version - expect(@knife.version.to_s).to eq('2.0.0') + expect(@knife.version.to_s).to eq("2.0.0") end end end - describe 'available_versions' do + describe "available_versions" do before(:each) do - @knife.cookbook_name = 'foobar' + @knife.cookbook_name = "foobar" end - it 'should return nil if there are no versions' do + it "should return nil if there are no versions" do expect(Chef::CookbookVersion).to receive(:available_versions). - with('foobar'). + with("foobar"). and_return(nil) expect(@knife.available_versions).to eq(nil) end - it 'should return the available versions' do + it "should return the available versions" do expect(Chef::CookbookVersion).to receive(:available_versions). - with('foobar'). - and_return(['1.1.0', '2.0.0', '1.0.0']) - expect(@knife.available_versions).to eq([Chef::Version.new('1.0.0'), - Chef::Version.new('1.1.0'), - Chef::Version.new('2.0.0')]) + with("foobar"). + and_return(["1.1.0", "2.0.0", "1.0.0"]) + expect(@knife.available_versions).to eq([Chef::Version.new("1.0.0"), + Chef::Version.new("1.1.0"), + Chef::Version.new("2.0.0")]) end - it 'should avoid multiple API calls to the server' do + it "should avoid multiple API calls to the server" do expect(Chef::CookbookVersion).to receive(:available_versions). once. - with('foobar'). - and_return(['1.1.0', '2.0.0', '1.0.0']) + with("foobar"). + and_return(["1.1.0", "2.0.0", "1.0.0"]) @knife.available_versions @knife.available_versions end end - describe 'ask_which_version' do + describe "ask_which_version" do before(:each) do - @knife.cookbook_name = 'foobar' - allow(@knife).to receive(:available_versions).and_return(['1.0.0', '1.1.0', '2.0.0']) + @knife.cookbook_name = "foobar" + allow(@knife).to receive(:available_versions).and_return(["1.0.0", "1.1.0", "2.0.0"]) end - it 'should prompt the user to select a version' do + it "should prompt the user to select a version" do prompt = /Which version do you want to download\?.+1\. foobar 1\.0\.0.+2\. foobar 1\.1\.0.+3\. foobar 2\.0\.0.+/m - expect(@knife).to receive(:ask_question).with(prompt).and_return('1') + expect(@knife).to receive(:ask_question).with(prompt).and_return("1") @knife.ask_which_version end it "should set the version to the user's selection" do - expect(@knife).to receive(:ask_question).and_return('1') + expect(@knife).to receive(:ask_question).and_return("1") @knife.ask_which_version - expect(@knife.version).to eq('1.0.0') + expect(@knife.version).to eq("1.0.0") end it "should print an error and exit if a version wasn't specified" do - expect(@knife).to receive(:ask_question).and_return('') + expect(@knife).to receive(:ask_question).and_return("") expect(@knife.ui).to receive(:error).with(/is not a valid value/i) expect { @knife.ask_which_version }.to raise_error(SystemExit) end - it 'should print an error if an invalid choice was selected' do - expect(@knife).to receive(:ask_question).and_return('100') + it "should print an error if an invalid choice was selected" do + expect(@knife).to receive(:ask_question).and_return("100") expect(@knife.ui).to receive(:error).with(/'100' is not a valid value/i) expect { @knife.ask_which_version }.to raise_error(SystemExit) end diff --git a/spec/unit/knife/cookbook_list_spec.rb b/spec/unit/knife/cookbook_list_spec.rb index fc07c8af3f..124c4bca8e 100644 --- a/spec/unit/knife/cookbook_list_spec.rb +++ b/spec/unit/knife/cookbook_list_spec.rb @@ -16,28 +16,28 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::CookbookList do before do @knife = Chef::Knife::CookbookList.new - @rest_mock = double('rest') + @rest_mock = double("rest") allow(@knife).to receive(:rest).and_return(@rest_mock) - @cookbook_names = ['apache2', 'mysql'] - @base_url = 'https://server.example.com/cookbooks' + @cookbook_names = ["apache2", "mysql"] + @base_url = "https://server.example.com/cookbooks" @cookbook_data = {} @cookbook_names.each do |item| - @cookbook_data[item] = {'url' => "#{@base_url}/#{item}", - 'versions' => [{'version' => '1.0.1', - 'url' => "#{@base_url}/#{item}/1.0.1"}]} + @cookbook_data[item] = {"url" => "#{@base_url}/#{item}", + "versions" => [{"version" => "1.0.1", + "url" => "#{@base_url}/#{item}/1.0.1"}]} end @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) end - describe 'run' do - it 'should display the latest version of the cookbooks' do - expect(@rest_mock).to receive(:get).with('/cookbooks?num_versions=1'). + describe "run" do + it "should display the latest version of the cookbooks" do + expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=1"). and_return(@cookbook_data) @knife.run @cookbook_names.each do |item| @@ -45,16 +45,16 @@ describe Chef::Knife::CookbookList do end end - it 'should query cookbooks for the configured environment' do - @knife.config[:environment] = 'production' + it "should query cookbooks for the configured environment" do + @knife.config[:environment] = "production" expect(@rest_mock).to receive(:get). - with('/environments/production/cookbooks?num_versions=1'). + with("/environments/production/cookbooks?num_versions=1"). and_return(@cookbook_data) @knife.run end - describe 'with -w or --with-uri' do - it 'should display the cookbook uris' do + describe "with -w or --with-uri" do + it "should display the cookbook uris" do @knife.config[:with_uri] = true allow(@rest_mock).to receive(:get).and_return(@cookbook_data) @knife.run @@ -65,17 +65,17 @@ describe Chef::Knife::CookbookList do end end - describe 'with -a or --all' do + describe "with -a or --all" do before do @cookbook_names.each do |item| - @cookbook_data[item]['versions'] << {'version' => '1.0.0', - 'url' => "#{@base_url}/#{item}/1.0.0"} + @cookbook_data[item]["versions"] << {"version" => "1.0.0", + "url" => "#{@base_url}/#{item}/1.0.0"} end end - it 'should display all versions of the cookbooks' do + it "should display all versions of the cookbooks" do @knife.config[:all_versions] = true - expect(@rest_mock).to receive(:get).with('/cookbooks?num_versions=all'). + expect(@rest_mock).to receive(:get).with("/cookbooks?num_versions=all"). and_return(@cookbook_data) @knife.run @cookbook_names.each do |item| diff --git a/spec/unit/knife/cookbook_metadata_from_file_spec.rb b/spec/unit/knife/cookbook_metadata_from_file_spec.rb index 456e378ca2..852258e8a0 100644 --- a/spec/unit/knife/cookbook_metadata_from_file_spec.rb +++ b/spec/unit/knife/cookbook_metadata_from_file_spec.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::CookbookMetadataFromFile do before(:each) do diff --git a/spec/unit/knife/cookbook_metadata_spec.rb b/spec/unit/knife/cookbook_metadata_spec.rb index bd54d4278b..1dcc840611 100644 --- a/spec/unit/knife/cookbook_metadata_spec.rb +++ b/spec/unit/knife/cookbook_metadata_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::CookbookMetadata do before(:each) do @knife = Chef::Knife::CookbookMetadata.new - @knife.name_args = ['foobar'] + @knife.name_args = ["foobar"] @cookbook_dir = Dir.mktmpdir @json_data = '{ "version": "1.0.0" }' @stdout = StringIO.new @@ -30,50 +30,50 @@ describe Chef::Knife::CookbookMetadata do allow(@knife.ui).to receive(:stderr).and_return(@stderr) end - describe 'run' do - it 'should print an error and exit if a cookbook name was not provided' do + describe "run" do + it "should print an error and exit if a cookbook name was not provided" do @knife.name_args = [] expect(@knife.ui).to receive(:error).with(/you must specify the cookbook.+use the --all/i) expect { @knife.run }.to raise_error(SystemExit) end - it 'should print an error and exit if an empty cookbook name was provided' do - @knife.name_args = [''] + it "should print an error and exit if an empty cookbook name was provided" do + @knife.name_args = [""] expect(@knife.ui).to receive(:error).with(/you must specify the cookbook.+use the --all/i) expect { @knife.run }.to raise_error(SystemExit) end - it 'should generate the metadata for the cookbook' do - expect(@knife).to receive(:generate_metadata).with('foobar') + it "should generate the metadata for the cookbook" do + expect(@knife).to receive(:generate_metadata).with("foobar") @knife.run end - describe 'with -a or --all' do + describe "with -a or --all" do before(:each) do @knife.config[:all] = true - @foo = Chef::CookbookVersion.new('foo', '/tmp/blah') - @foo.version = '1.0.0' - @bar = Chef::CookbookVersion.new('bar', '/tmp/blah') - @bar.version = '2.0.0' + @foo = Chef::CookbookVersion.new("foo", "/tmp/blah") + @foo.version = "1.0.0" + @bar = Chef::CookbookVersion.new("bar", "/tmp/blah") + @bar.version = "2.0.0" @cookbook_loader = { "foo" => @foo, "bar" => @bar, } expect(@cookbook_loader).to receive(:load_cookbooks).and_return(@cookbook_loader) - expect(@knife).to receive(:generate_metadata).with('foo') - expect(@knife).to receive(:generate_metadata).with('bar') + expect(@knife).to receive(:generate_metadata).with("foo") + expect(@knife).to receive(:generate_metadata).with("bar") end - it 'should generate the metadata for each cookbook' do + it "should generate the metadata for each cookbook" do Chef::Config[:cookbook_path] = @cookbook_dir expect(Chef::CookbookLoader).to receive(:new).with(@cookbook_dir).and_return(@cookbook_loader) @knife.run end - describe 'and with -o or --cookbook-path' do - it 'should look in the provided path and generate cookbook metadata' do - @knife.config[:cookbook_path] = '/opt/chef/cookbooks' - expect(Chef::CookbookLoader).to receive(:new).with('/opt/chef/cookbooks').and_return(@cookbook_loader) + describe "and with -o or --cookbook-path" do + it "should look in the provided path and generate cookbook metadata" do + @knife.config[:cookbook_path] = "/opt/chef/cookbooks" + expect(Chef::CookbookLoader).to receive(:new).with("/opt/chef/cookbooks").and_return(@cookbook_loader) @knife.run end end @@ -81,55 +81,55 @@ describe Chef::Knife::CookbookMetadata do end - describe 'generate_metadata' do + describe "generate_metadata" do before(:each) do @knife.config[:cookbook_path] = @cookbook_dir allow(File).to receive(:expand_path).with("#{@cookbook_dir}/foobar/metadata.rb"). and_return("#{@cookbook_dir}/foobar/metadata.rb") end - it 'should generate the metadata from metadata.rb if it exists' do + it "should generate the metadata from metadata.rb if it exists" do expect(File).to receive(:exists?).with("#{@cookbook_dir}/foobar/metadata.rb"). and_return(true) - expect(@knife).to receive(:generate_metadata_from_file).with('foobar', "#{@cookbook_dir}/foobar/metadata.rb") + expect(@knife).to receive(:generate_metadata_from_file).with("foobar", "#{@cookbook_dir}/foobar/metadata.rb") @knife.run end - it 'should validate the metadata json if metadata.rb does not exist' do + it "should validate the metadata json if metadata.rb does not exist" do expect(File).to receive(:exists?).with("#{@cookbook_dir}/foobar/metadata.rb"). and_return(false) - expect(@knife).to receive(:validate_metadata_json).with(@cookbook_dir, 'foobar') + expect(@knife).to receive(:validate_metadata_json).with(@cookbook_dir, "foobar") @knife.run end end - describe 'generate_metadata_from_file' do + describe "generate_metadata_from_file" do before(:each) do - @metadata_mock = double('metadata') - @json_file_mock = double('json_file') + @metadata_mock = double("metadata") + @json_file_mock = double("json_file") end - it 'should generate the metatdata json from metatdata.rb' do + it "should generate the metatdata json from metatdata.rb" do allow(Chef::Cookbook::Metadata).to receive(:new).and_return(@metadata_mock) - expect(@metadata_mock).to receive(:name).with('foobar') + expect(@metadata_mock).to receive(:name).with("foobar") expect(@metadata_mock).to receive(:from_file).with("#{@cookbook_dir}/foobar/metadata.rb") - expect(File).to receive(:open).with("#{@cookbook_dir}/foobar/metadata.json", 'w'). + expect(File).to receive(:open).with("#{@cookbook_dir}/foobar/metadata.json", "w"). and_yield(@json_file_mock) expect(@json_file_mock).to receive(:write).with(@json_data) expect(Chef::JSONCompat).to receive(:to_json_pretty).with(@metadata_mock). and_return(@json_data) - @knife.generate_metadata_from_file('foobar', "#{@cookbook_dir}/foobar/metadata.rb") + @knife.generate_metadata_from_file("foobar", "#{@cookbook_dir}/foobar/metadata.rb") expect(@stderr.string).to match /generating metadata for foobar from #{@cookbook_dir}\/foobar\/metadata\.rb/im end - { Chef::Exceptions::ObsoleteDependencySyntax => 'obsolote dependency', - Chef::Exceptions::InvalidVersionConstraint => 'invalid version constraint', + { Chef::Exceptions::ObsoleteDependencySyntax => "obsolote dependency", + Chef::Exceptions::InvalidVersionConstraint => "invalid version constraint", }.each_pair do |klass, description| it "should print an error and exit when an #{description} syntax exception is encountered" do exception = klass.new("#{description} blah") allow(Chef::Cookbook::Metadata).to receive(:new).and_raise(exception) expect { - @knife.generate_metadata_from_file('foobar', "#{@cookbook_dir}/foobar/metadata.rb") + @knife.generate_metadata_from_file("foobar", "#{@cookbook_dir}/foobar/metadata.rb") }.to raise_error(SystemExit) expect(@stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im expect(@stderr.string).to match /in #{@cookbook_dir}\/foobar\/metadata\.rb/im @@ -138,26 +138,26 @@ describe Chef::Knife::CookbookMetadata do end end - describe 'validate_metadata_json' do - it 'should validate the metadata json' do + describe "validate_metadata_json" do + it "should validate the metadata json" do expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json"). and_return(true) expect(IO).to receive(:read).with("#{@cookbook_dir}/foobar/metadata.json"). and_return(@json_data) expect(Chef::Cookbook::Metadata).to receive(:validate_json).with(@json_data) - @knife.validate_metadata_json(@cookbook_dir, 'foobar') + @knife.validate_metadata_json(@cookbook_dir, "foobar") end - it 'should not try to validate the metadata json if the file does not exist' do + it "should not try to validate the metadata json if the file does not exist" do expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json"). and_return(false) expect(IO).not_to receive(:read) expect(Chef::Cookbook::Metadata).not_to receive(:validate_json) - @knife.validate_metadata_json(@cookbook_dir, 'foobar') + @knife.validate_metadata_json(@cookbook_dir, "foobar") end - { Chef::Exceptions::ObsoleteDependencySyntax => 'obsolote dependency', - Chef::Exceptions::InvalidVersionConstraint => 'invalid version constraint', + { Chef::Exceptions::ObsoleteDependencySyntax => "obsolote dependency", + Chef::Exceptions::InvalidVersionConstraint => "invalid version constraint", }.each_pair do |klass, description| it "should print an error and exit when an #{description} syntax exception is encountered" do expect(File).to receive(:exist?).with("#{@cookbook_dir}/foobar/metadata.json"). @@ -167,7 +167,7 @@ describe Chef::Knife::CookbookMetadata do exception = klass.new("#{description} blah") allow(Chef::Cookbook::Metadata).to receive(:validate_json).and_raise(exception) expect { - @knife.validate_metadata_json(@cookbook_dir, 'foobar') + @knife.validate_metadata_json(@cookbook_dir, "foobar") }.to raise_error(SystemExit) expect(@stderr.string).to match /error: the cookbook 'foobar' contains invalid or obsolete metadata syntax/im expect(@stderr.string).to match /in #{@cookbook_dir}\/foobar\/metadata\.json/im diff --git a/spec/unit/knife/cookbook_show_spec.rb b/spec/unit/knife/cookbook_show_spec.rb index 6c77db013f..bde33b0689 100644 --- a/spec/unit/knife/cookbook_show_spec.rb +++ b/spec/unit/knife/cookbook_show_spec.rb @@ -17,7 +17,7 @@ # # rename to cookbook not coookbook -require 'spec_helper' +require "spec_helper" describe Chef::Knife::CookbookShow do before(:each) do @@ -33,7 +33,7 @@ describe Chef::Knife::CookbookShow do describe "run" do describe "with 0 arguments: help" do - it 'should should print usage and exit when given no arguments' do + it "should should print usage and exit when given no arguments" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) diff --git a/spec/unit/knife/cookbook_site_download_spec.rb b/spec/unit/knife/cookbook_site_download_spec.rb index 35c6544d58..52e82a7f0b 100644 --- a/spec/unit/knife/cookbook_site_download_spec.rb +++ b/spec/unit/knife/cookbook_site_download_spec.rb @@ -16,22 +16,22 @@ # limitations under the License. # -require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') +require File.expand_path(File.dirname(__FILE__) + "/../../spec_helper") describe Chef::Knife::CookbookSiteDownload do - describe 'run' do + describe "run" do before do @knife = Chef::Knife::CookbookSiteDownload.new - @knife.name_args = ['apache2'] - @noauth_rest = double('no auth rest') + @knife.name_args = ["apache2"] + @noauth_rest = double("no auth rest") @stderr = StringIO.new - @cookbook_api_url = 'https://supermarket.chef.io/api/v1/cookbooks' - @version = '1.0.2' - @version_us = @version.gsub '.', '_' - @current_data = { 'deprecated' => false, - 'latest_version' => "#{@cookbook_api_url}/apache2/versions/#{@version_us}", - 'replacement' => 'other_apache2' } + @cookbook_api_url = "https://supermarket.chef.io/api/v1/cookbooks" + @version = "1.0.2" + @version_us = @version.gsub ".", "_" + @current_data = { "deprecated" => false, + "latest_version" => "#{@cookbook_api_url}/apache2/versions/#{@version_us}", + "replacement" => "other_apache2" } allow(@knife.ui).to receive(:stderr).and_return(@stderr) allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest) @@ -40,12 +40,12 @@ describe Chef::Knife::CookbookSiteDownload do and_return(@current_data) end - context 'when the cookbook is deprecated and not forced' do + context "when the cookbook is deprecated and not forced" do before do - @current_data['deprecated'] = true + @current_data["deprecated"] = true end - it 'should warn with info about the replacement' do + it "should warn with info about the replacement" do expect(@knife.ui).to receive(:warn). with(/.+deprecated.+replaced by other_apache2.+/i) expect(@knife.ui).to receive(:warn). @@ -54,33 +54,33 @@ describe Chef::Knife::CookbookSiteDownload do end end - context 'when' do + context "when" do before do - @cookbook_data = { 'version' => @version, - 'file' => "http://example.com/apache2_#{@version_us}.tgz" } + @cookbook_data = { "version" => @version, + "file" => "http://example.com/apache2_#{@version_us}.tgz" } @temp_file = double( :path => "/tmp/apache2_#{@version_us}.tgz" ) @file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz") expect(@noauth_rest).to receive(:sign_on_redirect=).with(false) end - context 'downloading the latest version' do + context "downloading the latest version" do before do expect(@noauth_rest).to receive(:get). - with(@current_data['latest_version']). + with(@current_data["latest_version"]). and_return(@cookbook_data) expect(@noauth_rest).to receive(:get). - with(@cookbook_data['file'], true). + with(@cookbook_data["file"], true). and_return(@temp_file) end - context 'and it is deprecated and with --force' do + context "and it is deprecated and with --force" do before do - @current_data['deprecated'] = true + @current_data["deprecated"] = true @knife.config[:force] = true end - it 'should download the latest version' do + it "should download the latest version" do expect(@knife.ui).to receive(:warn). with(/.+deprecated.+replaced by other_apache2.+/i) expect(FileUtils).to receive(:cp).with(@temp_file.path, @file) @@ -91,51 +91,51 @@ describe Chef::Knife::CookbookSiteDownload do end - it 'should download the latest version' do + it "should download the latest version" do expect(FileUtils).to receive(:cp).with(@temp_file.path, @file) @knife.run expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i end - context 'with -f or --file' do + context "with -f or --file" do before do - @file = '/opt/chef/cookbooks/apache2.tar.gz' + @file = "/opt/chef/cookbooks/apache2.tar.gz" @knife.config[:file] = @file expect(FileUtils).to receive(:cp).with(@temp_file.path, @file) end - it 'should download the cookbook to the desired file' do + it "should download the cookbook to the desired file" do @knife.run expect(@stderr.string).to match /downloading apache2.+version.+#{Regexp.escape(@version)}/i expect(@stderr.string).to match /cookbook save.+#{Regexp.escape(@file)}/i end end - it 'should provide an accessor to the version' do + it "should provide an accessor to the version" do allow(FileUtils).to receive(:cp).and_return(true) expect(@knife.version).to eq(@version) @knife.run end end - context 'downloading a cookbook of a specific version' do + context "downloading a cookbook of a specific version" do before do - @version = '1.0.1' - @version_us = @version.gsub '.', '_' - @cookbook_data = { 'version' => @version, - 'file' => "http://example.com/apache2_#{@version_us}.tgz" } + @version = "1.0.1" + @version_us = @version.gsub ".", "_" + @cookbook_data = { "version" => @version, + "file" => "http://example.com/apache2_#{@version_us}.tgz" } @temp_file = double(:path => "/tmp/apache2_#{@version_us}.tgz") @file = File.join(Dir.pwd, "apache2-#{@version}.tar.gz") @knife.name_args << @version end - it 'should download the desired version' do + it "should download the desired version" do expect(@noauth_rest).to receive(:get). with("#{@cookbook_api_url}/apache2/versions/#{@version_us}"). and_return(@cookbook_data) expect(@noauth_rest).to receive(:get). - with(@cookbook_data['file'], true). + with(@cookbook_data["file"], true). and_return(@temp_file) expect(FileUtils).to receive(:cp).with(@temp_file.path, @file) @knife.run diff --git a/spec/unit/knife/cookbook_site_install_spec.rb b/spec/unit/knife/cookbook_site_install_spec.rb index 9779de4a64..c2ffe4bb14 100644 --- a/spec/unit/knife/cookbook_site_install_spec.rb +++ b/spec/unit/knife/cookbook_site_install_spec.rb @@ -28,14 +28,14 @@ describe Chef::Knife::CookbookSiteInstall do :merge_updates_from => true) } let(:install_path) { if Chef::Platform.windows? - 'C:/tmp/chef' + "C:/tmp/chef" else - '/var/tmp/chef' + "/var/tmp/chef" end } before(:each) do - require 'chef/knife/core/cookbook_scm_repo' + require "chef/knife/core/cookbook_scm_repo" allow(knife.ui).to receive(:stdout).and_return(stdout) knife.config = {} diff --git a/spec/unit/knife/cookbook_site_share_spec.rb b/spec/unit/knife/cookbook_site_share_spec.rb index 14ade10e09..5cd90bc0c4 100644 --- a/spec/unit/knife/cookbook_site_share_spec.rb +++ b/spec/unit/knife/cookbook_site_share_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/cookbook_uploader' -require 'chef/cookbook_site_streaming_uploader' +require "chef/cookbook_uploader" +require "chef/cookbook_site_streaming_uploader" describe Chef::Knife::CookbookSiteShare do @@ -27,11 +27,11 @@ describe Chef::Knife::CookbookSiteShare do @knife = Chef::Knife::CookbookSiteShare.new # Merge default settings in. @knife.merge_configs - @knife.name_args = ['cookbook_name', 'AwesomeSausage'] + @knife.name_args = ["cookbook_name", "AwesomeSausage"] - @cookbook = Chef::CookbookVersion.new('cookbook_name') + @cookbook = Chef::CookbookVersion.new("cookbook_name") - @cookbook_loader = double('Chef::CookbookLoader') + @cookbook_loader = double("Chef::CookbookLoader") allow(@cookbook_loader).to receive(:cookbook_exists?).and_return(true) allow(@cookbook_loader).to receive(:[]).and_return(@cookbook) allow(Chef::CookbookLoader).to receive(:new).and_return(@cookbook_loader) @@ -39,7 +39,7 @@ describe Chef::Knife::CookbookSiteShare do @noauth_rest = double(Chef::ServerAPI) allow(@knife).to receive(:noauth_rest).and_return(@noauth_rest) - @cookbook_uploader = Chef::CookbookUploader.new('herpderp', :rest => "norest") + @cookbook_uploader = Chef::CookbookUploader.new("herpderp", :rest => "norest") allow(Chef::CookbookUploader).to receive(:new).and_return(@cookbook_uploader) allow(@cookbook_uploader).to receive(:validate_cookbooks).and_return(true) allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return(Dir.mktmpdir) @@ -49,7 +49,7 @@ describe Chef::Knife::CookbookSiteShare do allow(@knife.ui).to receive(:stdout).and_return(@stdout) end - describe 'run' do + describe "run" do before(:each) do allow(@knife).to receive(:do_upload).and_return(true) @@ -65,39 +65,39 @@ describe Chef::Knife::CookbookSiteShare do } end - it 'should set true to config[:dry_run] as default' do + it "should set true to config[:dry_run] as default" do expect(@knife.config[:dry_run]).to be_falsey end - it 'should should print usage and exit when given no arguments' do + it "should should print usage and exit when given no arguments" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) expect { @knife.run }.to raise_error(SystemExit) end - it 'should not fail when given only 1 argument and can determine category' do - @knife.name_args = ['cookbook_name'] + it "should not fail when given only 1 argument and can determine category" do + @knife.name_args = ["cookbook_name"] expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name").and_return(@category_response) expect(@knife).to receive(:do_upload) @knife.run end - it 'should print error and exit when given only 1 argument and cannot determine category' do - @knife.name_args = ['cookbook_name'] + it "should print error and exit when given only 1 argument and cannot determine category" do + @knife.name_args = ["cookbook_name"] expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name").and_return(@bad_category_response) expect(@knife.ui).to receive(:fatal) expect { @knife.run }.to raise_error(SystemExit) end - it 'should print error and exit when given only 1 argument and Chef::ServerAPI throws an exception' do - @knife.name_args = ['cookbook_name'] + it "should print error and exit when given only 1 argument and Chef::ServerAPI throws an exception" do + @knife.name_args = ["cookbook_name"] expect(@noauth_rest).to receive(:get).with("https://supermarket.chef.io/api/v1/cookbooks/cookbook_name") { raise Errno::ECONNREFUSED, "Connection refused" } expect(@knife.ui).to receive(:fatal) expect { @knife.run }.to raise_error(SystemExit) end - it 'should check if the cookbook exists' do + it "should check if the cookbook exists" do expect(@cookbook_loader).to receive(:cookbook_exists?) @knife.run end @@ -108,15 +108,15 @@ describe Chef::Knife::CookbookSiteShare do expect { @knife.run }.to raise_error(SystemExit) end - if File.exists?('/usr/bin/gnutar') || File.exists?('/bin/gnutar') - it 'should use gnutar to make a tarball of the cookbook' do + if File.exists?("/usr/bin/gnutar") || File.exists?("/bin/gnutar") + it "should use gnutar to make a tarball of the cookbook" do expect(@knife).to receive(:shell_out!) do |args| expect(args.to_s).to match(/gnutar -czf/) end @knife.run end else - it 'should make a tarball of the cookbook' do + it "should make a tarball of the cookbook" do expect(@knife).to receive(:shell_out!) do |args| expect(args.to_s).to match(/tar -czf/) end @@ -124,13 +124,13 @@ describe Chef::Knife::CookbookSiteShare do end end - it 'should exit and log to error when the tarball creation fails' do + it "should exit and log to error when the tarball creation fails" do allow(@knife).to receive(:shell_out!).and_raise(Chef::Exceptions::Exec) expect(@knife.ui).to receive(:error) expect { @knife.run }.to raise_error(SystemExit) end - it 'should upload the cookbook and clean up the tarball' do + it "should upload the cookbook and clean up the tarball" do expect(@knife).to receive(:do_upload) expect(FileUtils).to receive(:rm_rf) @knife.run @@ -140,7 +140,7 @@ describe Chef::Knife::CookbookSiteShare do before do allow(Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return("/var/tmp/dummy") @knife.config = { :dry_run => true } - allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return('file') + allow(@knife).to receive_message_chain(:shell_out!, :stdout).and_return("file") end it "should list files in the tarball" do @@ -158,10 +158,10 @@ describe Chef::Knife::CookbookSiteShare do end end - describe 'do_upload' do + describe "do_upload" do before(:each) do - @upload_response = double('Net::HTTPResponse') + @upload_response = double("Net::HTTPResponse") allow(Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(@upload_response) @stdout = StringIO.new @@ -172,22 +172,22 @@ describe Chef::Knife::CookbookSiteShare do end it 'should post the cookbook to "https://supermarket.chef.io"' do - response_text = Chef::JSONCompat.to_json({:uri => 'https://supermarket.chef.io/cookbooks/cookbook_name'}) + response_text = Chef::JSONCompat.to_json({:uri => "https://supermarket.chef.io/cookbooks/cookbook_name"}) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(201) expect(Chef::CookbookSiteStreamingUploader).to receive(:post).with(/supermarket\.chef\.io/, anything(), anything(), anything()) @knife.run end - it 'should alert the user when a version already exists' do - response_text = Chef::JSONCompat.to_json({:error_messages => ['Version already exists']}) + it "should alert the user when a version already exists" do + response_text = Chef::JSONCompat.to_json({:error_messages => ["Version already exists"]}) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(409) expect { @knife.run }.to raise_error(SystemExit) expect(@stderr.string).to match(/ERROR(.+)cookbook already exists/) end - it 'should pass any errors on to the user' do + it "should pass any errors on to the user" do response_text = Chef::JSONCompat.to_json({:error_messages => ["You're holding it wrong"]}) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(403) @@ -195,7 +195,7 @@ describe Chef::Knife::CookbookSiteShare do expect(@stderr.string).to match("ERROR(.*)You're holding it wrong") end - it 'should print the body if no errors are exposed on failure' do + it "should print the body if no errors are exposed on failure" do response_text = Chef::JSONCompat.to_json({:system_error => "Your call was dropped", :reason => "There's a map for that"}) allow(@upload_response).to receive(:body).and_return(response_text) allow(@upload_response).to receive(:code).and_return(500) diff --git a/spec/unit/knife/cookbook_site_unshare_spec.rb b/spec/unit/knife/cookbook_site_unshare_spec.rb index aafb7c1507..d8c67aae20 100644 --- a/spec/unit/knife/cookbook_site_unshare_spec.rb +++ b/spec/unit/knife/cookbook_site_unshare_spec.rb @@ -17,26 +17,26 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::CookbookSiteUnshare do before(:each) do @knife = Chef::Knife::CookbookSiteUnshare.new - @knife.name_args = ['cookbook_name'] + @knife.name_args = ["cookbook_name"] allow(@knife).to receive(:confirm).and_return(true) - @rest = double('Chef::ServerAPI') + @rest = double("Chef::ServerAPI") allow(@rest).to receive(:delete).and_return(true) allow(@knife).to receive(:rest).and_return(@rest) @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) end - describe 'run' do + describe "run" do - describe 'with no cookbook argument' do - it 'should print the usage and exit' do + describe "with no cookbook argument" do + it "should print the usage and exit" do @knife.name_args = [] expect(@knife.ui).to receive(:fatal) expect(@knife).to receive(:show_usage) @@ -44,30 +44,30 @@ describe Chef::Knife::CookbookSiteUnshare do end end - it 'should confirm you want to unshare the cookbook' do + it "should confirm you want to unshare the cookbook" do expect(@knife).to receive(:confirm) @knife.run end - it 'should send a delete request to the cookbook site' do + it "should send a delete request to the cookbook site" do expect(@rest).to receive(:delete) @knife.run end - it 'should log an error and exit when forbidden' do - exception = double('403 "Forbidden"', :code => '403') + it "should log an error and exit when forbidden" do + exception = double('403 "Forbidden"', :code => "403") allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('403 "Forbidden"', exception)) expect(@knife.ui).to receive(:error) expect { @knife.run }.to raise_error(SystemExit) end - it 'should re-raise any non-forbidden errors on delete' do - exception = double('500 "Application Error"', :code => '500') + it "should re-raise any non-forbidden errors on delete" do + exception = double('500 "Application Error"', :code => "500") allow(@rest).to receive(:delete).and_raise(Net::HTTPServerException.new('500 "Application Error"', exception)) expect { @knife.run }.to raise_error(Net::HTTPServerException) end - it 'should log a success message' do + it "should log a success message" do expect(@knife.ui).to receive(:info) @knife.run end diff --git a/spec/unit/knife/cookbook_test_spec.rb b/spec/unit/knife/cookbook_test_spec.rb index ce74bcaa5d..3587de0c78 100644 --- a/spec/unit/knife/cookbook_test_spec.rb +++ b/spec/unit/knife/cookbook_test_spec.rb @@ -18,14 +18,14 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::CookbookTest.load_deps describe Chef::Knife::CookbookTest do before(:each) do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::CookbookTest.new - @knife.config[:cookbook_path] = File.join(CHEF_SPEC_DATA,'cookbooks') + @knife.config[:cookbook_path] = File.join(CHEF_SPEC_DATA,"cookbooks") allow(@knife.cookbook_loader).to receive(:cookbook_exists?).and_return(true) @cookbooks = [] %w{tats central_market jimmy_johns pho}.each do |cookbook_name| diff --git a/spec/unit/knife/cookbook_upload_spec.rb b/spec/unit/knife/cookbook_upload_spec.rb index ecee34f308..666974a817 100644 --- a/spec/unit/knife/cookbook_upload_spec.rb +++ b/spec/unit/knife/cookbook_upload_spec.rb @@ -19,11 +19,11 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper")) -require 'chef/cookbook_uploader' -require 'timeout' +require "chef/cookbook_uploader" +require "timeout" describe Chef::Knife::CookbookUpload do - let(:cookbook) { Chef::CookbookVersion.new('test_cookbook', '/tmp/blah.txt') } + let(:cookbook) { Chef::CookbookVersion.new("test_cookbook", "/tmp/blah.txt") } let(:cookbooks_by_name) do {cookbook.name => cookbook} @@ -40,7 +40,7 @@ describe Chef::Knife::CookbookUpload do let(:output) { StringIO.new } - let(:name_args) { ['test_cookbook'] } + let(:name_args) { ["test_cookbook"] } let(:knife) do k = Chef::Knife::CookbookUpload.new @@ -54,11 +54,11 @@ describe Chef::Knife::CookbookUpload do allow(Chef::CookbookLoader).to receive(:new).and_return(cookbook_loader) end - describe 'with --concurrency' do - it 'should upload cookbooks with predefined concurrency' do + describe "with --concurrency" do + it "should upload cookbooks with predefined concurrency" do allow(Chef::CookbookVersion).to receive(:list_all_versions).and_return({}) knife.config[:concurrency] = 3 - test_cookbook = Chef::CookbookVersion.new('test_cookbook', '/tmp/blah') + test_cookbook = Chef::CookbookVersion.new("test_cookbook", "/tmp/blah") allow(cookbook_loader).to receive(:each).and_yield("test_cookbook", test_cookbook) allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook"]) expect(Chef::CookbookUploader).to receive(:new). @@ -68,35 +68,35 @@ describe Chef::Knife::CookbookUpload do end end - describe 'run' do + describe "run" do before(:each) do allow(Chef::CookbookUploader).to receive_messages(:new => cookbook_uploader) allow(Chef::CookbookVersion).to receive(:list_all_versions).and_return({}) end - it 'should print usage and exit when a cookbook name is not provided' do + it "should print usage and exit when a cookbook name is not provided" do knife.name_args = [] expect(knife).to receive(:show_usage) expect(knife.ui).to receive(:fatal) expect { knife.run }.to raise_error(SystemExit) end - describe 'when specifying a cookbook name' do - it 'should upload the cookbook' do + describe "when specifying a cookbook name" do + it "should upload the cookbook" do expect(knife).to receive(:upload).once knife.run end - it 'should report on success' do + it "should report on success" do expect(knife).to receive(:upload).once expect(knife.ui).to receive(:info).with(/Uploaded 1 cookbook/) knife.run end end - describe 'when specifying the same cookbook name twice' do - it 'should upload the cookbook only once' do - knife.name_args = ['test_cookbook', 'test_cookbook'] + describe "when specifying the same cookbook name twice" do + it "should upload the cookbook only once" do + knife.name_args = ["test_cookbook", "test_cookbook"] expect(knife).to receive(:upload).once knife.run end @@ -105,9 +105,9 @@ describe Chef::Knife::CookbookUpload do context "when uploading a cookbook that uses deprecated overlays" do before do - allow(cookbook_loader).to receive(:merged_cookbooks).and_return(['test_cookbook']) + allow(cookbook_loader).to receive(:merged_cookbooks).and_return(["test_cookbook"]) allow(cookbook_loader).to receive(:merged_cookbook_paths). - and_return({'test_cookbook' => %w{/path/one/test_cookbook /path/two/test_cookbook}}) + and_return({"test_cookbook" => %w{/path/one/test_cookbook /path/two/test_cookbook}}) end it "emits a warning" do @@ -127,19 +127,19 @@ E end end - describe 'when specifying a cookbook name among many' do - let(:name_args) { ['test_cookbook1'] } + describe "when specifying a cookbook name among many" do + let(:name_args) { ["test_cookbook1"] } let(:cookbooks_by_name) do { - 'test_cookbook1' => Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah'), - 'test_cookbook2' => Chef::CookbookVersion.new('test_cookbook2', '/tmp/blah'), - 'test_cookbook3' => Chef::CookbookVersion.new('test_cookbook3', '/tmp/blah'), + "test_cookbook1" => Chef::CookbookVersion.new("test_cookbook1", "/tmp/blah"), + "test_cookbook2" => Chef::CookbookVersion.new("test_cookbook2", "/tmp/blah"), + "test_cookbook3" => Chef::CookbookVersion.new("test_cookbook3", "/tmp/blah"), } end it "should read only one cookbook" do - expect(cookbook_loader).to receive(:[]).once.with('test_cookbook1').and_call_original + expect(cookbook_loader).to receive(:[]).once.with("test_cookbook1").and_call_original knife.run end @@ -155,7 +155,7 @@ E end # This is testing too much. We should break it up. - describe 'when specifying a cookbook name with dependencies' do + describe "when specifying a cookbook name with dependencies" do let(:name_args) { ["test_cookbook2"] } let(:cookbooks_by_name) do @@ -164,16 +164,16 @@ E "test_cookbook3" => test_cookbook3 } end - let(:test_cookbook1) { Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah') } + let(:test_cookbook1) { Chef::CookbookVersion.new("test_cookbook1", "/tmp/blah") } let(:test_cookbook2) do - c = Chef::CookbookVersion.new('test_cookbook2') + c = Chef::CookbookVersion.new("test_cookbook2") c.metadata.depends("test_cookbook3") c end let(:test_cookbook3) do - c = Chef::CookbookVersion.new('test_cookbook3') + c = Chef::CookbookVersion.new("test_cookbook3") c.metadata.depends("test_cookbook1") c.metadata.depends("test_cookbook2") c @@ -191,8 +191,8 @@ E end end - describe 'when specifying a cookbook name with missing dependencies' do - let(:cookbook_dependency) { Chef::CookbookVersion.new('dependency', '/tmp/blah') } + describe "when specifying a cookbook name with missing dependencies" do + let(:cookbook_dependency) { Chef::CookbookVersion.new("dependency", "/tmp/blah") } before(:each) do cookbook.metadata.depends("dependency") @@ -205,22 +205,22 @@ E knife.ui = Chef::Knife::UI.new(@stdout, @stderr, @stdin, {}) end - it 'should exit and not upload the cookbook' do - expect(cookbook_loader).to receive(:[]).once.with('test_cookbook') + it "should exit and not upload the cookbook" do + expect(cookbook_loader).to receive(:[]).once.with("test_cookbook") expect(cookbook_loader).not_to receive(:load_cookbooks) expect(cookbook_uploader).not_to receive(:upload_cookbooks) expect {knife.run}.to raise_error(SystemExit) end - it 'should output a message for a single missing dependency' do + it "should output a message for a single missing dependency" do expect {knife.run}.to raise_error(SystemExit) - expect(@stderr.string).to include('Cookbook test_cookbook depends on cookbooks which are not currently') - expect(@stderr.string).to include('being uploaded and cannot be found on the server.') + expect(@stderr.string).to include("Cookbook test_cookbook depends on cookbooks which are not currently") + expect(@stderr.string).to include("being uploaded and cannot be found on the server.") expect(@stderr.string).to include("The missing cookbook(s) are: 'dependency' version '>= 0.0.0'") end - it 'should output a message for a multiple missing dependencies which are concatenated' do - cookbook_dependency2 = Chef::CookbookVersion.new('dependency2') + it "should output a message for a multiple missing dependencies which are concatenated" do + cookbook_dependency2 = Chef::CookbookVersion.new("dependency2") cookbook.metadata.depends("dependency2") allow(cookbook_loader).to receive(:[]) do |ckbk| { "test_cookbook" => cookbook, @@ -229,8 +229,8 @@ E end allow(knife).to receive(:cookbook_names).and_return(["dependency", "dependency2", "test_cookbook"]) expect {knife.run}.to raise_error(SystemExit) - expect(@stderr.string).to include('Cookbook test_cookbook depends on cookbooks which are not currently') - expect(@stderr.string).to include('being uploaded and cannot be found on the server.') + expect(@stderr.string).to include("Cookbook test_cookbook depends on cookbooks which are not currently") + expect(@stderr.string).to include("being uploaded and cannot be found on the server.") expect(@stderr.string).to include("The missing cookbook(s) are:") expect(@stderr.string).to include("'dependency' version '>= 0.0.0'") expect(@stderr.string).to include("'dependency2' version '>= 0.0.0'") @@ -243,31 +243,31 @@ E knife.run end - describe 'with -a or --all' do + describe "with -a or --all" do before(:each) do knife.config[:all] = true end - context 'when cookbooks exist in the cookbook path' do + context "when cookbooks exist in the cookbook path" do before(:each) do - @test_cookbook1 = Chef::CookbookVersion.new('test_cookbook1', '/tmp/blah') - @test_cookbook2 = Chef::CookbookVersion.new('test_cookbook2', '/tmp/blah') + @test_cookbook1 = Chef::CookbookVersion.new("test_cookbook1", "/tmp/blah") + @test_cookbook2 = Chef::CookbookVersion.new("test_cookbook2", "/tmp/blah") allow(cookbook_loader).to receive(:each).and_yield("test_cookbook1", @test_cookbook1).and_yield("test_cookbook2", @test_cookbook2) allow(cookbook_loader).to receive(:cookbook_names).and_return(["test_cookbook1", "test_cookbook2"]) end - it 'should upload all cookbooks' do + it "should upload all cookbooks" do expect(knife).to receive(:upload).once knife.run end - it 'should report on success' do + it "should report on success" do expect(knife).to receive(:upload).once expect(knife.ui).to receive(:info).with(/Uploaded all cookbooks/) knife.run end - it 'should update the version constraints for an environment' do + it "should update the version constraints for an environment" do allow(knife).to receive(:assert_environment_valid!).and_return(true) knife.config[:environment] = "production" expect(knife).to receive(:update_version_constraints).once @@ -275,28 +275,28 @@ E end end - context 'when no cookbooks exist in the cookbook path' do + context "when no cookbooks exist in the cookbook path" do before(:each) do allow(cookbook_loader).to receive(:each) end - it 'should not upload any cookbooks' do + it "should not upload any cookbooks" do expect(knife).to_not receive(:upload) knife.run end - context 'when cookbook path is an array' do - it 'should warn users that no cookbooks exist' do - knife.config[:cookbook_path] = ['/chef-repo/cookbooks', '/home/user/cookbooks'] + context "when cookbook path is an array" do + it "should warn users that no cookbooks exist" do + knife.config[:cookbook_path] = ["/chef-repo/cookbooks", "/home/user/cookbooks"] expect(knife.ui).to receive(:warn).with( /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path].join(', ')}\. Use --cookbook-path to specify the desired path\./) knife.run end end - context 'when cookbook path is a string' do - it 'should warn users that no cookbooks exist' do - knife.config[:cookbook_path] = '/chef-repo/cookbooks' + context "when cookbook path is a string" do + it "should warn users that no cookbooks exist" do + knife.config[:cookbook_path] = "/chef-repo/cookbooks" expect(knife.ui).to receive(:warn).with( /Could not find any cookbooks in your cookbook path: #{knife.config[:cookbook_path]}\. Use --cookbook-path to specify the desired path\./) knife.run @@ -305,8 +305,8 @@ E end end - describe 'when a frozen cookbook exists on the server' do - it 'should fail to replace it' do + describe "when a frozen cookbook exists on the server" do + it "should fail to replace it" do exception = Chef::Exceptions::CookbookFrozen.new expect(cookbook_uploader).to receive(:upload_cookbooks). and_raise(exception) @@ -315,7 +315,7 @@ E expect { knife.run }.to raise_error(SystemExit) end - it 'should not update the version constraints for an environment' do + it "should not update the version constraints for an environment" do allow(knife).to receive(:assert_environment_valid!).and_return(true) knife.config[:environment] = "production" allow(knife).to receive(:upload).and_raise(Chef::Exceptions::CookbookFrozen) diff --git a/spec/unit/knife/core/bootstrap_context_spec.rb b/spec/unit/knife/core/bootstrap_context_spec.rb index 1d93f64e32..7ecade338a 100644 --- a/spec/unit/knife/core/bootstrap_context_spec.rb +++ b/spec/unit/knife/core/bootstrap_context_spec.rb @@ -16,17 +16,17 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/core/bootstrap_context' +require "spec_helper" +require "chef/knife/core/bootstrap_context" describe Chef::Knife::Core::BootstrapContext do let(:config) { {:foo => :bar, :color => true} } - let(:run_list) { Chef::RunList.new('recipe[tmux]', 'role[base]') } + let(:run_list) { Chef::RunList.new("recipe[tmux]", "role[base]") } let(:chef_config) do { - :validation_key => File.join(CHEF_SPEC_DATA, 'ssl', 'private_key.pem'), - :chef_server_url => 'http://chef.example.com:4444', - :validation_client_name => 'chef-validator-testing', + :validation_key => File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem"), + :chef_server_url => "http://chef.example.com:4444", + :validation_client_name => "chef-validator-testing", } end @@ -57,7 +57,7 @@ describe Chef::Knife::Core::BootstrapContext do end it "reads the validation key" do - expect(bootstrap_context.validation_key).to eq IO.read(File.join(CHEF_SPEC_DATA, 'ssl', 'private_key.pem')) + expect(bootstrap_context.validation_key).to eq IO.read(File.join(CHEF_SPEC_DATA, "ssl", "private_key.pem")) end it "generates the config file data" do @@ -75,23 +75,23 @@ EXPECTED end describe "alternate chef-client path" do - let(:chef_config){ {:chef_client_path => '/usr/local/bin/chef-client'} } + let(:chef_config){ {:chef_client_path => "/usr/local/bin/chef-client"} } it "runs chef-client from another path when specified" do expect(bootstrap_context.start_chef).to eq "/usr/local/bin/chef-client -j /etc/chef/first-boot.json" end end describe "validation key path that contains a ~" do - let(:chef_config){ {:validation_key => '~/my.key'} } + let(:chef_config){ {:validation_key => "~/my.key"} } it "reads the validation key when it contains a ~" do - expect(File).to receive(:exist?).with(File.expand_path("my.key", ENV['HOME'])).and_return(true) - expect(IO).to receive(:read).with(File.expand_path("my.key", ENV['HOME'])) + expect(File).to receive(:exist?).with(File.expand_path("my.key", ENV["HOME"])).and_return(true) + expect(IO).to receive(:read).with(File.expand_path("my.key", ENV["HOME"])) bootstrap_context.validation_key end end describe "when an explicit node name is given" do - let(:config){ {:chef_node_name => 'foobar.example.com' }} + let(:config){ {:chef_node_name => "foobar.example.com" }} it "sets the node name in the client.rb" do expect(bootstrap_context.config_content).to match(/node_name "foobar\.example\.com"/) end @@ -100,7 +100,7 @@ EXPECTED describe "when bootstrapping into a specific environment" do let(:config){ {:environment => "prodtastic", :color => true} } it "starts chef in the configured environment" do - expect(bootstrap_context.start_chef).to eq('chef-client -j /etc/chef/first-boot.json -E prodtastic') + expect(bootstrap_context.start_chef).to eq("chef-client -j /etc/chef/first-boot.json -E prodtastic") end end diff --git a/spec/unit/knife/core/cookbook_scm_repo_spec.rb b/spec/unit/knife/core/cookbook_scm_repo_spec.rb index 2d66df31c1..b29091188e 100644 --- a/spec/unit/knife/core/cookbook_scm_repo_spec.rb +++ b/spec/unit/knife/core/cookbook_scm_repo_spec.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/core/cookbook_scm_repo' +require "spec_helper" +require "chef/knife/core/cookbook_scm_repo" describe Chef::Knife::CookbookSCMRepo do before do - @repo_path = File.join(CHEF_SPEC_DATA, 'cookbooks') + @repo_path = File.join(CHEF_SPEC_DATA, "cookbooks") @stdout, @stderr, @stdin = StringIO.new, StringIO.new, StringIO.new @ui = Chef::Knife::UI.new(@stdout, @stderr, @stdin, {}) - @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => 'master') + @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => "master") @branch_list = Mixlib::ShellOut.new @branch_list.stdout.replace(<<-BRANCHES) @@ -43,7 +43,7 @@ BRANCHES end it "has a default branch" do - expect(@cookbook_repo.default_branch).to eq('master') + expect(@cookbook_repo.default_branch).to eq("master") end describe "when sanity checking the repo" do @@ -64,12 +64,12 @@ BRANCHES describe "and the repo is a git repo" do before do - allow(::File).to receive(:directory?).with(File.join(@repo_path, '.git')).and_return(true) + allow(::File).to receive(:directory?).with(File.join(@repo_path, ".git")).and_return(true) end it "exits when the default branch doesn't exist" do @nobranches = Mixlib::ShellOut.new.tap {|s|s.stdout.replace "\n"} - expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@nobranches) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@nobranches) expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit) end @@ -85,14 +85,14 @@ BRANCHES @dirty_status.stdout.replace(<<-DIRTY) M chef/lib/chef/knife/cookbook_site_vendor.rb DIRTY - expect(@cookbook_repo).to receive(:shell_out!).with('git status --porcelain', :cwd => @repo_path).and_return(@dirty_status) + expect(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@dirty_status) expect {@cookbook_repo.sanity_check}.to raise_error(SystemExit) end describe "and the repo is clean" do before do @clean_status = Mixlib::ShellOut.new.tap {|s| s.stdout.replace("\n")} - allow(@cookbook_repo).to receive(:shell_out!).with('git status --porcelain', :cwd => @repo_path).and_return(@clean_status) + allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain", :cwd => @repo_path).and_return(@clean_status) end it "passes the sanity check" do @@ -106,35 +106,35 @@ DIRTY end it "resets to default state by checking out the default branch" do - expect(@cookbook_repo).to receive(:shell_out!).with('git checkout master', :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git checkout master", :cwd => @repo_path) @cookbook_repo.reset_to_default_state end it "determines if a the pristine copy branch exists" do - expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) expect(@cookbook_repo.branch_exists?("chef-vendor-apache2")).to be_truthy - expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) expect(@cookbook_repo.branch_exists?("chef-vendor-nginx")).to be_falsey end it "determines if a the branch not exists correctly without substring search" do - expect(@cookbook_repo).to receive(:shell_out!).twice.with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).twice.with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) expect(@cookbook_repo).not_to be_branch_exists("chef-vendor-absent") expect(@cookbook_repo).to be_branch_exists("chef-vendor-absent-new") end describe "when the pristine copy branch does not exist" do it "prepares for import by creating the pristine copy branch" do - expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list) - expect(@cookbook_repo).to receive(:shell_out!).with('git checkout -b chef-vendor-nginx', :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).with("git checkout -b chef-vendor-nginx", :cwd => @repo_path) @cookbook_repo.prepare_to_import("nginx") end end describe "when the pristine copy branch does exist" do it "prepares for import by checking out the pristine copy branch" do - expect(@cookbook_repo).to receive(:shell_out!).with('git branch --no-color', :cwd => @repo_path).and_return(@branch_list) - expect(@cookbook_repo).to receive(:shell_out!).with('git checkout chef-vendor-apache2', :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git branch --no-color", :cwd => @repo_path).and_return(@branch_list) + expect(@cookbook_repo).to receive(:shell_out!).with("git checkout chef-vendor-apache2", :cwd => @repo_path) @cookbook_repo.prepare_to_import("apache2") end end @@ -143,15 +143,15 @@ DIRTY before do @updates = Mixlib::ShellOut.new @updates.stdout.replace("\n") - allow(@cookbook_repo).to receive(:shell_out!).with('git status --porcelain -- apache2', :cwd => @repo_path).and_return(@updates) + allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", :cwd => @repo_path).and_return(@updates) end it "shows no changes in the pristine copy" do - expect(@cookbook_repo.updated?('apache2')).to be_falsey + expect(@cookbook_repo.updated?("apache2")).to be_falsey end it "does nothing to finalize the updates" do - expect(@cookbook_repo.finalize_updates_to('apache2', '1.2.3')).to be_falsey + expect(@cookbook_repo.finalize_updates_to("apache2", "1.2.3")).to be_falsey end end @@ -159,11 +159,11 @@ DIRTY before do @updates = Mixlib::ShellOut.new @updates.stdout.replace(" M cookbooks/apache2/recipes/default.rb\n") - allow(@cookbook_repo).to receive(:shell_out!).with('git status --porcelain -- apache2', :cwd => @repo_path).and_return(@updates) + allow(@cookbook_repo).to receive(:shell_out!).with("git status --porcelain -- apache2", :cwd => @repo_path).and_return(@updates) end it "shows changes in the pristine copy" do - expect(@cookbook_repo.updated?('apache2')).to be_truthy + expect(@cookbook_repo.updated?("apache2")).to be_truthy end it "commits the changes to the repo and tags the commit" do @@ -176,11 +176,11 @@ DIRTY describe "when a custom default branch is specified" do before do - @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => 'develop') + @cookbook_repo = Chef::Knife::CookbookSCMRepo.new(@repo_path, @ui, :default_branch => "develop") end it "resets to default state by checking out the default branch" do - expect(@cookbook_repo).to receive(:shell_out!).with('git checkout develop', :cwd => @repo_path) + expect(@cookbook_repo).to receive(:shell_out!).with("git checkout develop", :cwd => @repo_path) @cookbook_repo.reset_to_default_state end end diff --git a/spec/unit/knife/core/custom_manifest_loader_spec.rb b/spec/unit/knife/core/custom_manifest_loader_spec.rb index 1edbedd3c8..f15710274c 100644 --- a/spec/unit/knife/core/custom_manifest_loader_spec.rb +++ b/spec/unit/knife/core/custom_manifest_loader_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::SubcommandLoader::CustomManifestLoader do let(:ec2_server_create_plugin) { "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_server_create.rb" } @@ -30,7 +30,7 @@ describe Chef::Knife::SubcommandLoader::CustomManifestLoader do } end let(:loader) do - Chef::Knife::SubcommandLoader::CustomManifestLoader.new(File.join(CHEF_SPEC_DATA, 'knife-site-subcommands'), + Chef::Knife::SubcommandLoader::CustomManifestLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands"), manifest_content) end diff --git a/spec/unit/knife/core/gem_glob_loader_spec.rb b/spec/unit/knife/core/gem_glob_loader_spec.rb index 89de9f98e4..671fabf695 100644 --- a/spec/unit/knife/core/gem_glob_loader_spec.rb +++ b/spec/unit/knife/core/gem_glob_loader_spec.rb @@ -15,12 +15,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::SubcommandLoader::GemGlobLoader do - let(:loader) { Chef::Knife::SubcommandLoader::GemGlobLoader.new(File.join(CHEF_SPEC_DATA, 'knife-site-subcommands')) } - let(:home) { File.join(CHEF_SPEC_DATA, 'knife-home') } - let(:plugin_dir) { File.join(home, '.chef', 'plugins', 'knife') } + let(:loader) { Chef::Knife::SubcommandLoader::GemGlobLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands")) } + let(:home) { File.join(CHEF_SPEC_DATA, "knife-home") } + let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") } before do allow(ChefConfig).to receive(:windows?) { false } @@ -39,15 +39,15 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do end it "finds files installed via rubygems" do - expect(loader.find_subcommands_via_rubygems).to include('chef/knife/node_create') + expect(loader.find_subcommands_via_rubygems).to include("chef/knife/node_create") loader.find_subcommands_via_rubygems.each {|rel_path, abs_path| expect(abs_path).to match(%r[chef/knife/.+])} end it "finds files from latest version of installed gems" do - gems = [ double('knife-ec2-0.5.12') ] + gems = [ double("knife-ec2-0.5.12") ] gem_files = [ - '/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_base.rb', - '/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_otherstuff.rb', + "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_base.rb", + "/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/ec2_otherstuff.rb", ] expect($LOAD_PATH).to receive(:map).and_return([]) if Gem::Specification.respond_to? :latest_specs @@ -55,26 +55,26 @@ describe Chef::Knife::SubcommandLoader::GemGlobLoader do expect(gems[0]).to receive(:matches_for_glob).with(/chef\/knife\/\*\.rb\{(.*),\.rb,(.*)\}/).and_return(gem_files) else expect(Gem.source_index).to receive(:latest_specs).with(true).and_return(gems) - expect(gems[0]).to receive(:require_paths).twice.and_return(['lib']) - expect(gems[0]).to receive(:full_gem_path).and_return('/usr/lib/ruby/gems/knife-ec2-0.5.12') - expect(Dir).to receive(:[]).with('/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/*.rb').and_return(gem_files) + expect(gems[0]).to receive(:require_paths).twice.and_return(["lib"]) + expect(gems[0]).to receive(:full_gem_path).and_return("/usr/lib/ruby/gems/knife-ec2-0.5.12") + expect(Dir).to receive(:[]).with("/usr/lib/ruby/gems/knife-ec2-0.5.12/lib/chef/knife/*.rb").and_return(gem_files) end expect(loader).to receive(:find_subcommands_via_dirglob).and_return({}) expect(loader.subcommand_files.select { |file| file =~ /knife-ec2/ }.sort).to eq(gem_files) end it "finds files using a dirglob when rubygems is not available" do - expect(loader.find_subcommands_via_dirglob).to include('chef/knife/node_create') + expect(loader.find_subcommands_via_dirglob).to include("chef/knife/node_create") loader.find_subcommands_via_dirglob.each {|rel_path, abs_path| expect(abs_path).to match(%r[chef/knife/.+])} end it "finds user-specific subcommands in the user's ~/.chef directory" do - expected_command = File.join(home, '.chef', 'plugins', 'knife', 'example_home_subcommand.rb') + expected_command = File.join(home, ".chef", "plugins", "knife", "example_home_subcommand.rb") expect(loader.site_subcommands).to include(expected_command) end it "finds repo specific subcommands by searching for a .chef directory" do - expected_command = File.join(CHEF_SPEC_DATA, 'knife-site-subcommands', 'plugins', 'knife', 'example_subcommand.rb') + expected_command = File.join(CHEF_SPEC_DATA, "knife-site-subcommands", "plugins", "knife", "example_subcommand.rb") expect(loader.site_subcommands).to include(expected_command) end diff --git a/spec/unit/knife/core/hashed_command_loader_spec.rb b/spec/unit/knife/core/hashed_command_loader_spec.rb index 1a6c2f42b7..45ee377ac6 100644 --- a/spec/unit/knife/core/hashed_command_loader_spec.rb +++ b/spec/unit/knife/core/hashed_command_loader_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::SubcommandLoader::HashedCommandLoader do before do @@ -42,7 +42,7 @@ describe Chef::Knife::SubcommandLoader::HashedCommandLoader do } let(:loader) { Chef::Knife::SubcommandLoader::HashedCommandLoader.new( - File.join(CHEF_SPEC_DATA, 'knife-site-subcommands'), + File.join(CHEF_SPEC_DATA, "knife-site-subcommands"), plugin_manifest)} describe "#list_commands" do diff --git a/spec/unit/knife/core/node_editor_spec.rb b/spec/unit/knife/core/node_editor_spec.rb index 52e3aeadd5..2c1beb6ccb 100644 --- a/spec/unit/knife/core/node_editor_spec.rb +++ b/spec/unit/knife/core/node_editor_spec.rb @@ -16,34 +16,34 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/core/node_editor' +require "spec_helper" +require "chef/knife/core/node_editor" describe Chef::Knife::NodeEditor do let(:node_data) do - { 'name' => 'test_node', - 'chef_environment' => 'production', - 'automatic' => { 'foo' => 'bar' }, - 'default' => { 'alpha' => { 'bravo' => 'charlie', 'delta' => 'echo' } }, - 'normal' => { 'alpha' => { 'bravo' => 'hotel' }, 'tags' => [] }, - 'override' => { 'alpha' => { 'bravo' => 'foxtrot', 'delta' => 'golf' } }, - 'policy_name' => nil, - 'policy_group' => nil, - 'run_list' => %w(role[comedy] role[drama] recipe[mystery]) + { "name" => "test_node", + "chef_environment" => "production", + "automatic" => { "foo" => "bar" }, + "default" => { "alpha" => { "bravo" => "charlie", "delta" => "echo" } }, + "normal" => { "alpha" => { "bravo" => "hotel" }, "tags" => [] }, + "override" => { "alpha" => { "bravo" => "foxtrot", "delta" => "golf" } }, + "policy_name" => nil, + "policy_group" => nil, + "run_list" => %w(role[comedy] role[drama] recipe[mystery]), } end let(:node) { Chef::Node.from_hash(node_data) } - let(:ui) { double 'ui' } - let(:base_config) { { editor: 'cat' } } + let(:ui) { double "ui" } + let(:base_config) { { editor: "cat" } } let(:config) { base_config.merge(all_attributes: false) } subject { described_class.new(node, ui, config) } describe '#view' do - it 'returns a Hash with only the name, chef_environment, normal, ' + - 'policy_name, policy_group, and run_list properties' do + it "returns a Hash with only the name, chef_environment, normal, " + + "policy_name, policy_group, and run_list properties" do expected = node_data.select do |key,| %w[ name chef_environment normal policy_name policy_group run_list ].include?(key) @@ -52,7 +52,7 @@ describe Chef::Knife::NodeEditor do expect(subject.view).to eq(expected) end - context 'when config[:all_attributes] == true' do + context "when config[:all_attributes] == true" do let(:config) { base_config.merge(all_attributes: true) } it 'returns a Hash with all of the node\'s properties' do @@ -62,49 +62,49 @@ describe Chef::Knife::NodeEditor do end describe '#apply_updates' do - context 'when the node name is changed' do + context "when the node name is changed" do before(:each) do allow(ui).to receive(:warn) allow(ui).to receive(:confirm).and_return(true) end - it 'emits a warning and prompts for confirmation' do - data = subject.view.merge('name' => 'foo_new_name_node') + it "emits a warning and prompts for confirmation" do + data = subject.view.merge("name" => "foo_new_name_node") updated_node = subject.apply_updates(data) expect(ui).to have_received(:warn) - .with 'Changing the name of a node results in a new node being ' + - 'created, test_node will not be modified or removed.' + .with "Changing the name of a node results in a new node being " + + "created, test_node will not be modified or removed." expect(ui).to have_received(:confirm) - .with('Proceed with creation of new node') + .with("Proceed with creation of new node") expect(updated_node).to be_a(Chef::Node) end end - context 'when config[:all_attributes] == false' do + context "when config[:all_attributes] == false" do let(:config) { base_config.merge(all_attributes: false) } let(:updated_data) do subject.view.merge( - 'normal' => { 'alpha' => { 'bravo' => 'hotel2' }, 'tags' => [ 'xyz' ] }, - 'policy_name' => 'mypolicy', - 'policy_group' => 'prod', - 'run_list' => %w(role[drama] recipe[mystery]) + "normal" => { "alpha" => { "bravo" => "hotel2" }, "tags" => [ "xyz" ] }, + "policy_name" => "mypolicy", + "policy_group" => "prod", + "run_list" => %w(role[drama] recipe[mystery]), ) end - it 'returns a node with run_list and normal_attrs changed' do + it "returns a node with run_list and normal_attrs changed" do updated_node = subject.apply_updates(updated_data) expect(updated_node).to be_a(Chef::Node) # Expected to have been changed - expect(updated_node.chef_environment).to eql(updated_data['chef_environment']) - expect(updated_node.normal_attrs).to eql(updated_data['normal']) - expect(updated_node.policy_name).to eql(updated_data['policy_name']) - expect(updated_node.policy_group).to eql(updated_data['policy_group']) - expect(updated_node.run_list.map(&:to_s)).to eql(updated_data['run_list']) + expect(updated_node.chef_environment).to eql(updated_data["chef_environment"]) + expect(updated_node.normal_attrs).to eql(updated_data["normal"]) + expect(updated_node.policy_name).to eql(updated_data["policy_name"]) + expect(updated_node.policy_group).to eql(updated_data["policy_group"]) + expect(updated_node.run_list.map(&:to_s)).to eql(updated_data["run_list"]) # Expected not to have changed expect(updated_node.default_attrs).to eql(node.default_attrs) @@ -113,57 +113,57 @@ describe Chef::Knife::NodeEditor do end end - context 'when config[:all_attributes] == true' do + context "when config[:all_attributes] == true" do let(:config) { base_config.merge(all_attributes: true) } let(:updated_data) do subject.view.merge( - 'default' => { 'alpha' => { 'bravo' => 'charlie2', 'delta' => 'echo2' } }, - 'normal' => { 'alpha' => { 'bravo' => 'hotel2' }, 'tags' => [ 'xyz' ] }, - 'override' => { 'alpha' => { 'bravo' => 'foxtrot2', 'delta' => 'golf2' } }, - 'policy_name' => 'mypolicy', - 'policy_group' => 'prod', - 'run_list' => %w(role[drama] recipe[mystery]) + "default" => { "alpha" => { "bravo" => "charlie2", "delta" => "echo2" } }, + "normal" => { "alpha" => { "bravo" => "hotel2" }, "tags" => [ "xyz" ] }, + "override" => { "alpha" => { "bravo" => "foxtrot2", "delta" => "golf2" } }, + "policy_name" => "mypolicy", + "policy_group" => "prod", + "run_list" => %w(role[drama] recipe[mystery]), ) end - it 'returns a node with all editable properties changed' do + it "returns a node with all editable properties changed" do updated_node = subject.apply_updates(updated_data) expect(updated_node).to be_a(Chef::Node) - expect(updated_node.chef_environment).to eql(updated_data['chef_environment']) - expect(updated_node.automatic_attrs).to eql(updated_data['automatic']) - expect(updated_node.normal_attrs).to eql(updated_data['normal']) - expect(updated_node.default_attrs).to eql(updated_data['default']) - expect(updated_node.override_attrs).to eql(updated_data['override']) - expect(updated_node.policy_name).to eql(updated_data['policy_name']) - expect(updated_node.policy_group).to eql(updated_data['policy_group']) - expect(updated_node.run_list.map(&:to_s)).to eql(updated_data['run_list']) + expect(updated_node.chef_environment).to eql(updated_data["chef_environment"]) + expect(updated_node.automatic_attrs).to eql(updated_data["automatic"]) + expect(updated_node.normal_attrs).to eql(updated_data["normal"]) + expect(updated_node.default_attrs).to eql(updated_data["default"]) + expect(updated_node.override_attrs).to eql(updated_data["override"]) + expect(updated_node.policy_name).to eql(updated_data["policy_name"]) + expect(updated_node.policy_group).to eql(updated_data["policy_group"]) + expect(updated_node.run_list.map(&:to_s)).to eql(updated_data["run_list"]) end end end describe '#updated?' do - context 'before the node has been edited' do - it 'returns false' do + context "before the node has been edited" do + it "returns false" do expect(subject.updated?).to be false end end - context 'after the node has been edited' do - context 'and changes were made' do + context "after the node has been edited" do + context "and changes were made" do let(:updated_data) do subject.view.merge( - 'default' => { 'alpha' => { 'bravo' => 'charlie2', 'delta' => 'echo2' } }, - 'normal' => { 'alpha' => { 'bravo' => 'hotel2' }, 'tags' => [ 'xyz' ] }, - 'override' => { 'alpha' => { 'bravo' => 'foxtrot2', 'delta' => 'golf2' } }, - 'policy_name' => 'mypolicy', - 'policy_group' => 'prod', - 'run_list' => %w(role[drama] recipe[mystery]) + "default" => { "alpha" => { "bravo" => "charlie2", "delta" => "echo2" } }, + "normal" => { "alpha" => { "bravo" => "hotel2" }, "tags" => [ "xyz" ] }, + "override" => { "alpha" => { "bravo" => "foxtrot2", "delta" => "golf2" } }, + "policy_name" => "mypolicy", + "policy_group" => "prod", + "run_list" => %w(role[drama] recipe[mystery]), ) end - context 'and changes affect only editable properties' do + context "and changes affect only editable properties" do before(:each) do allow(ui).to receive(:edit_data) .with(subject.view) @@ -172,14 +172,14 @@ describe Chef::Knife::NodeEditor do subject.edit_node end - it 'returns an array of the changed property names' do + it "returns an array of the changed property names" do expect(subject.updated?).to eql %w[ normal policy_name policy_group run_list ] end end - context 'and the changes include non-editable properties' do + context "and the changes include non-editable properties" do before(:each) do - data = updated_data.merge('bad_property' => 'bad_value') + data = updated_data.merge("bad_property" => "bad_value") allow(ui).to receive(:edit_data) .with(subject.view) @@ -189,13 +189,13 @@ describe Chef::Knife::NodeEditor do end it 'returns an array of property names that doesn\'t include ' + - 'the non-editable properties' do + "the non-editable properties" do expect(subject.updated?).to eql %w[ normal policy_name policy_group run_list ] end end end - context 'and changes were not made' do + context "and changes were not made" do before(:each) do allow(ui).to receive(:edit_data) .with(subject.view) diff --git a/spec/unit/knife/core/object_loader_spec.rb b/spec/unit/knife/core/object_loader_spec.rb index 0b572cc1f0..50f358379e 100644 --- a/spec/unit/knife/core/object_loader_spec.rb +++ b/spec/unit/knife/core/object_loader_spec.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/core/object_loader' +require "spec_helper" +require "chef/knife/core/object_loader" describe Chef::Knife::Core::ObjectLoader do before(:each) do @knife = Chef::Knife.new @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) - Dir.chdir(File.join(CHEF_SPEC_DATA, 'object_loader')) + Dir.chdir(File.join(CHEF_SPEC_DATA, "object_loader")) end shared_examples_for "Chef object" do |chef_class| @@ -34,14 +34,14 @@ describe Chef::Knife::Core::ObjectLoader do end it "should has a attribute 'name'" do - expect(@object.name).to eql('test') + expect(@object.name).to eql("test") end end { - 'nodes' => Chef::Node, - 'roles' => Chef::Role, - 'environments' => Chef::Environment, + "nodes" => Chef::Node, + "roles" => Chef::Role, + "environments" => Chef::Environment, }.each do |repo_location, chef_class| describe "when the file is a #{chef_class}" do @@ -51,7 +51,7 @@ describe Chef::Knife::Core::ObjectLoader do describe "when the file is a Ruby" do before do - @object = @loader.load_from(repo_location, 'test.rb') + @object = @loader.load_from(repo_location, "test.rb") end it_behaves_like "Chef object", chef_class @@ -61,7 +61,7 @@ describe Chef::Knife::Core::ObjectLoader do describe "when the file is a JSON" do describe "and it has defined 'json_class'" do before do - @object = @loader.load_from(repo_location, 'test_json_class.json') + @object = @loader.load_from(repo_location, "test_json_class.json") end it_behaves_like "Chef object", chef_class @@ -69,7 +69,7 @@ describe Chef::Knife::Core::ObjectLoader do describe "and it has not defined 'json_class'" do before do - @object = @loader.load_from(repo_location, 'test.json') + @object = @loader.load_from(repo_location, "test.json") end it_behaves_like "Chef object", chef_class diff --git a/spec/unit/knife/core/subcommand_loader_spec.rb b/spec/unit/knife/core/subcommand_loader_spec.rb index 2386465c75..c1712c297e 100644 --- a/spec/unit/knife/core/subcommand_loader_spec.rb +++ b/spec/unit/knife/core/subcommand_loader_spec.rb @@ -15,12 +15,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::SubcommandLoader do - let(:loader) { Chef::Knife::SubcommandLoader.new(File.join(CHEF_SPEC_DATA, 'knife-site-subcommands')) } - let(:home) { File.join(CHEF_SPEC_DATA, 'knife-home') } - let(:plugin_dir) { File.join(home, '.chef', 'plugins', 'knife') } + let(:loader) { Chef::Knife::SubcommandLoader.new(File.join(CHEF_SPEC_DATA, "knife-site-subcommands")) } + let(:home) { File.join(CHEF_SPEC_DATA, "knife-home") } + let(:plugin_dir) { File.join(home, ".chef", "plugins", "knife") } before do allow(ChefConfig).to receive(:windows?) { false } @@ -31,29 +31,29 @@ describe Chef::Knife::SubcommandLoader do Chef::Util::PathHelper.class_variable_set(:@@home_dir, nil) end - let(:config_dir) { File.join(CHEF_SPEC_DATA, 'knife-site-subcommands') } + let(:config_dir) { File.join(CHEF_SPEC_DATA, "knife-site-subcommands") } describe "#for_config" do context "when ~/.chef/plugin_manifest.json exists" do before do - allow(File).to receive(:exist?).with(File.join(home, '.chef', 'plugin_manifest.json')).and_return(true) + allow(File).to receive(:exist?).with(File.join(home, ".chef", "plugin_manifest.json")).and_return(true) end it "creates a HashedCommandLoader with the manifest has _autogenerated_command_paths" do - allow(File).to receive(:read).with(File.join(home, '.chef', 'plugin_manifest.json')).and_return("{ \"_autogenerated_command_paths\": {}}") + allow(File).to receive(:read).with(File.join(home, ".chef", "plugin_manifest.json")).and_return("{ \"_autogenerated_command_paths\": {}}") expect(Chef::Knife::SubcommandLoader.for_config(config_dir)).to be_a Chef::Knife::SubcommandLoader::HashedCommandLoader end it "creates a CustomManifestLoader with then manifest has a key other than _autogenerated_command_paths" do Chef::Config[:treat_deprecation_warnings_as_errors] = false - allow(File).to receive(:read).with(File.join(home, '.chef', 'plugin_manifest.json')).and_return("{ \"plugins\": {}}") + allow(File).to receive(:read).with(File.join(home, ".chef", "plugin_manifest.json")).and_return("{ \"plugins\": {}}") expect(Chef::Knife::SubcommandLoader.for_config(config_dir)).to be_a Chef::Knife::SubcommandLoader::CustomManifestLoader end end context "when ~/.chef/plugin_manifest.json does not exist" do before do - allow(File).to receive(:exist?).with(File.join(home, '.chef', 'plugin_manifest.json')).and_return(false) + allow(File).to receive(:exist?).with(File.join(home, ".chef", "plugin_manifest.json")).and_return(false) end it "creates a GemGlobLoader" do diff --git a/spec/unit/knife/core/ui_spec.rb b/spec/unit/knife/core/ui_spec.rb index 2c3b067e4f..b5b6a0a179 100644 --- a/spec/unit/knife/core/ui_spec.rb +++ b/spec/unit/knife/core/ui_spec.rb @@ -19,7 +19,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::UI do before do @@ -33,10 +33,10 @@ describe Chef::Knife::UI do end describe "edit" do - ruby_for_json = { 'foo' => 'bar' } + ruby_for_json = { "foo" => "bar" } json_from_ruby = "{\n \"foo\": \"bar\"\n}" json_from_editor = "{\n \"bar\": \"foo\"\n}" - ruby_from_editor = { 'bar' => 'foo' } + ruby_from_editor = { "bar" => "foo" } my_editor = "veeeye" temp_path = "/tmp/bar/baz" @@ -66,12 +66,12 @@ describe Chef::Knife::UI do before do @ui.config[:disable_editing] = false @ui.config[:editor] = my_editor - @mock = double('Tempfile') + @mock = double("Tempfile") expect(@mock).to receive(:sync=).with(true) expect(@mock).to receive(:puts).with(json_from_ruby) expect(@mock).to receive(:close) expect(@mock).to receive(:path).at_least(:once).and_return(temp_path) - expect(Tempfile).to receive(:open).with([ 'knife-edit-', '.json' ]).and_yield(@mock) + expect(Tempfile).to receive(:open).with([ "knife-edit-", ".json" ]).and_yield(@mock) end context "and the editor works" do before do @@ -114,8 +114,8 @@ describe Chef::Knife::UI do before do @ui.config[:disable_editing] = false @ui.config[:editor] = my_editor - @tempfile = Tempfile.new([ 'knife-edit-', '.json' ]) - expect(Tempfile).to receive(:open).with([ 'knife-edit-', '.json' ]).and_yield(@tempfile) + @tempfile = Tempfile.new([ "knife-edit-", ".json" ]) + expect(Tempfile).to receive(:open).with([ "knife-edit-", ".json" ]).and_yield(@tempfile) end context "and the editor works" do @@ -192,7 +192,7 @@ describe Chef::Knife::UI do end it "formats hashes appropriately" do - @ui.output({'hi' => 'a', 'lo' => 'b' }) + @ui.output({"hi" => "a", "lo" => "b" }) expect(@out.string).to eq <<EOM hi: a lo: b @@ -205,7 +205,7 @@ EOM end it "formats arrays appropriately" do - @ui.output([ 'a', 'b' ]) + @ui.output([ "a", "b" ]) expect(@out.string).to eq <<EOM a b @@ -218,17 +218,17 @@ EOM end it "formats single-member arrays appropriately" do - @ui.output([ 'a' ]) + @ui.output([ "a" ]) expect(@out.string).to eq("a\n") end it "formats nested single-member arrays appropriately" do - @ui.output([ [ 'a' ] ]) + @ui.output([ [ "a" ] ]) expect(@out.string).to eq("a\n") end it "formats nested arrays appropriately" do - @ui.output([ [ 'a', 'b' ], [ 'c', 'd' ]]) + @ui.output([ [ "a", "b" ], [ "c", "d" ]]) expect(@out.string).to eq <<EOM a b @@ -239,7 +239,7 @@ EOM end it "formats nested arrays with single- and empty subarrays appropriately" do - @ui.output([ [ 'a', 'b' ], [ 'c' ], [], [ 'd', 'e' ]]) + @ui.output([ [ "a", "b" ], [ "c" ], [], [ "d", "e" ]]) expect(@out.string).to eq <<EOM a b @@ -253,7 +253,7 @@ EOM end it "formats arrays of hashes with extra lines in between for readability" do - @ui.output([ { 'a' => 'b', 'c' => 'd' }, { 'x' => 'y' }, { 'm' => 'n', 'o' => 'p' }]) + @ui.output([ { "a" => "b", "c" => "d" }, { "x" => "y" }, { "m" => "n", "o" => "p" }]) expect(@out.string).to eq <<EOM a: b c: d @@ -266,7 +266,7 @@ EOM end it "formats hashes with empty array members appropriately" do - @ui.output({ 'a' => [], 'b' => 'c' }) + @ui.output({ "a" => [], "b" => "c" }) expect(@out.string).to eq <<EOM a: b: c @@ -274,7 +274,7 @@ EOM end it "formats hashes with single-member array values appropriately" do - @ui.output({ 'a' => [ 'foo' ], 'b' => 'c' }) + @ui.output({ "a" => [ "foo" ], "b" => "c" }) expect(@out.string).to eq <<EOM a: foo b: c @@ -282,7 +282,7 @@ EOM end it "formats hashes with array members appropriately" do - @ui.output({ 'a' => [ 'foo', 'bar' ], 'b' => 'c' }) + @ui.output({ "a" => [ "foo", "bar" ], "b" => "c" }) expect(@out.string).to eq <<EOM a: foo @@ -292,7 +292,7 @@ EOM end it "formats hashes with single-member nested array values appropriately" do - @ui.output({ 'a' => [ [ 'foo' ] ], 'b' => 'c' }) + @ui.output({ "a" => [ [ "foo" ] ], "b" => "c" }) expect(@out.string).to eq <<EOM a: foo @@ -301,14 +301,14 @@ EOM end it "formats hashes with nested array values appropriately" do - @ui.output({ 'a' => [ [ 'foo', 'bar' ], [ 'baz', 'bjork' ] ], 'b' => 'c' }) + @ui.output({ "a" => [ [ "foo", "bar" ], [ "baz", "bjork" ] ], "b" => "c" }) # XXX: using a HEREDOC at this point results in a line with required spaces which auto-whitespace removal settings # on editors will remove and will break this test. expect(@out.string).to eq("a:\n foo\n bar\n \n baz\n bjork\nb: c\n") end it "formats hashes with hash values appropriately" do - @ui.output({ 'a' => { 'aa' => 'bb', 'cc' => 'dd' }, 'b' => 'c' }) + @ui.output({ "a" => { "aa" => "bb", "cc" => "dd" }, "b" => "c" }) expect(@out.string).to eq <<EOM a: aa: bb @@ -318,7 +318,7 @@ EOM end it "formats hashes with empty hash values appropriately" do - @ui.output({ 'a' => { }, 'b' => 'c' }) + @ui.output({ "a" => { }, "b" => "c" }) expect(@out.string).to eq <<EOM a: b: c @@ -432,7 +432,7 @@ EOM context "when running on Windows" do before(:each) do - stdout = double('StringIO', :tty? => true) + stdout = double("StringIO", :tty? => true) allow(@ui).to receive(:stdout).and_return(stdout) allow(ChefConfig).to receive(:windows?) { true } Chef::Config.reset @@ -464,7 +464,7 @@ EOM let(:output) {stdout.string} let(:question) { "monkeys rule" } - let(:answer) { 'y' } + let(:answer) { "y" } let(:default_choice) { nil } let(:append_instructions) { true } @@ -583,7 +583,7 @@ EOM out = StringIO.new allow(@ui).to receive(:stdout).and_return(out) allow(@ui).to receive(:stdin).and_return(StringIO.new(" \n")) - expect(@ui.ask_question("your chef server URL? ", :default => 'http://localhost:4000')).to eq("http://localhost:4000") + expect(@ui.ask_question("your chef server URL? ", :default => "http://localhost:4000")).to eq("http://localhost:4000") expect(out.string).to eq("your chef server URL? [http://localhost:4000] ") end end diff --git a/spec/unit/knife/data_bag_create_spec.rb b/spec/unit/knife/data_bag_create_spec.rb index d022cc7f7d..3cca61be6b 100644 --- a/spec/unit/knife/data_bag_create_spec.rb +++ b/spec/unit/knife/data_bag_create_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tempfile' +require "spec_helper" +require "tempfile" describe Chef::Knife::DataBagCreate do let(:knife) do @@ -47,7 +47,7 @@ describe Chef::Knife::DataBagCreate do end it "tries to create a data bag with an invalid name when given one argument" do - knife.name_args = ['invalid&char'] + knife.name_args = ["invalid&char"] expect(Chef::DataBag).to receive(:validate_name!).with(knife.name_args[0]).and_raise(Chef::Exceptions::InvalidDataBagName) expect {knife.run}.to exit_with_code(1) end @@ -75,7 +75,7 @@ describe Chef::Knife::DataBagCreate do it "creates a data bag item" do expect(knife).to receive(:create_object).and_yield(raw_hash) expect(knife).to receive(:encryption_secret_provided?).and_return(false) - expect(rest).to receive(:post).with("data", {'name' => bag_name}).ordered + expect(rest).to receive(:post).with("data", {"name" => bag_name}).ordered expect(rest).to receive(:post).with("data/#{bag_name}", item).ordered knife.run diff --git a/spec/unit/knife/data_bag_edit_spec.rb b/spec/unit/knife/data_bag_edit_spec.rb index f1bcae990b..4e55a9386e 100644 --- a/spec/unit/knife/data_bag_edit_spec.rb +++ b/spec/unit/knife/data_bag_edit_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tempfile' +require "spec_helper" +require "tempfile" describe Chef::Knife::DataBagEdit do before do diff --git a/spec/unit/knife/data_bag_from_file_spec.rb b/spec/unit/knife/data_bag_from_file_spec.rb index ddf877d9f7..387dfc7554 100644 --- a/spec/unit/knife/data_bag_from_file_spec.rb +++ b/spec/unit/knife/data_bag_from_file_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/data_bag_item' -require 'chef/encrypted_data_bag_item' -require 'tempfile' +require "chef/data_bag_item" +require "chef/encrypted_data_bag_item" +require "tempfile" Chef::Knife::DataBagFromFile.load_deps diff --git a/spec/unit/knife/data_bag_secret_options_spec.rb b/spec/unit/knife/data_bag_secret_options_spec.rb index 0a2d8ca4bf..71a6bf7af5 100644 --- a/spec/unit/knife/data_bag_secret_options_spec.rb +++ b/spec/unit/knife/data_bag_secret_options_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife' -require 'chef/config' -require 'tempfile' +require "spec_helper" +require "chef/knife" +require "chef/config" +require "tempfile" class ExampleDataBagCommand < Chef::Knife include Chef::Knife::DataBagSecretOptions diff --git a/spec/unit/knife/data_bag_show_spec.rb b/spec/unit/knife/data_bag_show_spec.rb index 48a0071b49..427d3e4d1b 100644 --- a/spec/unit/knife/data_bag_show_spec.rb +++ b/spec/unit/knife/data_bag_show_spec.rb @@ -17,12 +17,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/data_bag_item' -require 'chef/encrypted_data_bag_item' -require 'chef/json_compat' -require 'tempfile' +require "chef/data_bag_item" +require "chef/encrypted_data_bag_item" +require "chef/json_compat" +require "tempfile" describe Chef::Knife::DataBagShow do diff --git a/spec/unit/knife/environment_compare_spec.rb b/spec/unit/knife/environment_compare_spec.rb index 14dc5c52cf..bf2c2c15f0 100644 --- a/spec/unit/knife/environment_compare_spec.rb +++ b/spec/unit/knife/environment_compare_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::EnvironmentCompare do before(:each) do @@ -40,15 +40,15 @@ describe Chef::Knife::EnvironmentCompare do allow(@knife).to receive(:cookbook_list).and_return(@cookbooks) - @rest_double = double('rest') + @rest_double = double("rest") allow(@knife).to receive(:rest).and_return(@rest_double) - @cookbook_names = ['apache2', 'mysql', 'foo', 'bar', 'dummy', 'chef_handler'] - @base_url = 'https://server.example.com/cookbooks' + @cookbook_names = ["apache2", "mysql", "foo", "bar", "dummy", "chef_handler"] + @base_url = "https://server.example.com/cookbooks" @cookbook_data = {} @cookbook_names.each do |item| - @cookbook_data[item] = {'url' => "#{@base_url}/#{item}", - 'versions' => [{'version' => '1.0.1', - 'url' => "#{@base_url}/#{item}/1.0.1"}]} + @cookbook_data[item] = {"url" => "#{@base_url}/#{item}", + "versions" => [{"version" => "1.0.1", + "url" => "#{@base_url}/#{item}/1.0.1"}]} end allow(@rest_double).to receive(:get).with("/cookbooks?num_versions=1").and_return(@cookbook_data) @@ -57,25 +57,25 @@ describe Chef::Knife::EnvironmentCompare do allow(@knife.ui).to receive(:stdout).and_return(@stdout) end - describe 'run' do - it 'should display only cookbooks with version constraints' do - @knife.config[:format] = 'summary' + describe "run" do + it "should display only cookbooks with version constraints" do + @knife.config[:format] = "summary" @knife.run @environments.each do |item, url| expect(@stdout.string).to match /#{item}/ and expect(@stdout.string.lines.count).to be 4 end end - it 'should display 4 number of lines' do - @knife.config[:format] = 'summary' + it "should display 4 number of lines" do + @knife.config[:format] = "summary" @knife.run expect(@stdout.string.lines.count).to be 4 end end - describe 'with -m or --mismatch' do - it 'should display only cookbooks that have mismatching version constraints' do - @knife.config[:format] = 'summary' + describe "with -m or --mismatch" do + it "should display only cookbooks that have mismatching version constraints" do + @knife.config[:format] = "summary" @knife.config[:mismatch] = true @knife.run @constraints.each do |item, ver| @@ -83,17 +83,17 @@ describe Chef::Knife::EnvironmentCompare do end end - it 'should display 3 number of lines' do - @knife.config[:format] = 'summary' + it "should display 3 number of lines" do + @knife.config[:format] = "summary" @knife.config[:mismatch] = true @knife.run expect(@stdout.string.lines.count).to be 3 end end - describe 'with -a or --all' do - it 'should display all cookbooks' do - @knife.config[:format] = 'summary' + describe "with -a or --all" do + it "should display all cookbooks" do + @knife.config[:format] = "summary" @knife.config[:all] = true @knife.run @constraints.each do |item, ver| @@ -101,8 +101,8 @@ describe Chef::Knife::EnvironmentCompare do end end - it 'should display 8 number of lines' do - @knife.config[:format] = 'summary' + it "should display 8 number of lines" do + @knife.config[:format] = "summary" @knife.config[:all] = true @knife.run expect(@stdout.string.lines.count).to be 8 diff --git a/spec/unit/knife/environment_create_spec.rb b/spec/unit/knife/environment_create_spec.rb index 04e45048ef..7cee275499 100644 --- a/spec/unit/knife/environment_create_spec.rb +++ b/spec/unit/knife/environment_create_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::EnvironmentCreate do before(:each) do diff --git a/spec/unit/knife/environment_delete_spec.rb b/spec/unit/knife/environment_delete_spec.rb index 95df6e15fe..262c87dcc6 100644 --- a/spec/unit/knife/environment_delete_spec.rb +++ b/spec/unit/knife/environment_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::EnvironmentDelete do before(:each) do diff --git a/spec/unit/knife/environment_edit_spec.rb b/spec/unit/knife/environment_edit_spec.rb index 61c2663a41..d23aa7234c 100644 --- a/spec/unit/knife/environment_edit_spec.rb +++ b/spec/unit/knife/environment_edit_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::EnvironmentEdit do before(:each) do diff --git a/spec/unit/knife/environment_from_file_spec.rb b/spec/unit/knife/environment_from_file_spec.rb index 11ad23c919..9ff2aceb6a 100644 --- a/spec/unit/knife/environment_from_file_spec.rb +++ b/spec/unit/knife/environment_from_file_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::EnvironmentFromFile.load_deps @@ -39,7 +39,7 @@ describe Chef::Knife::EnvironmentFromFile do describe "run" do it "loads the environment data from a file and saves it" do - expect(@knife.loader).to receive(:load_from).with('environments', 'spec.rb').and_return(@environment) + expect(@knife.loader).to receive(:load_from).with("environments", "spec.rb").and_return(@environment) expect(@environment).to receive(:save) @knife.run end diff --git a/spec/unit/knife/environment_list_spec.rb b/spec/unit/knife/environment_list_spec.rb index 1d5462257d..b01c0e57ed 100644 --- a/spec/unit/knife/environment_list_spec.rb +++ b/spec/unit/knife/environment_list_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::EnvironmentList do before(:each) do diff --git a/spec/unit/knife/environment_show_spec.rb b/spec/unit/knife/environment_show_spec.rb index caac958f8e..1c9d687d8c 100644 --- a/spec/unit/knife/environment_show_spec.rb +++ b/spec/unit/knife/environment_show_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::EnvironmentShow do before(:each) do diff --git a/spec/unit/knife/index_rebuild_spec.rb b/spec/unit/knife/index_rebuild_spec.rb index 6c1ff7b98e..187f77ee1c 100644 --- a/spec/unit/knife/index_rebuild_spec.rb +++ b/spec/unit/knife/index_rebuild_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::IndexRebuild do diff --git a/spec/unit/knife/key_create_spec.rb b/spec/unit/knife/key_create_spec.rb index 039dba7a44..4958f20321 100644 --- a/spec/unit/knife/key_create_spec.rb +++ b/spec/unit/knife/key_create_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/user_key_create' -require 'chef/knife/client_key_create' -require 'chef/knife/key_create' -require 'chef/key' +require "spec_helper" +require "chef/knife/user_key_create" +require "chef/knife/client_key_create" +require "chef/knife/key_create" +require "chef/key" describe "key create commands that inherit knife" do shared_examples_for "a key create command" do diff --git a/spec/unit/knife/key_delete_spec.rb b/spec/unit/knife/key_delete_spec.rb index 1d4b9f825f..65250df69f 100644 --- a/spec/unit/knife/key_delete_spec.rb +++ b/spec/unit/knife/key_delete_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/user_key_delete' -require 'chef/knife/client_key_delete' -require 'chef/knife/key_delete' -require 'chef/key' +require "spec_helper" +require "chef/knife/user_key_delete" +require "chef/knife/client_key_delete" +require "chef/knife/key_delete" +require "chef/key" describe "key delete commands that inherit knife" do shared_examples_for "a key delete command" do diff --git a/spec/unit/knife/key_edit_spec.rb b/spec/unit/knife/key_edit_spec.rb index 06b31ce71c..18f2cd45be 100644 --- a/spec/unit/knife/key_edit_spec.rb +++ b/spec/unit/knife/key_edit_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/user_key_edit' -require 'chef/knife/client_key_edit' -require 'chef/knife/key_edit' -require 'chef/key' +require "spec_helper" +require "chef/knife/user_key_edit" +require "chef/knife/client_key_edit" +require "chef/knife/key_edit" +require "chef/key" describe "key edit commands that inherit knife" do shared_examples_for "a key edit command" do diff --git a/spec/unit/knife/key_helper.rb b/spec/unit/knife/key_helper.rb index 36ababc09a..6a972d1e7b 100644 --- a/spec/unit/knife/key_helper.rb +++ b/spec/unit/knife/key_helper.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" shared_examples_for "a knife key command" do let(:stderr) { StringIO.new } diff --git a/spec/unit/knife/key_list_spec.rb b/spec/unit/knife/key_list_spec.rb index 775a7cdfb1..70caa249bb 100644 --- a/spec/unit/knife/key_list_spec.rb +++ b/spec/unit/knife/key_list_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/user_key_list' -require 'chef/knife/client_key_list' -require 'chef/knife/key_list' -require 'chef/key' +require "spec_helper" +require "chef/knife/user_key_list" +require "chef/knife/client_key_list" +require "chef/knife/key_list" +require "chef/key" describe "key list commands that inherit knife" do shared_examples_for "a key list command" do diff --git a/spec/unit/knife/key_show_spec.rb b/spec/unit/knife/key_show_spec.rb index f4923ef235..03b3062e62 100644 --- a/spec/unit/knife/key_show_spec.rb +++ b/spec/unit/knife/key_show_spec.rb @@ -16,11 +16,11 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/user_key_show' -require 'chef/knife/client_key_show' -require 'chef/knife/key_show' -require 'chef/key' +require "spec_helper" +require "chef/knife/user_key_show" +require "chef/knife/client_key_show" +require "chef/knife/key_show" +require "chef/key" describe "key show commands that inherit knife" do shared_examples_for "a key show command" do @@ -113,14 +113,14 @@ describe Chef::Knife::KeyShow do context "when load_method is :load_by_user" do it_should_behave_like "key show run command" do let(:load_method) { :load_by_user } - let(:actor_field_name) { 'user' } + let(:actor_field_name) { "user" } end end context "when load_method is :load_by_client" do it_should_behave_like "key show run command" do let(:load_method) { :load_by_client } - let(:actor_field_name) { 'user' } + let(:actor_field_name) { "user" } end end end diff --git a/spec/unit/knife/knife_help.rb b/spec/unit/knife/knife_help.rb index 293bae17f4..d357239e6a 100644 --- a/spec/unit/knife/knife_help.rb +++ b/spec/unit/knife/knife_help.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::Help do before(:each) do diff --git a/spec/unit/knife/node_bulk_delete_spec.rb b/spec/unit/knife/node_bulk_delete_spec.rb index 57a8d0bf64..7106fdfc7b 100644 --- a/spec/unit/knife/node_bulk_delete_spec.rb +++ b/spec/unit/knife/node_bulk_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::NodeBulkDelete do before(:each) do @@ -78,10 +78,10 @@ describe Chef::Knife::NodeBulkDelete do end it "should only delete nodes that match the regex" do - @knife.name_args = ['adam'] - expect(@inflatedish_list['adam']).to receive(:destroy) - expect(@inflatedish_list['brent']).not_to receive(:destroy) - expect(@inflatedish_list['jacob']).not_to receive(:destroy) + @knife.name_args = ["adam"] + expect(@inflatedish_list["adam"]).to receive(:destroy) + expect(@inflatedish_list["brent"]).not_to receive(:destroy) + expect(@inflatedish_list["jacob"]).not_to receive(:destroy) @knife.run end diff --git a/spec/unit/knife/node_delete_spec.rb b/spec/unit/knife/node_delete_spec.rb index 0941d850e5..b2fd54219c 100644 --- a/spec/unit/knife/node_delete_spec.rb +++ b/spec/unit/knife/node_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::NodeDelete do before(:each) do diff --git a/spec/unit/knife/node_edit_spec.rb b/spec/unit/knife/node_edit_spec.rb index be42a15ee7..c7a99517a4 100644 --- a/spec/unit/knife/node_edit_spec.rb +++ b/spec/unit/knife/node_edit_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::NodeEdit.load_deps describe Chef::Knife::NodeEdit do @@ -30,7 +30,7 @@ describe Chef::Knife::NodeEdit do Chef::Config[:node_name] = "webmonkey.example.com" @knife = Chef::Knife::NodeEdit.new @knife.config = { - :editor => 'cat', + :editor => "cat", :attribute => nil, :print_after => nil, } diff --git a/spec/unit/knife/node_environment_set_spec.rb b/spec/unit/knife/node_environment_set_spec.rb index 10267915d7..0888af05e9 100644 --- a/spec/unit/knife/node_environment_set_spec.rb +++ b/spec/unit/knife/node_environment_set_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::NodeEnvironmentSet do before(:each) do @@ -39,7 +39,7 @@ describe Chef::Knife::NodeEnvironmentSet do it "should update the environment" do @knife.run - expect(@node.chef_environment).to eq('bar') + expect(@node.chef_environment).to eq("bar") end it "should save the node" do diff --git a/spec/unit/knife/node_from_file_spec.rb b/spec/unit/knife/node_from_file_spec.rb index 623904753e..19ee8b52ff 100644 --- a/spec/unit/knife/node_from_file_spec.rb +++ b/spec/unit/knife/node_from_file_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::NodeFromFile.load_deps @@ -39,7 +39,7 @@ describe Chef::Knife::NodeFromFile do describe "run" do it "should load from a file" do - expect(@knife.loader).to receive(:load_from).with('nodes', 'adam.rb').and_return(@node) + expect(@knife.loader).to receive(:load_from).with("nodes", "adam.rb").and_return(@node) @knife.run end diff --git a/spec/unit/knife/node_list_spec.rb b/spec/unit/knife/node_list_spec.rb index ec694cb040..c043d47b29 100644 --- a/spec/unit/knife/node_list_spec.rb +++ b/spec/unit/knife/node_list_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::NodeList do before(:each) do diff --git a/spec/unit/knife/node_run_list_add_spec.rb b/spec/unit/knife/node_run_list_add_spec.rb index 92fbfd23fe..e309878a22 100644 --- a/spec/unit/knife/node_run_list_add_spec.rb +++ b/spec/unit/knife/node_run_list_add_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::NodeRunListAdd do before(:each) do @@ -40,7 +40,7 @@ describe Chef::Knife::NodeRunListAdd do it "should add to the run list" do @knife.run - expect(@node.run_list[0]).to eq('role[monkey]') + expect(@node.run_list[0]).to eq("role[monkey]") end it "should save the node" do diff --git a/spec/unit/knife/node_run_list_remove_spec.rb b/spec/unit/knife/node_run_list_remove_spec.rb index a279a59635..f450dd8016 100644 --- a/spec/unit/knife/node_run_list_remove_spec.rb +++ b/spec/unit/knife/node_run_list_remove_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::NodeRunListRemove do before(:each) do @@ -43,7 +43,7 @@ describe Chef::Knife::NodeRunListRemove do it "should remove the item from the run list" do @knife.run - expect(@node.run_list[0]).not_to eq('role[monkey]') + expect(@node.run_list[0]).not_to eq("role[monkey]") end it "should save the node" do @@ -53,50 +53,50 @@ describe Chef::Knife::NodeRunListRemove do it "should print the run list" do @knife.config[:print_after] = true - expect(@knife.ui).to receive(:output).with({ "knifetest-node" => { 'run_list' => [] } }) + expect(@knife.ui).to receive(:output).with({ "knifetest-node" => { "run_list" => [] } }) @knife.run end describe "run with a list of roles and recipes" do it "should remove the items from the run list" do - @node.run_list << 'role[monkey]' - @node.run_list << 'recipe[duck::type]' - @knife.name_args = [ 'adam', 'role[monkey],recipe[duck::type]' ] + @node.run_list << "role[monkey]" + @node.run_list << "recipe[duck::type]" + @knife.name_args = [ "adam", "role[monkey],recipe[duck::type]" ] @knife.run - expect(@node.run_list).not_to include('role[monkey]') - expect(@node.run_list).not_to include('recipe[duck::type]') + expect(@node.run_list).not_to include("role[monkey]") + expect(@node.run_list).not_to include("recipe[duck::type]") end it "should remove the items from the run list when name args contains whitespace" do - @node.run_list << 'role[monkey]' - @node.run_list << 'recipe[duck::type]' - @knife.name_args = [ 'adam', 'role[monkey], recipe[duck::type]' ] + @node.run_list << "role[monkey]" + @node.run_list << "recipe[duck::type]" + @knife.name_args = [ "adam", "role[monkey], recipe[duck::type]" ] @knife.run - expect(@node.run_list).not_to include('role[monkey]') - expect(@node.run_list).not_to include('recipe[duck::type]') + expect(@node.run_list).not_to include("role[monkey]") + expect(@node.run_list).not_to include("recipe[duck::type]") end it "should remove the items from the run list when name args contains multiple run lists" do - @node.run_list << 'role[blah]' - @node.run_list << 'recipe[duck::type]' - @knife.name_args = [ 'adam', 'role[monkey], recipe[duck::type]', 'role[blah]' ] + @node.run_list << "role[blah]" + @node.run_list << "recipe[duck::type]" + @knife.name_args = [ "adam", "role[monkey], recipe[duck::type]", "role[blah]" ] @knife.run - expect(@node.run_list).not_to include('role[monkey]') - expect(@node.run_list).not_to include('recipe[duck::type]') + expect(@node.run_list).not_to include("role[monkey]") + expect(@node.run_list).not_to include("recipe[duck::type]") end it "should warn when the thing to remove is not in the runlist" do - @node.run_list << 'role[blah]' - @node.run_list << 'recipe[duck::type]' - @knife.name_args = [ 'adam', 'role[blork]' ] + @node.run_list << "role[blah]" + @node.run_list << "recipe[duck::type]" + @knife.name_args = [ "adam", "role[blork]" ] expect(@knife.ui).to receive(:warn).with("role[blork] is not in the run list") @knife.run end it "should warn even more when the thing to remove is not in the runlist and unqualified" do - @node.run_list << 'role[blah]' - @node.run_list << 'recipe[duck::type]' - @knife.name_args = [ 'adam', 'blork' ] + @node.run_list << "role[blah]" + @node.run_list << "recipe[duck::type]" + @knife.name_args = [ "adam", "blork" ] expect(@knife.ui).to receive(:warn).with("blork is not in the run list") expect(@knife.ui).to receive(:warn).with(/did you forget recipe\[\] or role\[\]/) @knife.run diff --git a/spec/unit/knife/node_run_list_set_spec.rb b/spec/unit/knife/node_run_list_set_spec.rb index 68daaafd70..75eecfeb27 100644 --- a/spec/unit/knife/node_run_list_set_spec.rb +++ b/spec/unit/knife/node_run_list_set_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::NodeRunListSet do before(:each) do @@ -38,7 +38,7 @@ describe Chef::Knife::NodeRunListSet do it "should set the run list" do @knife.run - expect(@node.run_list[0]).to eq('role[monkey]') + expect(@node.run_list[0]).to eq("role[monkey]") end it "should save the node" do diff --git a/spec/unit/knife/node_show_spec.rb b/spec/unit/knife/node_show_spec.rb index 4806354b60..afc90dc1ed 100644 --- a/spec/unit/knife/node_show_spec.rb +++ b/spec/unit/knife/node_show_spec.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::NodeShow do let(:node) do node = Chef::Node.new() node.name("adam") - node.run_list = ['role[base]'] + node.run_list = ["role[base]"] node end @@ -54,10 +54,10 @@ describe Chef::Knife::NodeShow do end it "should pretty print json" do - knife.config[:format] = 'json' + knife.config[:format] = "json" stdout = StringIO.new allow(knife.ui).to receive(:stdout).and_return(stdout) - expect(Chef::Node).to receive(:load).with('adam').and_return(node) + expect(Chef::Node).to receive(:load).with("adam").and_return(node) knife.run expect(stdout.string).to eql("{\n \"name\": \"adam\",\n \"chef_environment\": \"_default\",\n \"run_list\": [\n\n]\n,\n \"normal\": {\n\n }\n}\n") end diff --git a/spec/unit/knife/osc_user_create_spec.rb b/spec/unit/knife/osc_user_create_spec.rb index e4ed78fe2b..006d50484d 100644 --- a/spec/unit/knife/osc_user_create_spec.rb +++ b/spec/unit/knife/osc_user_create_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::OscUserCreate.load_deps @@ -34,13 +34,13 @@ describe Chef::Knife::OscUserCreate do allow(@knife.ui).to receive(:stdout).and_return(@stdout) allow(@knife.ui).to receive(:stderr).and_return(@stderr) - @knife.name_args = [ 'a_user' ] + @knife.name_args = [ "a_user" ] @knife.config[:user_password] = "foobar" @user = Chef::User.new @user.name "a_user" @user_with_private_key = Chef::User.new @user_with_private_key.name "a_user" - @user_with_private_key.private_key 'private_key' + @user_with_private_key.private_key "private_key" allow(@user).to receive(:create).and_return(@user_with_private_key) allow(Chef::User).to receive(:new).and_return(@user) allow(Chef::User).to receive(:from_hash).and_return(@user) @@ -61,7 +61,7 @@ describe Chef::Knife::OscUserCreate do end it "exits with an error if password is blank" do - @knife.config[:user_password] = '' + @knife.config[:user_password] = "" expect { @knife.run }.to raise_error SystemExit expect(@stderr.string).to match /You must specify a non-blank password/ end @@ -86,7 +86,7 @@ describe Chef::Knife::OscUserCreate do it "writes the private key to a file when --file is specified" do @knife.config[:file] = "/tmp/a_file" filehandle = double("filehandle") - expect(filehandle).to receive(:print).with('private_key') + expect(filehandle).to receive(:print).with("private_key") expect(File).to receive(:open).with("/tmp/a_file", "w").and_yield(filehandle) @knife.run end diff --git a/spec/unit/knife/osc_user_delete_spec.rb b/spec/unit/knife/osc_user_delete_spec.rb index 4a3ec4228f..c0e3b0fbf9 100644 --- a/spec/unit/knife/osc_user_delete_spec.rb +++ b/spec/unit/knife/osc_user_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -27,15 +27,15 @@ describe Chef::Knife::OscUserDelete do before(:each) do Chef::Knife::OscUserDelete.load_deps @knife = Chef::Knife::OscUserDelete.new - @knife.name_args = [ 'my_user' ] + @knife.name_args = [ "my_user" ] end - it 'deletes the user' do - expect(@knife).to receive(:delete_object).with(Chef::User, 'my_user') + it "deletes the user" do + expect(@knife).to receive(:delete_object).with(Chef::User, "my_user") @knife.run end - it 'prints usage and exits when a user name is not provided' do + it "prints usage and exits when a user name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) diff --git a/spec/unit/knife/osc_user_edit_spec.rb b/spec/unit/knife/osc_user_edit_spec.rb index 279f2e30ef..55574bdc38 100644 --- a/spec/unit/knife/osc_user_edit_spec.rb +++ b/spec/unit/knife/osc_user_edit_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -32,18 +32,18 @@ describe Chef::Knife::OscUserEdit do @knife = Chef::Knife::OscUserEdit.new allow(@knife.ui).to receive(:stderr).and_return(@stderr) allow(@knife.ui).to receive(:stdout).and_return(@stdout) - @knife.name_args = [ 'my_user' ] + @knife.name_args = [ "my_user" ] @knife.config[:disable_editing] = true end - it 'loads and edits the user' do + it "loads and edits the user" do data = { :name => "my_user" } allow(Chef::User).to receive(:load).with("my_user").and_return(data) expect(@knife).to receive(:edit_data).with(data).and_return(data) @knife.run end - it 'prints usage and exits when a user name is not provided' do + it "prints usage and exits when a user name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) diff --git a/spec/unit/knife/osc_user_list_spec.rb b/spec/unit/knife/osc_user_list_spec.rb index f496a414b8..bc86e4ce97 100644 --- a/spec/unit/knife/osc_user_list_spec.rb +++ b/spec/unit/knife/osc_user_list_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -29,7 +29,7 @@ describe Chef::Knife::OscUserList do @knife = Chef::Knife::OscUserList.new end - it 'lists the users' do + it "lists the users" do expect(Chef::User).to receive(:list) expect(@knife).to receive(:format_list_for_display) @knife.run diff --git a/spec/unit/knife/osc_user_reregister_spec.rb b/spec/unit/knife/osc_user_reregister_spec.rb index 989eb180f1..95fa2c2dc8 100644 --- a/spec/unit/knife/osc_user_reregister_spec.rb +++ b/spec/unit/knife/osc_user_reregister_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -27,31 +27,31 @@ describe Chef::Knife::OscUserReregister do before(:each) do Chef::Knife::OscUserReregister.load_deps @knife = Chef::Knife::OscUserReregister.new - @knife.name_args = [ 'a_user' ] - @user_mock = double('user_mock', :private_key => "private_key") + @knife.name_args = [ "a_user" ] + @user_mock = double("user_mock", :private_key => "private_key") allow(Chef::User).to receive(:load).and_return(@user_mock) @stdout = StringIO.new allow(@knife.ui).to receive(:stdout).and_return(@stdout) end - it 'prints usage and exits when a user name is not provided' do + it "prints usage and exits when a user name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) expect { @knife.run }.to raise_error(SystemExit) end - it 'reregisters the user and prints the key' do + it "reregisters the user and prints the key" do expect(@user_mock).to receive(:reregister).and_return(@user_mock) @knife.run expect(@stdout.string).to match( /private_key/ ) end - it 'writes the private key to a file when --file is specified' do + it "writes the private key to a file when --file is specified" do expect(@user_mock).to receive(:reregister).and_return(@user_mock) - @knife.config[:file] = '/tmp/a_file' + @knife.config[:file] = "/tmp/a_file" filehandle = StringIO.new - expect(File).to receive(:open).with('/tmp/a_file', 'w').and_yield(filehandle) + expect(File).to receive(:open).with("/tmp/a_file", "w").and_yield(filehandle) @knife.run expect(filehandle.string).to eq("private_key") end diff --git a/spec/unit/knife/osc_user_show_spec.rb b/spec/unit/knife/osc_user_show_spec.rb index 18d2086099..12f3bb069e 100644 --- a/spec/unit/knife/osc_user_show_spec.rb +++ b/spec/unit/knife/osc_user_show_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" # DEPRECATION NOTE # This code only remains to support users still operating with @@ -27,17 +27,17 @@ describe Chef::Knife::OscUserShow do before(:each) do Chef::Knife::OscUserShow.load_deps @knife = Chef::Knife::OscUserShow.new - @knife.name_args = [ 'my_user' ] - @user_mock = double('user_mock') + @knife.name_args = [ "my_user" ] + @user_mock = double("user_mock") end - it 'loads and displays the user' do - expect(Chef::User).to receive(:load).with('my_user').and_return(@user_mock) + it "loads and displays the user" do + expect(Chef::User).to receive(:load).with("my_user").and_return(@user_mock) expect(@knife).to receive(:format_for_display).with(@user_mock) @knife.run end - it 'prints usage and exits when a user name is not provided' do + it "prints usage and exits when a user name is not provided" do @knife.name_args = [] expect(@knife).to receive(:show_usage) expect(@knife.ui).to receive(:fatal) diff --git a/spec/unit/knife/raw_spec.rb b/spec/unit/knife/raw_spec.rb index ab929abd39..14cdfbd614 100644 --- a/spec/unit/knife/raw_spec.rb +++ b/spec/unit/knife/raw_spec.rb @@ -15,11 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" describe Chef::Knife::Raw do let(:rest) do - r = double('Chef::Knife::Raw::RawInputServerAPI') + r = double("Chef::Knife::Raw::RawInputServerAPI") allow(Chef::Knife::Raw::RawInputServerAPI).to receive(:new).and_return(r) r end @@ -35,8 +35,8 @@ describe Chef::Knife::Raw do it "should set the x-ops-request-source header when --proxy-auth is set" do knife.config[:proxy_auth] = true expect(rest).to receive(:request).with(:GET, "/nodes", - { 'Content-Type' => 'application/json', - 'x-ops-request-source' => 'web'}, false) + { "Content-Type" => "application/json", + "x-ops-request-source" => "web"}, false) knife.run end end diff --git a/spec/unit/knife/role_bulk_delete_spec.rb b/spec/unit/knife/role_bulk_delete_spec.rb index 5b79e52a04..55bf05e806 100644 --- a/spec/unit/knife/role_bulk_delete_spec.rb +++ b/spec/unit/knife/role_bulk_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleBulkDelete do before(:each) do diff --git a/spec/unit/knife/role_create_spec.rb b/spec/unit/knife/role_create_spec.rb index fb748c51f6..23c747efc9 100644 --- a/spec/unit/knife/role_create_spec.rb +++ b/spec/unit/knife/role_create_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleCreate do before(:each) do diff --git a/spec/unit/knife/role_delete_spec.rb b/spec/unit/knife/role_delete_spec.rb index b1a0d90410..6d7d0d964e 100644 --- a/spec/unit/knife/role_delete_spec.rb +++ b/spec/unit/knife/role_delete_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleDelete do before(:each) do diff --git a/spec/unit/knife/role_edit_spec.rb b/spec/unit/knife/role_edit_spec.rb index 0975c6458d..8026d8a21d 100644 --- a/spec/unit/knife/role_edit_spec.rb +++ b/spec/unit/knife/role_edit_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleEdit do before(:each) do diff --git a/spec/unit/knife/role_env_run_list_add_spec.rb b/spec/unit/knife/role_env_run_list_add_spec.rb index f286d5fd0d..743aa55d9d 100644 --- a/spec/unit/knife/role_env_run_list_add_spec.rb +++ b/spec/unit/knife/role_env_run_list_add_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleEnvRunListAdd do before(:each) do @@ -48,7 +48,7 @@ describe Chef::Knife::RoleEnvRunListAdd do it "should have a QA environment" do @knife.run - expect(@role.active_run_list_for('QA')).to eq('QA') + expect(@role.active_run_list_for("QA")).to eq("QA") end it "should load the role named will" do @@ -58,7 +58,7 @@ describe Chef::Knife::RoleEnvRunListAdd do it "should be able to add an environment specific run list" do @knife.run - expect(@role.run_list_for('QA')[0]).to eq('role[monkey]') + expect(@role.run_list_for("QA")[0]).to eq("role[monkey]") end it "should save the role" do diff --git a/spec/unit/knife/role_env_run_list_clear_spec.rb b/spec/unit/knife/role_env_run_list_clear_spec.rb index 525376c358..6a5157d5d4 100644 --- a/spec/unit/knife/role_env_run_list_clear_spec.rb +++ b/spec/unit/knife/role_env_run_list_clear_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleEnvRunListClear do before(:each) do @@ -60,7 +60,7 @@ describe Chef::Knife::RoleEnvRunListClear do it "should remove the item from the run list" do @setup.run @knife.run - expect(@role.run_list_for('QA')[0]).to be_nil + expect(@role.run_list_for("QA")[0]).to be_nil expect(@role.run_list[0]).to be_nil end @@ -82,15 +82,15 @@ describe Chef::Knife::RoleEnvRunListClear do @setup.run @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] @setup.run - @knife.name_args = [ 'will', 'QA' ] + @knife.name_args = [ "will", "QA" ] @knife.run - expect(@role.run_list_for('QA')[0]).to be_nil - expect(@role.run_list_for('PRD')[0]).to eq('recipe[orange::chicken]') - expect(@role.run_list_for('PRD')[1]).to eq('role[monkey]') - expect(@role.run_list_for('PRD')[2]).to eq('recipe[duck::type]') - expect(@role.run_list_for('PRD')[3]).to eq('role[person]') - expect(@role.run_list_for('PRD')[4]).to eq('role[bird]') - expect(@role.run_list_for('PRD')[5]).to eq('role[town]') + expect(@role.run_list_for("QA")[0]).to be_nil + expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") + expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") + expect(@role.run_list_for("PRD")[3]).to eq("role[person]") + expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") + expect(@role.run_list_for("PRD")[5]).to eq("role[town]") end end end diff --git a/spec/unit/knife/role_env_run_list_remove_spec.rb b/spec/unit/knife/role_env_run_list_remove_spec.rb index a15d0af691..329ac2aff0 100644 --- a/spec/unit/knife/role_env_run_list_remove_spec.rb +++ b/spec/unit/knife/role_env_run_list_remove_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleEnvRunListRemove do before(:each) do @@ -60,8 +60,8 @@ describe Chef::Knife::RoleEnvRunListRemove do it "should remove the item from the run list" do @setup.run @knife.run - expect(@role.run_list_for('QA')[0]).not_to eq('role[monkey]') - expect(@role.run_list_for('QA')[0]).to eq('role[person]') + expect(@role.run_list_for("QA")[0]).not_to eq("role[monkey]") + expect(@role.run_list_for("QA")[0]).to eq("role[person]") expect(@role.run_list[0]).to be_nil end @@ -83,22 +83,22 @@ describe Chef::Knife::RoleEnvRunListRemove do @setup.run @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] @setup.run - @knife.name_args = [ 'will', 'QA', 'role[monkey]' ] + @knife.name_args = [ "will", "QA", "role[monkey]" ] @knife.run - @knife.name_args = [ 'will', 'QA', 'recipe[duck::type]' ] + @knife.name_args = [ "will", "QA", "recipe[duck::type]" ] @knife.run - expect(@role.run_list_for('QA')).not_to include('role[monkey]') - expect(@role.run_list_for('QA')).not_to include('recipe[duck::type]') - expect(@role.run_list_for('QA')[0]).to eq('recipe[orange::chicken]') - expect(@role.run_list_for('QA')[1]).to eq('role[person]') - expect(@role.run_list_for('QA')[2]).to eq('role[bird]') - expect(@role.run_list_for('QA')[3]).to eq('role[town]') - expect(@role.run_list_for('PRD')[0]).to eq('recipe[orange::chicken]') - expect(@role.run_list_for('PRD')[1]).to eq('role[monkey]') - expect(@role.run_list_for('PRD')[2]).to eq('recipe[duck::type]') - expect(@role.run_list_for('PRD')[3]).to eq('role[person]') - expect(@role.run_list_for('PRD')[4]).to eq('role[bird]') - expect(@role.run_list_for('PRD')[5]).to eq('role[town]') + expect(@role.run_list_for("QA")).not_to include("role[monkey]") + expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]") + expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("QA")[1]).to eq("role[person]") + expect(@role.run_list_for("QA")[2]).to eq("role[bird]") + expect(@role.run_list_for("QA")[3]).to eq("role[town]") + expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") + expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") + expect(@role.run_list_for("PRD")[3]).to eq("role[person]") + expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") + expect(@role.run_list_for("PRD")[5]).to eq("role[town]") end end end diff --git a/spec/unit/knife/role_env_run_list_replace_spec.rb b/spec/unit/knife/role_env_run_list_replace_spec.rb index ea48601b8d..bb7b79e3f0 100644 --- a/spec/unit/knife/role_env_run_list_replace_spec.rb +++ b/spec/unit/knife/role_env_run_list_replace_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleEnvRunListReplace do before(:each) do @@ -60,8 +60,8 @@ describe Chef::Knife::RoleEnvRunListReplace do it "should remove the item from the run list" do @setup.run @knife.run - expect(@role.run_list_for('QA')[1]).not_to eq('role[dude]') - expect(@role.run_list_for('QA')[1]).to eq('role[person]') + expect(@role.run_list_for("QA")[1]).not_to eq("role[dude]") + expect(@role.run_list_for("QA")[1]).to eq("role[person]") expect(@role.run_list[0]).to be_nil end @@ -83,24 +83,24 @@ describe Chef::Knife::RoleEnvRunListReplace do @setup.run @setup.name_args = [ "will", "PRD", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] @setup.run - @knife.name_args = [ 'will', 'QA', 'role[monkey]', 'role[gibbon]' ] + @knife.name_args = [ "will", "QA", "role[monkey]", "role[gibbon]" ] @knife.run - @knife.name_args = [ 'will', 'QA', 'recipe[duck::type]', 'recipe[duck::mallard]' ] + @knife.name_args = [ "will", "QA", "recipe[duck::type]", "recipe[duck::mallard]" ] @knife.run - expect(@role.run_list_for('QA')).not_to include('role[monkey]') - expect(@role.run_list_for('QA')).not_to include('recipe[duck::type]') - expect(@role.run_list_for('QA')[0]).to eq('recipe[orange::chicken]') - expect(@role.run_list_for('QA')[1]).to eq('role[gibbon]') - expect(@role.run_list_for('QA')[2]).to eq('recipe[duck::mallard]') - expect(@role.run_list_for('QA')[3]).to eq('role[person]') - expect(@role.run_list_for('QA')[4]).to eq('role[bird]') - expect(@role.run_list_for('QA')[5]).to eq('role[town]') - expect(@role.run_list_for('PRD')[0]).to eq('recipe[orange::chicken]') - expect(@role.run_list_for('PRD')[1]).to eq('role[monkey]') - expect(@role.run_list_for('PRD')[2]).to eq('recipe[duck::type]') - expect(@role.run_list_for('PRD')[3]).to eq('role[person]') - expect(@role.run_list_for('PRD')[4]).to eq('role[bird]') - expect(@role.run_list_for('PRD')[5]).to eq('role[town]') + expect(@role.run_list_for("QA")).not_to include("role[monkey]") + expect(@role.run_list_for("QA")).not_to include("recipe[duck::type]") + expect(@role.run_list_for("QA")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("QA")[1]).to eq("role[gibbon]") + expect(@role.run_list_for("QA")[2]).to eq("recipe[duck::mallard]") + expect(@role.run_list_for("QA")[3]).to eq("role[person]") + expect(@role.run_list_for("QA")[4]).to eq("role[bird]") + expect(@role.run_list_for("QA")[5]).to eq("role[town]") + expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") + expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") + expect(@role.run_list_for("PRD")[3]).to eq("role[person]") + expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") + expect(@role.run_list_for("PRD")[5]).to eq("role[town]") expect(@role.run_list[0]).to be_nil end end diff --git a/spec/unit/knife/role_env_run_list_set_spec.rb b/spec/unit/knife/role_env_run_list_set_spec.rb index f3abb86fcf..0932b07ffd 100644 --- a/spec/unit/knife/role_env_run_list_set_spec.rb +++ b/spec/unit/knife/role_env_run_list_set_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleEnvRunListSet do before(:each) do @@ -60,9 +60,9 @@ describe Chef::Knife::RoleEnvRunListSet do it "should replace all the items in the runlist with what is specified" do @setup.run @knife.run - expect(@role.run_list_for('QA')[0]).to eq("role[owen]") - expect(@role.run_list_for('QA')[1]).to eq("role[mauntel]") - expect(@role.run_list_for('QA')[2]).to be_nil + expect(@role.run_list_for("QA")[0]).to eq("role[owen]") + expect(@role.run_list_for("QA")[1]).to eq("role[mauntel]") + expect(@role.run_list_for("QA")[2]).to be_nil expect(@role.run_list[0]).to be_nil end @@ -86,15 +86,15 @@ describe Chef::Knife::RoleEnvRunListSet do @setup.run @knife.name_args = [ "will", "QA", "role[coke]", "role[pepsi]" ] @knife.run - expect(@role.run_list_for('QA')[0]).to eq("role[coke]") - expect(@role.run_list_for('QA')[1]).to eq("role[pepsi]") - expect(@role.run_list_for('QA')[2]).to be_nil - expect(@role.run_list_for('PRD')[0]).to eq('recipe[orange::chicken]') - expect(@role.run_list_for('PRD')[1]).to eq('role[monkey]') - expect(@role.run_list_for('PRD')[2]).to eq('recipe[duck::type]') - expect(@role.run_list_for('PRD')[3]).to eq('role[person]') - expect(@role.run_list_for('PRD')[4]).to eq('role[bird]') - expect(@role.run_list_for('PRD')[5]).to eq('role[town]') + expect(@role.run_list_for("QA")[0]).to eq("role[coke]") + expect(@role.run_list_for("QA")[1]).to eq("role[pepsi]") + expect(@role.run_list_for("QA")[2]).to be_nil + expect(@role.run_list_for("PRD")[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list_for("PRD")[1]).to eq("role[monkey]") + expect(@role.run_list_for("PRD")[2]).to eq("recipe[duck::type]") + expect(@role.run_list_for("PRD")[3]).to eq("role[person]") + expect(@role.run_list_for("PRD")[4]).to eq("role[bird]") + expect(@role.run_list_for("PRD")[5]).to eq("role[town]") expect(@role.run_list[0]).to be_nil end end diff --git a/spec/unit/knife/role_from_file_spec.rb b/spec/unit/knife/role_from_file_spec.rb index 9379f08de3..b08d4bfc59 100644 --- a/spec/unit/knife/role_from_file_spec.rb +++ b/spec/unit/knife/role_from_file_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::RoleFromFile.load_deps @@ -39,7 +39,7 @@ describe Chef::Knife::RoleFromFile do describe "run" do it "should load from a file" do - expect(@knife.loader).to receive(:load_from).with('roles', 'adam.rb').and_return(@role) + expect(@knife.loader).to receive(:load_from).with("roles", "adam.rb").and_return(@role) @knife.run end @@ -60,8 +60,8 @@ describe Chef::Knife::RoleFromFile do describe "run with multiple arguments" do it "should load each file" do @knife.name_args = [ "adam.rb", "caleb.rb" ] - expect(@knife.loader).to receive(:load_from).with('roles', 'adam.rb').and_return(@role) - expect(@knife.loader).to receive(:load_from).with('roles', 'caleb.rb').and_return(@role) + expect(@knife.loader).to receive(:load_from).with("roles", "adam.rb").and_return(@role) + expect(@knife.loader).to receive(:load_from).with("roles", "caleb.rb").and_return(@role) @knife.run end end diff --git a/spec/unit/knife/role_list_spec.rb b/spec/unit/knife/role_list_spec.rb index 65c4f94ff2..0cb4e08337 100644 --- a/spec/unit/knife/role_list_spec.rb +++ b/spec/unit/knife/role_list_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleList do before(:each) do diff --git a/spec/unit/knife/role_run_list_add_spec.rb b/spec/unit/knife/role_run_list_add_spec.rb index d61c114912..425dd0a9a1 100644 --- a/spec/unit/knife/role_run_list_add_spec.rb +++ b/spec/unit/knife/role_run_list_add_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleRunListAdd do before(:each) do diff --git a/spec/unit/knife/role_run_list_clear_spec.rb b/spec/unit/knife/role_run_list_clear_spec.rb index e5a6e18673..42980467e2 100644 --- a/spec/unit/knife/role_run_list_clear_spec.rb +++ b/spec/unit/knife/role_run_list_clear_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleRunListClear do before(:each) do @@ -78,7 +78,7 @@ describe Chef::Knife::RoleRunListClear do it "should remove the items from the run list" do @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] @setup.run - @knife.name_args = [ 'will' ] + @knife.name_args = [ "will" ] @knife.run expect(@role.run_list[0]).to be_nil end diff --git a/spec/unit/knife/role_run_list_remove_spec.rb b/spec/unit/knife/role_run_list_remove_spec.rb index 0f4adf253b..5c3da5c3f7 100644 --- a/spec/unit/knife/role_run_list_remove_spec.rb +++ b/spec/unit/knife/role_run_list_remove_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleRunListRemove do before(:each) do @@ -59,7 +59,7 @@ describe Chef::Knife::RoleRunListRemove do it "should remove the item from the run list" do @setup.run @knife.run - expect(@role.run_list[0]).to eq('role[person]') + expect(@role.run_list[0]).to eq("role[person]") expect(@role.run_list[1]).to be_nil end @@ -79,16 +79,16 @@ describe Chef::Knife::RoleRunListRemove do it "should remove the items from the run list" do @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] @setup.run - @knife.name_args = [ 'will', 'role[monkey]' ] + @knife.name_args = [ "will", "role[monkey]" ] @knife.run - @knife.name_args = [ 'will', 'recipe[duck::type]' ] + @knife.name_args = [ "will", "recipe[duck::type]" ] @knife.run - expect(@role.run_list).not_to include('role[monkey]') - expect(@role.run_list).not_to include('recipe[duck::type]') - expect(@role.run_list[0]).to eq('recipe[orange::chicken]') - expect(@role.run_list[1]).to eq('role[person]') - expect(@role.run_list[2]).to eq('role[bird]') - expect(@role.run_list[3]).to eq('role[town]') + expect(@role.run_list).not_to include("role[monkey]") + expect(@role.run_list).not_to include("recipe[duck::type]") + expect(@role.run_list[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list[1]).to eq("role[person]") + expect(@role.run_list[2]).to eq("role[bird]") + expect(@role.run_list[3]).to eq("role[town]") end end end diff --git a/spec/unit/knife/role_run_list_replace_spec.rb b/spec/unit/knife/role_run_list_replace_spec.rb index 2ff38f573c..44fb3caabc 100644 --- a/spec/unit/knife/role_run_list_replace_spec.rb +++ b/spec/unit/knife/role_run_list_replace_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleRunListReplace do before(:each) do @@ -59,10 +59,10 @@ describe Chef::Knife::RoleRunListReplace do it "should remove the item from the run list" do @setup.run @knife.run - expect(@role.run_list[0]).to eq('role[monkey]') - expect(@role.run_list[1]).not_to eq('role[dude]') - expect(@role.run_list[1]).to eq('role[person]') - expect(@role.run_list[2]).to eq('role[fixer]') + expect(@role.run_list[0]).to eq("role[monkey]") + expect(@role.run_list[1]).not_to eq("role[dude]") + expect(@role.run_list[1]).to eq("role[person]") + expect(@role.run_list[2]).to eq("role[fixer]") expect(@role.run_list[3]).to be_nil end @@ -82,18 +82,18 @@ describe Chef::Knife::RoleRunListReplace do it "should replace the items from the run list" do @setup.name_args = [ "will", "recipe[orange::chicken]", "role[monkey]", "recipe[duck::type]", "role[person]", "role[bird]", "role[town]" ] @setup.run - @knife.name_args = [ 'will', 'role[monkey]', 'role[gibbon]' ] + @knife.name_args = [ "will", "role[monkey]", "role[gibbon]" ] @knife.run - @knife.name_args = [ 'will', 'recipe[duck::type]', 'recipe[duck::mallard]' ] + @knife.name_args = [ "will", "recipe[duck::type]", "recipe[duck::mallard]" ] @knife.run - expect(@role.run_list).not_to include('role[monkey]') - expect(@role.run_list).not_to include('recipe[duck::type]') - expect(@role.run_list[0]).to eq('recipe[orange::chicken]') - expect(@role.run_list[1]).to eq('role[gibbon]') - expect(@role.run_list[2]).to eq('recipe[duck::mallard]') - expect(@role.run_list[3]).to eq('role[person]') - expect(@role.run_list[4]).to eq('role[bird]') - expect(@role.run_list[5]).to eq('role[town]') + expect(@role.run_list).not_to include("role[monkey]") + expect(@role.run_list).not_to include("recipe[duck::type]") + expect(@role.run_list[0]).to eq("recipe[orange::chicken]") + expect(@role.run_list[1]).to eq("role[gibbon]") + expect(@role.run_list[2]).to eq("recipe[duck::mallard]") + expect(@role.run_list[3]).to eq("role[person]") + expect(@role.run_list[4]).to eq("role[bird]") + expect(@role.run_list[5]).to eq("role[town]") expect(@role.run_list[6]).to be_nil end end diff --git a/spec/unit/knife/role_run_list_set_spec.rb b/spec/unit/knife/role_run_list_set_spec.rb index 1350741f10..73d42cf2a2 100644 --- a/spec/unit/knife/role_run_list_set_spec.rb +++ b/spec/unit/knife/role_run_list_set_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleRunListSet do before(:each) do diff --git a/spec/unit/knife/role_show_spec.rb b/spec/unit/knife/role_show_spec.rb index b086136186..2b5b0eec18 100644 --- a/spec/unit/knife/role_show_spec.rb +++ b/spec/unit/knife/role_show_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::RoleShow do - let(:role) { 'base' } + let(:role) { "base" } let(:knife) do knife = Chef::Knife::RoleShow.new @@ -27,21 +27,21 @@ describe Chef::Knife::RoleShow do knife end - let(:role_mock) { double('role_mock') } + let(:role_mock) { double("role_mock") } - describe 'run' do - it 'should list the role' do - expect(Chef::Role).to receive(:load).with('base').and_return(role_mock) + describe "run" do + it "should list the role" do + expect(Chef::Role).to receive(:load).with("base").and_return(role_mock) expect(knife).to receive(:format_for_display).with(role_mock) knife.run end - it 'should pretty print json' do - knife.config[:format] = 'json' + it "should pretty print json" do + knife.config[:format] = "json" stdout = StringIO.new allow(knife.ui).to receive(:stdout).and_return(stdout) fake_role_contents = {"foo"=>"bar", "baz"=>"qux"} - expect(Chef::Role).to receive(:load).with('base').and_return(fake_role_contents) + expect(Chef::Role).to receive(:load).with("base").and_return(fake_role_contents) knife.run expect(stdout.string).to eql("{\n \"foo\": \"bar\",\n \"baz\": \"qux\"\n}\n") end @@ -49,7 +49,7 @@ describe Chef::Knife::RoleShow do context "without a role name" do let(:role) { } - it 'should print usage and exit when a role name is not provided' do + it "should print usage and exit when a role name is not provided" do expect(knife).to receive(:show_usage) expect(knife.ui).to receive(:fatal) expect { knife.run }.to raise_error(SystemExit) diff --git a/spec/unit/knife/ssh_spec.rb b/spec/unit/knife/ssh_spec.rb index 197dc4ca77..adaa8829a5 100644 --- a/spec/unit/knife/ssh_spec.rb +++ b/spec/unit/knife/ssh_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'net/ssh' -require 'net/ssh/multi' +require "spec_helper" +require "net/ssh" +require "net/ssh/multi" describe Chef::Knife::Ssh do before(:each) do @@ -54,7 +54,7 @@ describe Chef::Knife::Ssh do @knife.config[:attribute] = "ipaddress" Chef::Config[:knife][:ssh_attribute] = "ipaddress" # this value will be in the config file configure_query([@node_foo, @node_bar]) - expect(@knife).to receive(:session_from_list).with([['10.0.0.1', nil], ['10.0.0.2', nil]]) + expect(@knife).to receive(:session_from_list).with([["10.0.0.1", nil], ["10.0.0.2", nil]]) @knife.configure_session end @@ -62,7 +62,7 @@ describe Chef::Knife::Ssh do Chef::Config[:knife][:ssh_attribute] = "config_file" # this value will be in the config file @knife.config[:attribute] = "ipaddress" # this is the value of the command line via #configure_attribute configure_query([@node_foo, @node_bar]) - expect(@knife).to receive(:session_from_list).with([['10.0.0.1', nil], ['10.0.0.2', nil]]) + expect(@knife).to receive(:session_from_list).with([["10.0.0.1", nil], ["10.0.0.2", nil]]) @knife.configure_session end end @@ -70,8 +70,8 @@ describe Chef::Knife::Ssh do it "searchs for and returns an array of fqdns" do configure_query([@node_foo, @node_bar]) expect(@knife).to receive(:session_from_list).with([ - ['foo.example.org', nil], - ['bar.example.org', nil], + ["foo.example.org", nil], + ["bar.example.org", nil], ]) @knife.configure_session end @@ -86,8 +86,8 @@ describe Chef::Knife::Ssh do it "returns an array of cloud public hostnames" do configure_query([@node_foo, @node_bar]) expect(@knife).to receive(:session_from_list).with([ - ['ec2-10-0-0-1.compute-1.amazonaws.com', nil], - ['ec2-10-0-0-2.compute-1.amazonaws.com', nil], + ["ec2-10-0-0-1.compute-1.amazonaws.com", nil], + ["ec2-10-0-0-2.compute-1.amazonaws.com", nil], ]) @knife.configure_session end @@ -97,15 +97,15 @@ describe Chef::Knife::Ssh do context "when cloud hostnames are available but empty" do before do - @node_foo.automatic_attrs[:cloud][:public_hostname] = '' - @node_bar.automatic_attrs[:cloud][:public_hostname] = '' + @node_foo.automatic_attrs[:cloud][:public_hostname] = "" + @node_bar.automatic_attrs[:cloud][:public_hostname] = "" end it "returns an array of fqdns" do configure_query([@node_foo, @node_bar]) expect(@knife).to receive(:session_from_list).with([ - ['foo.example.org', nil], - ['bar.example.org', nil], + ["foo.example.org", nil], + ["bar.example.org", nil], ]) @knife.configure_session end @@ -143,7 +143,7 @@ describe Chef::Knife::Ssh do it "returns an array of provided values" do @knife.instance_variable_set(:@name_args, ["foo.example.org bar.example.org"]) - expect(@knife).to receive(:session_from_list).with(['foo.example.org', 'bar.example.org']) + expect(@knife).to receive(:session_from_list).with(["foo.example.org", "bar.example.org"]) @knife.configure_session end end @@ -159,7 +159,7 @@ describe Chef::Knife::Ssh do Chef::Config[:knife][:ssh_attribute] = nil @knife.config[:attribute] = nil @node_foo.automatic_attrs[:cloud][:public_hostname] = "ec2-10-0-0-1.compute-1.amazonaws.com" - @node_bar.automatic_attrs[:cloud][:public_hostname] = '' + @node_bar.automatic_attrs[:cloud][:public_hostname] = "" end it "should return fqdn by default" do @@ -190,21 +190,21 @@ describe Chef::Knife::Ssh do before :each do @knife.instance_variable_set(:@longest, 0) ssh_config = {:timeout => 50, :user => "locutus", :port => 23 } - allow(Net::SSH).to receive(:configuration_for).with('the.b.org').and_return(ssh_config) + allow(Net::SSH).to receive(:configuration_for).with("the.b.org").and_return(ssh_config) end it "uses the port from an ssh config file" do - @knife.session_from_list([['the.b.org', nil]]) + @knife.session_from_list([["the.b.org", nil]]) expect(@knife.session.servers[0].port).to eq(23) end it "uses the port from a cloud attr" do - @knife.session_from_list([['the.b.org', 123]]) + @knife.session_from_list([["the.b.org", 123]]) expect(@knife.session.servers[0].port).to eq(123) end it "uses the user from an ssh config file" do - @knife.session_from_list([['the.b.org', 123]]) + @knife.session_from_list([["the.b.org", 123]]) expect(@knife.session.servers[0].user).to eq("locutus") end end @@ -279,7 +279,7 @@ describe Chef::Knife::Ssh do expect(@query).to receive(:search).and_return([[@node_foo]]) allow(Chef::Search::Query).to receive(:new).and_return(@query) allow(@knife).to receive(:ssh_command).and_return(exit_code) - @knife.name_args = ['*:*', 'false'] + @knife.name_args = ["*:*", "false"] end context "with an error" do diff --git a/spec/unit/knife/ssl_check_spec.rb b/spec/unit/knife/ssl_check_spec.rb index feeb85c8af..5fe1b18cb7 100644 --- a/spec/unit/knife/ssl_check_spec.rb +++ b/spec/unit/knife/ssl_check_spec.rb @@ -17,7 +17,7 @@ # require "spec_helper" -require 'stringio' +require "stringio" describe Chef::Knife::SslCheck do diff --git a/spec/unit/knife/ssl_fetch_spec.rb b/spec/unit/knife/ssl_fetch_spec.rb index 5982ed9470..be098e4834 100644 --- a/spec/unit/knife/ssl_fetch_spec.rb +++ b/spec/unit/knife/ssl_fetch_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/knife/ssl_fetch' +require "spec_helper" +require "chef/knife/ssl_fetch" describe Chef::Knife::SslFetch do diff --git a/spec/unit/knife/status_spec.rb b/spec/unit/knife/status_spec.rb index 11728a6f9b..c2866dc0f6 100644 --- a/spec/unit/knife/status_spec.rb +++ b/spec/unit/knife/status_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::Status do before(:each) do diff --git a/spec/unit/knife/tag_create_spec.rb b/spec/unit/knife/tag_create_spec.rb index 586ec118bd..6a3ced3f5b 100644 --- a/spec/unit/knife/tag_create_spec.rb +++ b/spec/unit/knife/tag_create_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Chef::Knife::TagCreate do before(:each) do diff --git a/spec/unit/knife/tag_delete_spec.rb b/spec/unit/knife/tag_delete_spec.rb index e7fa108947..3095eda191 100644 --- a/spec/unit/knife/tag_delete_spec.rb +++ b/spec/unit/knife/tag_delete_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Chef::Knife::TagDelete do before(:each) do diff --git a/spec/unit/knife/tag_list_spec.rb b/spec/unit/knife/tag_list_spec.rb index 9c71d22f06..97cd8e7efa 100644 --- a/spec/unit/knife/tag_list_spec.rb +++ b/spec/unit/knife/tag_list_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe Chef::Knife::TagList do before(:each) do diff --git a/spec/unit/knife/user_create_spec.rb b/spec/unit/knife/user_create_spec.rb index fa5c8324b4..e05d518c1a 100644 --- a/spec/unit/knife/user_create_spec.rb +++ b/spec/unit/knife/user_create_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" Chef::Knife::UserCreate.load_deps @@ -41,7 +41,7 @@ describe Chef::Knife::UserCreate do # delete this once OSC11 support is gone context "when only one name_arg is passed" do before do - knife.name_args = ['some_user'] + knife.name_args = ["some_user"] allow(knife).to receive(:run_osc_11_user_create).and_raise(SystemExit) end @@ -61,7 +61,7 @@ describe Chef::Knife::UserCreate do # from spec/support/shared/unit/knife_shared.rb it_should_behave_like "mandatory field missing" do let(:name_args) { [] } - let(:fieldname) { 'username' } + let(:fieldname) { "username" } end end @@ -79,38 +79,38 @@ describe Chef::Knife::UserCreate do context "when FIRST_NAME isn't specified" do # from spec/support/shared/unit/knife_shared.rb it_should_behave_like "mandatory field missing" do - let(:name_args) { ['some_user', 'some_display_name'] } - let(:fieldname) { 'first name' } + let(:name_args) { ["some_user", "some_display_name"] } + let(:fieldname) { "first name" } end end context "when LAST_NAME isn't specified" do # from spec/support/shared/unit/knife_shared.rb it_should_behave_like "mandatory field missing" do - let(:name_args) { ['some_user', 'some_display_name', 'some_first_name'] } - let(:fieldname) { 'last name' } + let(:name_args) { ["some_user", "some_display_name", "some_first_name"] } + let(:fieldname) { "last name" } end end context "when EMAIL isn't specified" do # from spec/support/shared/unit/knife_shared.rb it_should_behave_like "mandatory field missing" do - let(:name_args) { ['some_user', 'some_display_name', 'some_first_name', 'some_last_name'] } - let(:fieldname) { 'email' } + let(:name_args) { ["some_user", "some_display_name", "some_first_name", "some_last_name"] } + let(:fieldname) { "email" } end end context "when PASSWORD isn't specified" do # from spec/support/shared/unit/knife_shared.rb it_should_behave_like "mandatory field missing" do - let(:name_args) { ['some_user', 'some_display_name', 'some_first_name', 'some_last_name', 'some_email'] } - let(:fieldname) { 'password' } + let(:name_args) { ["some_user", "some_display_name", "some_first_name", "some_last_name", "some_email"] } + let(:fieldname) { "password" } end end context "when all mandatory fields are validly specified" do before do - knife.name_args = ['some_user', 'some_display_name', 'some_first_name', 'some_last_name', 'some_email', 'some_password'] + knife.name_args = ["some_user", "some_display_name", "some_first_name", "some_last_name", "some_email", "some_password"] allow(knife).to receive(:edit_data).and_return(knife.user.to_hash) allow(knife).to receive(:create_user_from_hash).and_return(knife.user) end @@ -122,12 +122,12 @@ describe Chef::Knife::UserCreate do it "sets all the mandatory fields" do knife.run - expect(knife.user.username).to eq('some_user') - expect(knife.user.display_name).to eq('some_display_name') - expect(knife.user.first_name).to eq('some_first_name') - expect(knife.user.last_name).to eq('some_last_name') - expect(knife.user.email).to eq('some_email') - expect(knife.user.password).to eq('some_password') + expect(knife.user.username).to eq("some_user") + expect(knife.user.display_name).to eq("some_display_name") + expect(knife.user.first_name).to eq("some_first_name") + expect(knife.user.last_name).to eq("some_last_name") + expect(knife.user.email).to eq("some_email") + expect(knife.user.password).to eq("some_password") end context "when user_key and prevent_keygen are passed" do @@ -166,14 +166,14 @@ describe Chef::Knife::UserCreate do context "when --user-key is passed" do before do - knife.config[:user_key] = 'some_key' - allow(File).to receive(:read).and_return('some_key') + knife.config[:user_key] = "some_key" + allow(File).to receive(:read).and_return("some_key") allow(File).to receive(:expand_path) end it "sets user.public_key" do knife.run - expect(knife.user.public_key).to eq('some_key') + expect(knife.user.public_key).to eq("some_key") end end @@ -191,20 +191,20 @@ describe Chef::Knife::UserCreate do context "when --file is passed" do before do - knife.config[:file] = '/some/path' + knife.config[:file] = "/some/path" end it "creates a new file of the path passed" do - filehandle = double('filehandle') - expect(filehandle).to receive(:print).with('some_private_key') - expect(File).to receive(:open).with('/some/path', 'w').and_yield(filehandle) + filehandle = double("filehandle") + expect(filehandle).to receive(:print).with("some_private_key") + expect(File).to receive(:open).with("/some/path", "w").and_yield(filehandle) knife.run end end context "when --file is not passed" do it "prints the private key to stdout" do - expect(knife.ui).to receive(:msg).with('some_private_key') + expect(knife.ui).to receive(:msg).with("some_private_key") knife.run end end diff --git a/spec/unit/knife/user_delete_spec.rb b/spec/unit/knife/user_delete_spec.rb index a24160624a..f2f8b1537d 100644 --- a/spec/unit/knife/user_delete_spec.rb +++ b/spec/unit/knife/user_delete_spec.rb @@ -16,18 +16,18 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::UserDelete do let(:knife) { Chef::Knife::UserDelete.new } - let(:user) { double('user_object') } + let(:user) { double("user_object") } let(:stdout) { StringIO.new } before(:each) do Chef::Knife::UserDelete.load_deps - knife.name_args = [ 'my_user' ] + knife.name_args = [ "my_user" ] allow(Chef::UserV1).to receive(:load).and_return(user) - allow(user).to receive(:username).and_return('my_user') + allow(user).to receive(:username).and_return("my_user") allow(knife.ui).to receive(:stderr).and_return(stdout) allow(knife.ui).to receive(:stdout).and_return(stdout) end @@ -50,13 +50,13 @@ describe Chef::Knife::UserDelete do end end - it 'deletes the user' do + it "deletes the user" do #expect(knife).to receive(:delete_object).with(Chef::UserV1, 'my_user') - expect(knife).to receive(:delete_object).with('my_user') + expect(knife).to receive(:delete_object).with("my_user") knife.run end - it 'prints usage and exits when a user name is not provided' do + it "prints usage and exits when a user name is not provided" do knife.name_args = [] expect(knife).to receive(:show_usage) expect(knife.ui).to receive(:fatal) diff --git a/spec/unit/knife/user_edit_spec.rb b/spec/unit/knife/user_edit_spec.rb index a21d982d29..072a27be01 100644 --- a/spec/unit/knife/user_edit_spec.rb +++ b/spec/unit/knife/user_edit_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::UserEdit do let(:knife) { Chef::Knife::UserEdit.new } @@ -28,7 +28,7 @@ describe Chef::Knife::UserEdit do Chef::Knife::UserEdit.load_deps allow(knife.ui).to receive(:stderr).and_return(@stderr) allow(knife.ui).to receive(:stdout).and_return(@stdout) - knife.name_args = [ 'my_user' ] + knife.name_args = [ "my_user" ] knife.config[:disable_editing] = true end @@ -50,14 +50,14 @@ describe Chef::Knife::UserEdit do end end - it 'loads and edits the user' do + it "loads and edits the user" do data = { "username" => "my_user" } allow(Chef::UserV1).to receive(:load).with("my_user").and_return(data) expect(knife).to receive(:edit_data).with(data).and_return(data) knife.run end - it 'prints usage and exits when a user name is not provided' do + it "prints usage and exits when a user name is not provided" do knife.name_args = [] expect(knife).to receive(:show_usage) expect(knife.ui).to receive(:fatal) diff --git a/spec/unit/knife/user_list_spec.rb b/spec/unit/knife/user_list_spec.rb index fa2bac426e..753929e250 100644 --- a/spec/unit/knife/user_list_spec.rb +++ b/spec/unit/knife/user_list_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::UserList do let(:knife) { Chef::Knife::UserList.new } @@ -28,7 +28,7 @@ describe Chef::Knife::UserList do allow(knife.ui).to receive(:stdout).and_return(stdout) end - it 'lists the users' do + it "lists the users" do expect(Chef::UserV1).to receive(:list) expect(knife).to receive(:format_list_for_display) knife.run diff --git a/spec/unit/knife/user_reregister_spec.rb b/spec/unit/knife/user_reregister_spec.rb index 89aa6726cd..1907b5fa50 100644 --- a/spec/unit/knife/user_reregister_spec.rb +++ b/spec/unit/knife/user_reregister_spec.rb @@ -16,20 +16,20 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::UserReregister do let(:knife) { Chef::Knife::UserReregister.new } - let(:user_mock) { double('user_mock', :private_key => "private_key") } + let(:user_mock) { double("user_mock", :private_key => "private_key") } let(:stdout) { StringIO.new } before do Chef::Knife::UserReregister.load_deps - knife.name_args = [ 'a_user' ] + knife.name_args = [ "a_user" ] allow(Chef::UserV1).to receive(:load).and_return(user_mock) allow(knife.ui).to receive(:stdout).and_return(stdout) allow(knife.ui).to receive(:stderr).and_return(stdout) - allow(user_mock).to receive(:username).and_return('a_user') + allow(user_mock).to receive(:username).and_return("a_user") end # delete this once OSC11 support is gone @@ -50,24 +50,24 @@ describe Chef::Knife::UserReregister do end end - it 'prints usage and exits when a user name is not provided' do + it "prints usage and exits when a user name is not provided" do knife.name_args = [] expect(knife).to receive(:show_usage) expect(knife.ui).to receive(:fatal) expect { knife.run }.to raise_error(SystemExit) end - it 'reregisters the user and prints the key' do + it "reregisters the user and prints the key" do expect(user_mock).to receive(:reregister).and_return(user_mock) knife.run expect(stdout.string).to match( /private_key/ ) end - it 'writes the private key to a file when --file is specified' do + it "writes the private key to a file when --file is specified" do expect(user_mock).to receive(:reregister).and_return(user_mock) - knife.config[:file] = '/tmp/a_file' + knife.config[:file] = "/tmp/a_file" filehandle = StringIO.new - expect(File).to receive(:open).with('/tmp/a_file', 'w').and_yield(filehandle) + expect(File).to receive(:open).with("/tmp/a_file", "w").and_yield(filehandle) knife.run expect(filehandle.string).to eq("private_key") end diff --git a/spec/unit/knife/user_show_spec.rb b/spec/unit/knife/user_show_spec.rb index 7c39e428c0..12e8424af2 100644 --- a/spec/unit/knife/user_show_spec.rb +++ b/spec/unit/knife/user_show_spec.rb @@ -16,17 +16,17 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Knife::UserShow do let(:knife) { Chef::Knife::UserShow.new } - let(:user_mock) { double('user_mock') } + let(:user_mock) { double("user_mock") } let(:stdout) { StringIO.new } before do Chef::Knife::UserShow.load_deps - knife.name_args = [ 'my_user' ] - allow(user_mock).to receive(:username).and_return('my_user') + knife.name_args = [ "my_user" ] + allow(user_mock).to receive(:username).and_return("my_user") allow(knife.ui).to receive(:stderr).and_return(stdout) allow(knife.ui).to receive(:stdout).and_return(stdout) end @@ -35,7 +35,7 @@ describe Chef::Knife::UserShow do context "when the username field is not supported by the server" do before do allow(knife).to receive(:run_osc_11_user_show).and_raise(SystemExit) - allow(Chef::UserV1).to receive(:load).with('my_user').and_return(user_mock) + allow(Chef::UserV1).to receive(:load).with("my_user").and_return(user_mock) allow(user_mock).to receive(:username).and_return(nil) end @@ -50,13 +50,13 @@ describe Chef::Knife::UserShow do end end - it 'loads and displays the user' do - expect(Chef::UserV1).to receive(:load).with('my_user').and_return(user_mock) + it "loads and displays the user" do + expect(Chef::UserV1).to receive(:load).with("my_user").and_return(user_mock) expect(knife).to receive(:format_for_display).with(user_mock) knife.run end - it 'prints usage and exits when a user name is not provided' do + it "prints usage and exits when a user name is not provided" do knife.name_args = [] expect(knife).to receive(:show_usage) expect(knife.ui).to receive(:fatal) diff --git a/spec/unit/knife_spec.rb b/spec/unit/knife_spec.rb index 55b4f5c88a..06892af905 100644 --- a/spec/unit/knife_spec.rb +++ b/spec/unit/knife_spec.rb @@ -21,8 +21,8 @@ module KnifeSpecs end -require 'spec_helper' -require 'uri' +require "spec_helper" +require "uri" describe Chef::Knife do @@ -81,28 +81,28 @@ describe Chef::Knife do KnifeSpecs.send(:remove_const, :TestExplicitCategory) end - Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_name_mapping.rb')) - Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_explicit_category.rb')) + Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_name_mapping.rb")) + Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_explicit_category.rb")) end it "has a category based on its name" do - expect(KnifeSpecs::TestNameMapping.subcommand_category).to eq('test') + expect(KnifeSpecs::TestNameMapping.subcommand_category).to eq("test") end it "has an explicitly defined category if set" do - expect(KnifeSpecs::TestExplicitCategory.subcommand_category).to eq('cookbook site') + expect(KnifeSpecs::TestExplicitCategory.subcommand_category).to eq("cookbook site") end it "can reference the subcommand by its snake cased name" do - expect(Chef::Knife.subcommands['test_name_mapping']).to equal(KnifeSpecs::TestNameMapping) + expect(Chef::Knife.subcommands["test_name_mapping"]).to equal(KnifeSpecs::TestNameMapping) end it "lists subcommands by category" do - expect(Chef::Knife.subcommands_by_category['test']).to include('test_name_mapping') + expect(Chef::Knife.subcommands_by_category["test"]).to include("test_name_mapping") end it "lists subcommands by category when the subcommands have explicit categories" do - expect(Chef::Knife.subcommands_by_category['cookbook site']).to include('test_explicit_category') + expect(Chef::Knife.subcommands_by_category["cookbook site"]).to include("test_explicit_category") end it "has empty dependency_loader list by default" do @@ -137,9 +137,9 @@ describe Chef::Knife do it "guesses a category from a given ARGV" do Chef::Knife.subcommands_by_category["cookbook"] << :cookbook Chef::Knife.subcommands_by_category["cookbook site"] << :cookbook_site - expect(Chef::Knife.guess_category(%w{cookbook foo bar baz})).to eq('cookbook') - expect(Chef::Knife.guess_category(%w{cookbook site foo bar baz})).to eq('cookbook site') - expect(Chef::Knife.guess_category(%w{cookbook site --help})).to eq('cookbook site') + expect(Chef::Knife.guess_category(%w{cookbook foo bar baz})).to eq("cookbook") + expect(Chef::Knife.guess_category(%w{cookbook site foo bar baz})).to eq("cookbook site") + expect(Chef::Knife.guess_category(%w{cookbook site --help})).to eq("cookbook site") end it "finds a subcommand class based on ARGV" do @@ -154,7 +154,7 @@ describe Chef::Knife do let(:headers) {{"Accept"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", - 'X-Chef-Version' => Chef::VERSION, + "X-Chef-Version" => Chef::VERSION, "Host"=>"api.opscode.piab", "X-REMOTE-REQUEST-ID"=>request_id, }} @@ -195,7 +195,7 @@ describe Chef::Knife do if KnifeSpecs.const_defined?(:TestYourself) KnifeSpecs.send :remove_const, :TestYourself end - Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_yourself.rb')) + Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb")) Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.kind_of?(Class) } end @@ -210,7 +210,7 @@ describe Chef::Knife do if KnifeSpecs.const_defined?(:TestYourself) KnifeSpecs.send :remove_const, :TestYourself end - Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_yourself.rb')) + Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb")) Chef::Knife.subcommands.each { |name, klass| Chef::Knife.subcommands.delete(name) unless klass.kind_of?(Class) } end @@ -349,12 +349,12 @@ describe Chef::Knife do before do unless KnifeSpecs.const_defined?(:TestYourself) - Kernel.load(File.join(CHEF_SPEC_DATA, 'knife_subcommand', 'test_yourself.rb')) + Kernel.load(File.join(CHEF_SPEC_DATA, "knife_subcommand", "test_yourself.rb")) end end it "it parses the options passed to it" do - expect(knife.config[:scro]).to eq('scrogramming') + expect(knife.config[:scro]).to eq("scrogramming") end it "extracts its command specific args from the full arg list" do @@ -431,9 +431,9 @@ describe Chef::Knife do allow(knife).to receive(:run).and_raise(Net::HTTPServerException.new("406 Not Acceptable", response)) knife.run_with_pretty_exceptions - expect(stderr.string).to include('The request that Knife sent was using API version 10000000') - expect(stderr.string).to include('The Chef server you sent the request to supports a min API verson of 0 and a max API version of 1') - expect(stderr.string).to include('Please either update your Chef client or server to be a compatible set') + expect(stderr.string).to include("The request that Knife sent was using API version 10000000") + expect(stderr.string).to include("The Chef server you sent the request to supports a min API verson of 0 and a max API version of 1") + expect(stderr.string).to include("Please either update your Chef client or server to be a compatible set") end it "formats 500s nicely" do @@ -485,7 +485,7 @@ describe Chef::Knife do end it "formats missing private key errors nicely" do - allow(knife).to receive(:run).and_raise(Chef::Exceptions::PrivateKeyMissing.new('key not there')) + allow(knife).to receive(:run).and_raise(Chef::Exceptions::PrivateKeyMissing.new("key not there")) allow(knife).to receive(:api_key).and_return("/home/root/.chef/no-key-here.pem") knife.run_with_pretty_exceptions expect(stderr.string).to match(%r[ERROR: Your private key could not be loaded from /home/root/.chef/no-key-here.pem]) @@ -493,7 +493,7 @@ describe Chef::Knife do end it "formats connection refused errors nicely" do - allow(knife).to receive(:run).and_raise(Errno::ECONNREFUSED.new('y u no shut up')) + allow(knife).to receive(:run).and_raise(Errno::ECONNREFUSED.new("y u no shut up")) knife.run_with_pretty_exceptions # Errno::ECONNREFUSED message differs by platform # *nix = Errno::ECONNREFUSED: Connection refused diff --git a/spec/unit/log/syslog_spec.rb b/spec/unit/log/syslog_spec.rb index 3db90e50c6..440b4f018e 100644 --- a/spec/unit/log/syslog_spec.rb +++ b/spec/unit/log/syslog_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef' +require "spec_helper" +require "chef" describe "Chef::Log::Syslog", :unix_only => true do let(:syslog) { Chef::Log::Syslog.new } diff --git a/spec/unit/log/winevt_spec.rb b/spec/unit/log/winevt_spec.rb index 867ef55900..c20aeaf4bf 100644 --- a/spec/unit/log/winevt_spec.rb +++ b/spec/unit/log/winevt_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Log::WinEvt do let(:evtlog) { instance_double("Win32::EventLog")} diff --git a/spec/unit/log_spec.rb b/spec/unit/log_spec.rb index 7be40f77e6..288a827035 100644 --- a/spec/unit/log_spec.rb +++ b/spec/unit/log_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'tempfile' -require 'logger' -require 'spec_helper' +require "tempfile" +require "logger" +require "spec_helper" describe Chef::Log do end diff --git a/spec/unit/lwrp_spec.rb b/spec/unit/lwrp_spec.rb index 13d9f6acc7..8900743c75 100644 --- a/spec/unit/lwrp_spec.rb +++ b/spec/unit/lwrp_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' -require 'tmpdir' -require 'fileutils' -require 'chef/mixin/convert_to_class_name' +require "spec_helper" +require "tmpdir" +require "fileutils" +require "chef/mixin/convert_to_class_name" module LwrpConstScopingConflict end @@ -57,21 +57,21 @@ describe "LWRP" do end it "should not skip loading a resource when there's a top level symbol of the same name" do - Object.const_set('LwrpFoo', Class.new) + Object.const_set("LwrpFoo", Class.new) file = File.expand_path( "lwrp/resources/foo.rb", CHEF_SPEC_DATA) expect(Chef::Log).not_to receive(:info).with(/Skipping/) expect(Chef::Log).not_to receive(:debug).with(/anymore/) Chef::Resource::LWRPBase.build_from_file("lwrp", file, nil) - Object.send(:remove_const, 'LwrpFoo') + Object.send(:remove_const, "LwrpFoo") end it "should not skip loading a provider when there's a top level symbol of the same name" do - Object.const_set('LwrpBuckPasser', Class.new) + Object.const_set("LwrpBuckPasser", Class.new) file = File.expand_path( "lwrp/providers/buck_passer.rb", CHEF_SPEC_DATA) expect(Chef::Log).not_to receive(:info).with(/Skipping/) expect(Chef::Log).not_to receive(:debug).with(/anymore/) Chef::Provider::LWRPBase.build_from_file("lwrp", file, nil) - Object.send(:remove_const, 'LwrpBuckPasser') + Object.send(:remove_const, "LwrpBuckPasser") end # @todo: we need a before block to manually remove_const all of the LWRPs that we @@ -246,19 +246,19 @@ describe "LWRP" do let(:klass) do Class.new(Chef::Resource::LWRPBase) do self.resource_name = :sample_resource - attribute :food, :default => lazy { 'BACON!'*3 } + attribute :food, :default => lazy { "BACON!"*3 } attribute :drink, :default => lazy { |r| "Drink after #{r.food}!"} end end - let(:instance) { klass.new('kitchen') } + let(:instance) { klass.new("kitchen") } it "evaluates the default value when requested" do - expect(instance.food).to eq('BACON!BACON!BACON!') + expect(instance.food).to eq("BACON!BACON!BACON!") end it "evaluates yields self to the block" do - expect(instance.drink).to eq('Drink after BACON!BACON!BACON!!') + expect(instance.drink).to eq("Drink after BACON!BACON!BACON!!") end end end @@ -325,7 +325,7 @@ describe "LWRP" do end def raise_if_deprecated! - if Chef::VERSION.split('.').first.to_i > 12 + if Chef::VERSION.split(".").first.to_i > 12 raise "This test should be removed and the associated code should be removed!" end end @@ -344,7 +344,7 @@ describe "LWRP" do end end let(:resource) do - resource_class.new('blah') + resource_class.new("blah") end it "actions includes those actions" do expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ] @@ -364,7 +364,7 @@ describe "LWRP" do end end let(:resource) do - resource_class.new('blah') + resource_class.new("blah") end it "actions includes those actions" do expect(resource_class.actions).to eq [ :nothing, :eat, :sleep ] @@ -383,7 +383,7 @@ describe "LWRP" do let(:node) do Chef::Node.new.tap do |n| n.automatic[:platform] = :ubuntu - n.automatic[:platform_version] = '8.10' + n.automatic[:platform_version] = "8.10" end end @@ -483,8 +483,8 @@ describe "LWRP" do Chef::Runner.new(run_context).converge expect(run_context.resource_collection[0]).to eql(injector) - expect(run_context.resource_collection[1].name).to eql('prepared_thumbs') - expect(run_context.resource_collection[2].name).to eql('twiddled_thumbs') + expect(run_context.resource_collection[1].name).to eql("prepared_thumbs") + expect(run_context.resource_collection[2].name).to eql("twiddled_thumbs") expect(run_context.resource_collection[3]).to eql(dummy) end @@ -507,12 +507,12 @@ describe "LWRP" do Chef::Runner.new(run_context).converge expect(run_context.resource_collection[0]).to eql(injector) - expect(run_context.resource_collection[1].name).to eql('prepared_thumbs') - expect(run_context.resource_collection[2].name).to eql('twiddled_thumbs') + expect(run_context.resource_collection[1].name).to eql("prepared_thumbs") + expect(run_context.resource_collection[2].name).to eql("twiddled_thumbs") expect(run_context.resource_collection[3]).to eql(dummy) expect(run_context.resource_collection[4]).to eql(injector2) - expect(run_context.resource_collection[5].name).to eql('prepared_eyes') - expect(run_context.resource_collection[6].name).to eql('dried_paint_watched') + expect(run_context.resource_collection[5].name).to eql("prepared_eyes") + expect(run_context.resource_collection[6].name).to eql("dried_paint_watched") end it "should properly handle a new_resource reference" do @@ -535,7 +535,7 @@ describe "LWRP" do #provider = @runner.build_provider(resource) provider.action_twiddle_thumbs - expect(provider.enclosed_resource.monkey).to eq('bob, the monkey') + expect(provider.enclosed_resource.monkey).to eq("bob, the monkey") end describe "when using inline compilation" do @@ -603,7 +603,7 @@ describe "LWRP" do end it "get_lwrp(:lwrp_once).new is a Chef::Resource::LwrpOnce" do - lwrp = get_lwrp(:lwrp_once).new('hi') + lwrp = get_lwrp(:lwrp_once).new("hi") expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy @@ -611,7 +611,7 @@ describe "LWRP" do end it "Chef::Resource::LwrpOnce.new is a get_lwrp(:lwrp_once)" do - lwrp = Chef::Resource::LwrpOnce.new('hi') + lwrp = Chef::Resource::LwrpOnce.new("hi") expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy @@ -639,35 +639,35 @@ describe "LWRP" do end it "subclass.new is a subclass" do - lwrp = subclass.new('hi') + lwrp = subclass.new("hi") expect(lwrp.kind_of?(subclass)).to be_truthy expect(lwrp.is_a?(subclass)).to be_truthy expect(subclass === lwrp).to be_truthy expect(lwrp.class === subclass) end it "subclass.new is a Chef::Resource::LwrpOnce" do - lwrp = subclass.new('hi') + lwrp = subclass.new("hi") expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy expect(Chef::Resource::LwrpOnce === lwrp).to be_truthy expect(lwrp.class === Chef::Resource::LwrpOnce) end it "subclass.new is a get_lwrp(:lwrp_once)" do - lwrp = subclass.new('hi') + lwrp = subclass.new("hi") expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy expect(lwrp.class === get_lwrp(:lwrp_once)) end it "Chef::Resource::LwrpOnce.new is *not* a subclass" do - lwrp = Chef::Resource::LwrpOnce.new('hi') + lwrp = Chef::Resource::LwrpOnce.new("hi") expect(lwrp.kind_of?(subclass)).to be_falsey expect(lwrp.is_a?(subclass)).to be_falsey expect(subclass === lwrp.class).to be_falsey expect(subclass === Chef::Resource::LwrpOnce).to be_falsey end it "get_lwrp(:lwrp_once).new is *not* a subclass" do - lwrp = get_lwrp(:lwrp_once).new('hi') + lwrp = get_lwrp(:lwrp_once).new("hi") expect(lwrp.kind_of?(subclass)).to be_falsey expect(lwrp.is_a?(subclass)).to be_falsey expect(subclass === lwrp.class).to be_falsey @@ -681,35 +681,35 @@ describe "LWRP" do end it "subclass.new is a subclass" do - lwrp = subclass.new('hi') + lwrp = subclass.new("hi") expect(lwrp.kind_of?(subclass)).to be_truthy expect(lwrp.is_a?(subclass)).to be_truthy expect(subclass === lwrp).to be_truthy expect(lwrp.class === subclass) end it "subclass.new is a Chef::Resource::LwrpOnce" do - lwrp = subclass.new('hi') + lwrp = subclass.new("hi") expect(lwrp.kind_of?(Chef::Resource::LwrpOnce)).to be_truthy expect(lwrp.is_a?(Chef::Resource::LwrpOnce)).to be_truthy expect(Chef::Resource::LwrpOnce === lwrp).to be_truthy expect(lwrp.class === Chef::Resource::LwrpOnce) end it "subclass.new is a get_lwrp(:lwrp_once)" do - lwrp = subclass.new('hi') + lwrp = subclass.new("hi") expect(lwrp.kind_of?(get_lwrp(:lwrp_once))).to be_truthy expect(lwrp.is_a?(get_lwrp(:lwrp_once))).to be_truthy expect(get_lwrp(:lwrp_once) === lwrp).to be_truthy expect(lwrp.class === get_lwrp(:lwrp_once)) end it "Chef::Resource::LwrpOnce.new is *not* a subclass" do - lwrp = Chef::Resource::LwrpOnce.new('hi') + lwrp = Chef::Resource::LwrpOnce.new("hi") expect(lwrp.kind_of?(subclass)).to be_falsey expect(lwrp.is_a?(subclass)).to be_falsey expect(subclass === lwrp.class).to be_falsey expect(subclass === Chef::Resource::LwrpOnce).to be_falsey end it "get_lwrp(:lwrp_once).new is *not* a subclass" do - lwrp = get_lwrp(:lwrp_once).new('hi') + lwrp = get_lwrp(:lwrp_once).new("hi") expect(lwrp.kind_of?(subclass)).to be_falsey expect(lwrp.is_a?(subclass)).to be_falsey expect(subclass === lwrp.class).to be_falsey diff --git a/spec/unit/mash_spec.rb b/spec/unit/mash_spec.rb index b8f4c2d5aa..59904816f6 100644 --- a/spec/unit/mash_spec.rb +++ b/spec/unit/mash_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mash' +require "spec_helper" +require "chef/mash" describe Mash do it "should duplicate a simple key/value mash to a new mash" do diff --git a/spec/unit/mixin/api_version_request_handling_spec.rb b/spec/unit/mixin/api_version_request_handling_spec.rb index fc42d76d72..ac1122bbcf 100644 --- a/spec/unit/mixin/api_version_request_handling_spec.rb +++ b/spec/unit/mixin/api_version_request_handling_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Mixin::ApiVersionRequestHandling do let(:dummy_class) { Class.new { include Chef::Mixin::ApiVersionRequestHandling } } @@ -27,7 +27,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do context "when the response code is not 406" do - let(:response) { OpenStruct.new(:code => '405') } + let(:response) { OpenStruct.new(:code => "405") } let(:exception) { Net::HTTPServerException.new("405 Something Else", response) } it "returns nil" do @@ -38,7 +38,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do end # when the response code is not 406 context "when the response code is 406" do - let(:response) { OpenStruct.new(:code => '406') } + let(:response) { OpenStruct.new(:code => "406") } let(:exception) { Net::HTTPServerException.new("406 Not Acceptable", response) } context "when x-ops-server-api-version header does not exist" do @@ -59,7 +59,7 @@ describe Chef::Mixin::ApiVersionRequestHandling do } before(:each) do - allow(response).to receive(:[]).with('x-ops-server-api-version').and_return(Chef::JSONCompat.to_json(return_hash)) + allow(response).to receive(:[]).with("x-ops-server-api-version").and_return(Chef::JSONCompat.to_json(return_hash)) end context "when there is no intersection between client and server versions" do diff --git a/spec/unit/mixin/checksum_spec.rb b/spec/unit/mixin/checksum_spec.rb index 864b15f2bc..080220ec81 100644 --- a/spec/unit/mixin/checksum_spec.rb +++ b/spec/unit/mixin/checksum_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/checksum' -require 'stringio' +require "spec_helper" +require "chef/mixin/checksum" +require "stringio" class Chef::CMCCheck include Chef::Mixin::Checksum diff --git a/spec/unit/mixin/command_spec.rb b/spec/unit/mixin/command_spec.rb index cedabcbe49..8a4bb1acbf 100644 --- a/spec/unit/mixin/command_spec.rb +++ b/spec/unit/mixin/command_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Mixin::Command, :volatile do diff --git a/spec/unit/mixin/convert_to_class_name_spec.rb b/spec/unit/mixin/convert_to_class_name_spec.rb index 4cf6728d64..cf90cf31a0 100644 --- a/spec/unit/mixin/convert_to_class_name_spec.rb +++ b/spec/unit/mixin/convert_to_class_name_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class ConvertToClassTestHarness include Chef::Mixin::ConvertToClassName diff --git a/spec/unit/mixin/deep_merge_spec.rb b/spec/unit/mixin/deep_merge_spec.rb index d107323f32..1212ff2b53 100644 --- a/spec/unit/mixin/deep_merge_spec.rb +++ b/spec/unit/mixin/deep_merge_spec.rb @@ -22,26 +22,26 @@ # available under the MIT license from # http://trac.misuse.org/science/wiki/DeepMerge -require 'spec_helper' +require "spec_helper" # Test coverage from the original author converted to rspec describe Chef::Mixin::DeepMerge, "deep_merge!" do before do @dm = Chef::Mixin::DeepMerge - @field_ko_prefix = '!merge' + @field_ko_prefix = "!merge" end # deep_merge core tests - moving from basic to more complex it "tests merging an hash w/array into blank hash" do - hash_src = {'id' => '2'} + hash_src = {"id" => "2"} hash_dst = {} @dm.deep_merge!(hash_src.dup, hash_dst) expect(hash_dst).to eq(hash_src) end it "tests merging an hash w/array into blank hash" do - hash_src = {'region' => {'id' => ['227', '2']}} + hash_src = {"region" => {"id" => ["227", "2"]}} hash_dst = {} @dm.deep_merge!(hash_src, hash_dst) expect(hash_dst).to eq(hash_src) @@ -181,10 +181,10 @@ describe Chef::Mixin::DeepMerge, "deep_merge!" do end it "tests merging of hash with blank hash, and make sure that source array split does not function when turned off" do - hash_src = {'property' => {'bedroom_count' => ["1","2,3"]}} + hash_src = {"property" => {"bedroom_count" => ["1","2,3"]}} hash_dst = {} @dm.deep_merge!(hash_src, hash_dst) - expect(hash_dst).to eq({'property' => {'bedroom_count' => ["1","2,3"]}}) + expect(hash_dst).to eq({"property" => {"bedroom_count" => ["1","2,3"]}}) end it "tests merging into a blank hash" do @@ -247,13 +247,13 @@ describe Chef::Mixin::DeepMerge do describe "merge" do it "should merge a hash into an empty hash" do hash_dst = {} - hash_src = {'id' => '2'} + hash_src = {"id" => "2"} expect(@dm.merge(hash_dst, hash_src)).to eq(hash_src) end it "should merge a nested hash into an empty hash" do hash_dst = {} - hash_src = {'region' => {'id' => ['227', '2']}} + hash_src = {"region" => {"id" => ["227", "2"]}} expect(@dm.merge(hash_dst, hash_src)).to eq(hash_src) end diff --git a/spec/unit/mixin/deprecation_spec.rb b/spec/unit/mixin/deprecation_spec.rb index 6d9f39af9f..3ac0936f60 100644 --- a/spec/unit/mixin/deprecation_spec.rb +++ b/spec/unit/mixin/deprecation_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/deprecation' +require "spec_helper" +require "chef/mixin/deprecation" describe Chef::Mixin do describe "deprecating constants (Class/Module)" do @@ -46,7 +46,7 @@ describe Chef::Mixin::Deprecation::DeprecatedInstanceVariable do before do Chef::Log.logger = Logger.new(StringIO.new) - @deprecated_ivar = Chef::Mixin::Deprecation::DeprecatedInstanceVariable.new('value', 'an_ivar') + @deprecated_ivar = Chef::Mixin::Deprecation::DeprecatedInstanceVariable.new("value", "an_ivar") end it "forward method calls to the target object" do diff --git a/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb b/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb index 408926293e..9da7270bc3 100644 --- a/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb +++ b/spec/unit/mixin/enforce_ownership_and_permissions_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'etc' -require 'ostruct' +require "spec_helper" +require "etc" +require "ostruct" describe Chef::Mixin::EnforceOwnershipAndPermissions do @@ -52,8 +52,8 @@ describe Chef::Mixin::EnforceOwnershipAndPermissions do allow_any_instance_of(Chef::FileAccessControl).to receive(:describe_changes) passwd_struct = OpenStruct.new(:name => "root", :passwd => "x", - :uid => 0, :gid => 0, :dir => '/root', - :shell => '/bin/bash') + :uid => 0, :gid => 0, :dir => "/root", + :shell => "/bin/bash") group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0) allow(Etc).to receive(:getpwuid).and_return(passwd_struct) @@ -76,8 +76,8 @@ describe Chef::Mixin::EnforceOwnershipAndPermissions do allow_any_instance_of(Chef::FileAccessControl).to receive(:describe_changes) passwd_struct = OpenStruct.new(:name => "root", :passwd => "x", - :uid => 0, :gid => 0, :dir => '/root', - :shell => '/bin/bash') + :uid => 0, :gid => 0, :dir => "/root", + :shell => "/bin/bash") group_struct = OpenStruct.new(:name => "root", :passwd => "x", :gid => 0) allow(Etc).to receive(:getpwuid).and_return(passwd_struct) diff --git a/spec/unit/mixin/homebrew_user_spec.rb b/spec/unit/mixin/homebrew_user_spec.rb index 57b89720dc..77e37a030c 100644 --- a/spec/unit/mixin/homebrew_user_spec.rb +++ b/spec/unit/mixin/homebrew_user_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' -require 'chef/mixin/homebrew_user' +require "spec_helper" +require "chef/mixin/homebrew_user" class ExampleHomebrewUser include Chef::Mixin::HomebrewUser @@ -24,22 +24,22 @@ end describe Chef::Mixin::HomebrewUser do before(:each) do - node.default['homebrew']['owner'] = nil + node.default["homebrew"]["owner"] = nil end let(:homebrew_user) { ExampleHomebrewUser.new } let(:node) { Chef::Node.new } - describe 'when the homebrew user is provided' do + describe "when the homebrew user is provided" do let(:uid) { 1001 } let(:user) { "foo" } - it 'returns the homebrew user without looking at the file when uid is provided' do + it "returns the homebrew user without looking at the file when uid is provided" do expect(File).to receive(:exist?).exactly(0).times expect(homebrew_user.find_homebrew_uid(uid)).to eq(uid) end - it 'returns the homebrew user without looking at the file when name is provided' do + it "returns the homebrew user without looking at the file when name is provided" do expect(File).to receive(:exist?).exactly(0).times allow(Etc).to receive_message_chain(:getpwnam, :uid).and_return(uid) expect(homebrew_user.find_homebrew_uid(user)).to eq(uid) @@ -50,7 +50,7 @@ describe Chef::Mixin::HomebrewUser do shared_examples "successfully find executable" do let(:user) { nil } let(:brew_owner) { 2001 } - let(:default_brew_path) { '/usr/local/bin/brew' } + let(:default_brew_path) { "/usr/local/bin/brew" } let(:stat_double) { d = double() expect(d).to receive(:uid).and_return(brew_owner) @@ -63,13 +63,13 @@ describe Chef::Mixin::HomebrewUser do expect(Etc).to receive(:getpwuid).with(brew_owner).and_return(OpenStruct.new(:name => "name")) end - it 'returns the owner of the brew executable when it is at a default location' do + it "returns the owner of the brew executable when it is at a default location" do expect(File).to receive(:exist?).with(default_brew_path).and_return(true) expect(File).to receive(:stat).with(default_brew_path).and_return(stat_double) expect(homebrew_user.find_homebrew_uid(user)).to eq(brew_owner) end - it 'returns the owner of the brew executable when it is not at a default location' do + it "returns the owner of the brew executable when it is not at a default location" do expect(File).to receive(:exist?).with(default_brew_path).and_return(false) allow(homebrew_user).to receive_message_chain(:shell_out, :stdout, :strip).and_return("/foo") expect(File).to receive(:stat).with("/foo").and_return(stat_double) @@ -79,9 +79,9 @@ describe Chef::Mixin::HomebrewUser do end end - describe 'when the homebrew user is not provided' do + describe "when the homebrew user is not provided" do - it 'raises an error if no executable is found' do + it "raises an error if no executable is found" do expect(File).to receive(:exist?).with(default_brew_path).and_return(false) allow(homebrew_user).to receive_message_chain(:shell_out, :stdout, :strip).and_return("") expect { homebrew_user.find_homebrew_uid(user) }.to raise_error(Chef::Exceptions::CannotDetermineHomebrewOwner) diff --git a/spec/unit/mixin/params_validate_spec.rb b/spec/unit/mixin/params_validate_spec.rb index 99d5230a75..15f99d98f8 100644 --- a/spec/unit/mixin/params_validate_spec.rb +++ b/spec/unit/mixin/params_validate_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class TinyClass include Chef::Mixin::ParamsValidate @@ -372,12 +372,12 @@ describe Chef::Mixin::ParamsValidate do end it "should allow DelayedEvaluator instance to be set for value regardless of restriction" do - value = Chef::DelayedEvaluator.new{ 'test' } + value = Chef::DelayedEvaluator.new{ "test" } @vo.set_or_return(:test, value, {:kind_of => Numeric}) end it "should raise an error when delayed evaluated attribute is not valid" do - value = Chef::DelayedEvaluator.new{ 'test' } + value = Chef::DelayedEvaluator.new{ "test" } @vo.set_or_return(:test, value, {:kind_of => Numeric}) expect do @vo.set_or_return(:test, nil, {:kind_of => Numeric}) @@ -385,22 +385,22 @@ describe Chef::Mixin::ParamsValidate do end it "should create DelayedEvaluator instance when #lazy is used" do - @vo.set_or_return(:delayed, @vo.lazy{ 'test' }, {}) + @vo.set_or_return(:delayed, @vo.lazy{ "test" }, {}) expect(@vo.instance_variable_get(:@delayed)).to be_a(Chef::DelayedEvaluator) end it "should execute block on each call when DelayedEvaluator" do - value = 'fubar' + value = "fubar" @vo.set_or_return(:test, @vo.lazy{ value }, {}) - expect(@vo.set_or_return(:test, nil, {})).to eq('fubar') - value = 'foobar' - expect(@vo.set_or_return(:test, nil, {})).to eq('foobar') - value = 'fauxbar' - expect(@vo.set_or_return(:test, nil, {})).to eq('fauxbar') + expect(@vo.set_or_return(:test, nil, {})).to eq("fubar") + value = "foobar" + expect(@vo.set_or_return(:test, nil, {})).to eq("foobar") + value = "fauxbar" + expect(@vo.set_or_return(:test, nil, {})).to eq("fauxbar") end it "should not evaluate non DelayedEvaluator instances" do - value = lambda{ 'test' } + value = lambda{ "test" } @vo.set_or_return(:test, value, {}) expect(@vo.set_or_return(:test, nil, {}).object_id).to eq(value.object_id) expect(@vo.set_or_return(:test, nil, {})).to be_a(Proc) diff --git a/spec/unit/mixin/path_sanity_spec.rb b/spec/unit/mixin/path_sanity_spec.rb index 3a924b9538..547c78f706 100644 --- a/spec/unit/mixin/path_sanity_spec.rb +++ b/spec/unit/mixin/path_sanity_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class PathSanityTestHarness include Chef::Mixin::PathSanity @@ -31,10 +31,10 @@ describe Chef::Mixin::PathSanity do describe "when enforcing path sanity" do before do Chef::Config[:enforce_path_sanity] = true - @ruby_bindir = '/some/ruby/bin' - @gem_bindir = '/some/gem/bin' + @ruby_bindir = "/some/ruby/bin" + @gem_bindir = "/some/gem/bin" allow(Gem).to receive(:bindir).and_return(@gem_bindir) - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return(@ruby_bindir) + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(@ruby_bindir) allow(ChefConfig).to receive(:windows?).and_return(false) end @@ -63,10 +63,10 @@ describe Chef::Mixin::PathSanity do end it "does not create entries for Ruby/Gem bindirs if they exist in SANE_PATH or PATH" do - ruby_bindir = '/usr/bin' - gem_bindir = '/yo/gabba/gabba' + ruby_bindir = "/usr/bin" + gem_bindir = "/yo/gabba/gabba" allow(Gem).to receive(:bindir).and_return(gem_bindir) - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return(ruby_bindir) + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir) env = {"PATH" => gem_bindir} @sanity.enforce_path_sanity(env) expect(env["PATH"]).to eq("/yo/gabba/gabba:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin") @@ -76,7 +76,7 @@ describe Chef::Mixin::PathSanity do ruby_bindir = 'C:\ruby\bin' gem_bindir = 'C:\gems\bin' allow(Gem).to receive(:bindir).and_return(gem_bindir) - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return(ruby_bindir) + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return(ruby_bindir) allow(ChefConfig).to receive(:windows?).and_return(true) env = {"PATH" => 'C:\Windows\system32;C:\mr\softie'} @sanity.enforce_path_sanity(env) diff --git a/spec/unit/mixin/powershell_out_spec.rb b/spec/unit/mixin/powershell_out_spec.rb index 79faf8127d..e8ba6036c5 100644 --- a/spec/unit/mixin/powershell_out_spec.rb +++ b/spec/unit/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 do let(:shell_out_class) { Class.new { include Chef::Mixin::PowershellOut } } diff --git a/spec/unit/mixin/powershell_type_coercions_spec.rb b/spec/unit/mixin/powershell_type_coercions_spec.rb index 988c3926c1..7f49784e8b 100644 --- a/spec/unit/mixin/powershell_type_coercions_spec.rb +++ b/spec/unit/mixin/powershell_type_coercions_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/powershell_type_coercions' -require 'base64' +require "spec_helper" +require "chef/mixin/powershell_type_coercions" +require "base64" class Chef::PSTypeTester include Chef::Mixin::PowershellTypeCoercions @@ -28,45 +28,45 @@ describe Chef::Mixin::PowershellTypeCoercions do let (:test_class) { Chef::PSTypeTester.new } describe '#translate_type' do - it 'should single quote a string' do - expect(test_class.translate_type('foo')).to eq("'foo'") + it "should single quote a string" do + expect(test_class.translate_type("foo")).to eq("'foo'") end - ["'", '"', '#', '`'].each do |c| + ["'", '"', '#', "`"].each do |c| it "should base64 encode a string that contains #{c}" do expect(test_class.translate_type("#{c}")).to match(Base64.strict_encode64(c)) end end - it 'should not quote an integer' do - expect(test_class.translate_type(123)).to eq('123') + it "should not quote an integer" do + expect(test_class.translate_type(123)).to eq("123") end - it 'should not quote a floating point number' do - expect(test_class.translate_type(123.4)).to eq('123.4') + it "should not quote a floating point number" do + expect(test_class.translate_type(123.4)).to eq("123.4") end - it 'should return $false when an instance of FalseClass is provided' do - expect(test_class.translate_type(false)).to eq('$false') + it "should return $false when an instance of FalseClass is provided" do + expect(test_class.translate_type(false)).to eq("$false") end - it 'should return $true when an instance of TrueClass is provided' do - expect(test_class.translate_type(true)).to eq('$true') + it "should return $true when an instance of TrueClass is provided" do + expect(test_class.translate_type(true)).to eq("$true") end - it 'should translate all members of a hash and wrap them in @{} separated by ;' do + it "should translate all members of a hash and wrap them in @{} separated by ;" do expect(test_class.translate_type({"a" => 1, "b" => 1.2, "c" => false, "d" => true })).to eq("@{a=1;b=1.2;c=$false;d=$true}") end - it 'should translat all members of an array and them by a ,' do - expect(test_class.translate_type([true, false])).to eq('@($true,$false)') + it "should translat all members of an array and them by a ," do + expect(test_class.translate_type([true, false])).to eq("@($true,$false)") end - it 'should fall back :to_psobject if we have not defined at explicit rule' do + it "should fall back :to_psobject if we have not defined at explicit rule" do ps_obj = double("PSObject") - expect(ps_obj).to receive(:to_psobject).and_return('$true') - expect(test_class.translate_type(ps_obj)).to eq('($true)') + expect(ps_obj).to receive(:to_psobject).and_return("$true") + expect(test_class.translate_type(ps_obj)).to eq("($true)") end end end diff --git a/spec/unit/mixin/properties_spec.rb b/spec/unit/mixin/properties_spec.rb index 18178619e4..00e339a221 100644 --- a/spec/unit/mixin/properties_spec.rb +++ b/spec/unit/mixin/properties_spec.rb @@ -1,5 +1,5 @@ -require 'support/shared/integration/integration_helper' -require 'chef/mixin/properties' +require "support/shared/integration/integration_helper" +require "chef/mixin/properties" module ChefMixinPropertiesSpec describe "Chef::Resource.property" do @@ -8,46 +8,46 @@ module ChefMixinPropertiesSpec context "with a base class A with properties a, ab, and ac" do class A include Chef::Mixin::Properties - property :a, 'a', default: 'a' - property :ab, ['a', 'b'], default: 'a' - property :ac, ['a', 'c'], default: 'a' + property :a, "a", default: "a" + property :ab, ["a", "b"], default: "a" + property :ac, ["a", "c"], default: "a" end context "and a module B with properties b, ab and bc" do module B include Chef::Mixin::Properties - property :b, 'b', default: 'b' - property :ab, default: 'b' - property :bc, ['b', 'c'], default: 'c' + property :b, "b", default: "b" + property :ab, default: "b" + property :bc, ["b", "c"], default: "c" end context "and a derived class C < A with properties c, ac and bc" do class C < A include B - property :c, 'c', default: 'c' - property :ac, default: 'c' - property :bc, default: 'c' + property :c, "c", default: "c" + property :ac, default: "c" + property :bc, default: "c" end it "A.properties has a, ab, and ac with types 'a', ['a', 'b'], and ['b', 'c']" do expect(A.properties.keys).to eq [ :a, :ab, :ac ] - expect(A.properties[:a].validation_options[:is]).to eq 'a' - expect(A.properties[:ab].validation_options[:is]).to eq [ 'a', 'b' ] - expect(A.properties[:ac].validation_options[:is]).to eq [ 'a', 'c' ] + expect(A.properties[:a].validation_options[:is]).to eq "a" + expect(A.properties[:ab].validation_options[:is]).to eq [ "a", "b" ] + expect(A.properties[:ac].validation_options[:is]).to eq [ "a", "c" ] end it "B.properties has b, ab, and bc with types 'b', nil and ['b', 'c']" do expect(B.properties.keys).to eq [ :b, :ab, :bc ] - expect(B.properties[:b].validation_options[:is]).to eq 'b' + expect(B.properties[:b].validation_options[:is]).to eq "b" expect(B.properties[:ab].validation_options[:is]).to be_nil - expect(B.properties[:bc].validation_options[:is]).to eq [ 'b', 'c' ] + expect(B.properties[:bc].validation_options[:is]).to eq [ "b", "c" ] end it "C.properties has a, b, c, ac and bc with merged types" do expect(C.properties.keys).to eq [ :a, :ab, :ac, :b, :bc, :c ] - expect(C.properties[:a].validation_options[:is]).to eq 'a' - expect(C.properties[:b].validation_options[:is]).to eq 'b' - expect(C.properties[:c].validation_options[:is]).to eq 'c' - expect(C.properties[:ac].validation_options[:is]).to eq [ 'a', 'c' ] - expect(C.properties[:bc].validation_options[:is]).to eq [ 'b', 'c' ] + expect(C.properties[:a].validation_options[:is]).to eq "a" + expect(C.properties[:b].validation_options[:is]).to eq "b" + expect(C.properties[:c].validation_options[:is]).to eq "c" + expect(C.properties[:ac].validation_options[:is]).to eq [ "a", "c" ] + expect(C.properties[:bc].validation_options[:is]).to eq [ "b", "c" ] end it "C.properties has ab with a non-merged type (from B)" do expect(C.properties[:ab].validation_options[:is]).to be_nil @@ -57,12 +57,12 @@ module ChefMixinPropertiesSpec let(:c) { C.new } it "all properties can be retrieved and merged properties default to ab->b, ac->c, bc->c" do - expect(c.a).to eq('a') - expect(c.b).to eq('b') - expect(c.c).to eq('c') - expect(c.ab).to eq('b') - expect(c.ac).to eq('c') - expect(c.bc).to eq('c') + expect(c.a).to eq("a") + expect(c.b).to eq("b") + expect(c.c).to eq("c") + expect(c.ab).to eq("b") + expect(c.ac).to eq("c") + expect(c.bc).to eq("c") end end end diff --git a/spec/unit/mixin/proxified_socket_spec.rb b/spec/unit/mixin/proxified_socket_spec.rb index 88f71ae48b..70c1ff95cd 100644 --- a/spec/unit/mixin/proxified_socket_spec.rb +++ b/spec/unit/mixin/proxified_socket_spec.rb @@ -63,8 +63,8 @@ describe Chef::Mixin::ProxifiedSocket do before do # I'm purposefully setting both of these because we prefer the https # variable - ENV['https_proxy'] = https_uri - ENV['http_proxy'] = http_uri + ENV["https_proxy"] = https_uri + ENV["http_proxy"] = http_uri end let(:proxy_uri) { https_uri } @@ -74,7 +74,7 @@ describe Chef::Mixin::ProxifiedSocket do # This is testing that no_proxy is also provided to Proxified # when it is set before do - ENV['no_proxy'] = no_proxy_spec + ENV["no_proxy"] = no_proxy_spec end let(:no_proxy_spec) { "somehost1,somehost2" } @@ -84,7 +84,7 @@ describe Chef::Mixin::ProxifiedSocket do context "when http_proxy is set" do before do - ENV['http_proxy'] = http_uri + ENV["http_proxy"] = http_uri end let(:proxy_uri) { http_uri } diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb index 33d5eb2141..d52dcd7cbe 100644 --- a/spec/unit/mixin/securable_spec.rb +++ b/spec/unit/mixin/securable_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Mixin::Securable do @@ -59,32 +59,32 @@ describe Chef::Mixin::Securable do end it "should accept group/owner names that are a single character or digit" do - expect { @securable.group 'v' }.not_to raise_error - expect { @securable.group '1' }.not_to raise_error - expect { @securable.owner 'v' }.not_to raise_error - expect { @securable.owner '1' }.not_to raise_error + expect { @securable.group "v" }.not_to raise_error + expect { @securable.group "1" }.not_to raise_error + expect { @securable.owner "v" }.not_to raise_error + expect { @securable.owner "1" }.not_to raise_error end it "should not accept group/owner names starting with '-', '+', or '~'" do - expect { @securable.group '-test' }.to raise_error(ArgumentError) - expect { @securable.group '+test' }.to raise_error(ArgumentError) - expect { @securable.group '~test' }.to raise_error(ArgumentError) - expect { @securable.group 'te-st' }.not_to raise_error - expect { @securable.group 'te+st' }.not_to raise_error - expect { @securable.group 'te~st' }.not_to raise_error - expect { @securable.owner '-test' }.to raise_error(ArgumentError) - expect { @securable.owner '+test' }.to raise_error(ArgumentError) - expect { @securable.owner '~test' }.to raise_error(ArgumentError) - expect { @securable.owner 'te-st' }.not_to raise_error - expect { @securable.owner 'te+st' }.not_to raise_error - expect { @securable.owner 'te~st' }.not_to raise_error + expect { @securable.group "-test" }.to raise_error(ArgumentError) + expect { @securable.group "+test" }.to raise_error(ArgumentError) + expect { @securable.group "~test" }.to raise_error(ArgumentError) + expect { @securable.group "te-st" }.not_to raise_error + expect { @securable.group "te+st" }.not_to raise_error + expect { @securable.group "te~st" }.not_to raise_error + expect { @securable.owner "-test" }.to raise_error(ArgumentError) + expect { @securable.owner "+test" }.to raise_error(ArgumentError) + expect { @securable.owner "~test" }.to raise_error(ArgumentError) + expect { @securable.owner "te-st" }.not_to raise_error + expect { @securable.owner "te+st" }.not_to raise_error + expect { @securable.owner "te~st" }.not_to raise_error end it "should not accept group/owner names containing ':', ',' or non-space whitespace" do - expect { @securable.group ':test' }.to raise_error(ArgumentError) - expect { @securable.group 'te:st' }.to raise_error(ArgumentError) - expect { @securable.group ',test' }.to raise_error(ArgumentError) - expect { @securable.group 'te,st' }.to raise_error(ArgumentError) + expect { @securable.group ":test" }.to raise_error(ArgumentError) + expect { @securable.group "te:st" }.to raise_error(ArgumentError) + expect { @securable.group ",test" }.to raise_error(ArgumentError) + expect { @securable.group "te,st" }.to raise_error(ArgumentError) expect { @securable.group "\ttest" }.to raise_error(ArgumentError) expect { @securable.group "te\tst" }.to raise_error(ArgumentError) expect { @securable.group "\rtest" }.to raise_error(ArgumentError) @@ -93,10 +93,10 @@ describe Chef::Mixin::Securable do expect { @securable.group "te\fst" }.to raise_error(ArgumentError) expect { @securable.group "\0test" }.to raise_error(ArgumentError) expect { @securable.group "te\0st" }.to raise_error(ArgumentError) - expect { @securable.owner ':test' }.to raise_error(ArgumentError) - expect { @securable.owner 'te:st' }.to raise_error(ArgumentError) - expect { @securable.owner ',test' }.to raise_error(ArgumentError) - expect { @securable.owner 'te,st' }.to raise_error(ArgumentError) + expect { @securable.owner ":test" }.to raise_error(ArgumentError) + expect { @securable.owner "te:st" }.to raise_error(ArgumentError) + expect { @securable.owner ",test" }.to raise_error(ArgumentError) + expect { @securable.owner "te,st" }.to raise_error(ArgumentError) expect { @securable.owner "\ttest" }.to raise_error(ArgumentError) expect { @securable.owner "te\tst" }.to raise_error(ArgumentError) expect { @securable.owner "\rtest" }.to raise_error(ArgumentError) @@ -124,10 +124,10 @@ describe Chef::Mixin::Securable do end it "should accept group/owner names in UTF-8" do - expect { @securable.group 'tëst' }.not_to raise_error - expect { @securable.group 'ë' }.not_to raise_error - expect { @securable.owner 'tëst' }.not_to raise_error - expect { @securable.owner 'ë' }.not_to raise_error + expect { @securable.group "tëst" }.not_to raise_error + expect { @securable.group "ë" }.not_to raise_error + expect { @securable.owner "tëst" }.not_to raise_error + expect { @securable.owner "ë" }.not_to raise_error end it "should accept a unix file mode in string form as an octal number" do @@ -262,19 +262,19 @@ describe Chef::Mixin::Securable do expect { @securable.rights :read, "The Dude", :applies_to_children => true }.not_to raise_error expect { @securable.rights :read, "The Dude", :applies_to_children => :containers_only }.not_to raise_error expect { @securable.rights :read, "The Dude", :applies_to_children => :objects_only }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => 'poop' }.to raise_error(ArgumentError) + expect { @securable.rights :read, "The Dude", :applies_to_children => "poop" }.to raise_error(ArgumentError) end it "should allow you to specify whether the permissions applies_to_self with true/false" do expect { @securable.rights :read, "The Dude", :applies_to_children => true, :applies_to_self => false }.not_to raise_error expect { @securable.rights :read, "The Dude", :applies_to_self => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_self => 'poop' }.to raise_error(ArgumentError) + expect { @securable.rights :read, "The Dude", :applies_to_self => "poop" }.to raise_error(ArgumentError) end it "should allow you to specify whether the permissions applies one_level_deep with true/false" do expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => false }.not_to raise_error expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => true }.not_to raise_error - expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => 'poop' }.to raise_error(ArgumentError) + expect { @securable.rights :read, "The Dude", :applies_to_children => true, :one_level_deep => "poop" }.to raise_error(ArgumentError) end it "should allow multiple rights and deny_rights declarations" do diff --git a/spec/unit/mixin/shell_out_spec.rb b/spec/unit/mixin/shell_out_spec.rb index c22d45e5fd..8a2fea651a 100644 --- a/spec/unit/mixin/shell_out_spec.rb +++ b/spec/unit/mixin/shell_out_spec.rb @@ -20,7 +20,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Mixin::ShellOut do let(:shell_out_class) { Class.new { include Chef::Mixin::ShellOut } } @@ -34,25 +34,25 @@ describe Chef::Mixin::ShellOut do let!(:capture_log_output) { Chef::Log.logger = Logger.new(output) } let(:assume_deprecation_log_level) { allow(Chef::Log).to receive(:level).and_return(:warn) } - context 'without options' do + context "without options" do let(:command_args) { [ cmd ] } - it 'should not edit command args' do + it "should not edit command args" do is_expected.to eql(command_args) end end - context 'without deprecated options' do + context "without deprecated options" do let(:options) { { :environment => environment } } - let(:environment) { { 'LC_ALL' => 'C', 'LANG' => 'C', 'LANGUAGE' => 'C' } } + let(:environment) { { "LC_ALL" => "C", "LANG" => "C", "LANGUAGE" => "C" } } - it 'should not edit command args' do + it "should not edit command args" do is_expected.to eql(command_args) end end def self.should_emit_deprecation_warning_about(old_option, new_option) - it 'should emit a deprecation warning' do + it "should emit a deprecation warning" do assume_deprecation_log_level and capture_log_output subject expect(output.string).to match /DEPRECATION:/ @@ -61,22 +61,22 @@ describe Chef::Mixin::ShellOut do end end - context 'with :command_log_level option' do + context "with :command_log_level option" do let(:options) { { :command_log_level => command_log_level } } let(:command_log_level) { :warn } - it 'should convert :command_log_level to :log_level' do + it "should convert :command_log_level to :log_level" do is_expected.to eql [ cmd, { :log_level => command_log_level } ] end should_emit_deprecation_warning_about :command_log_level, :log_level end - context 'with :command_log_prepend option' do + context "with :command_log_prepend option" do let(:options) { { :command_log_prepend => command_log_prepend } } - let(:command_log_prepend) { 'PROVIDER:' } + let(:command_log_prepend) { "PROVIDER:" } - it 'should convert :command_log_prepend to :log_tag' do + it "should convert :command_log_prepend to :log_tag" do is_expected.to eql [ cmd, { :log_tag => command_log_prepend } ] end @@ -84,7 +84,7 @@ describe Chef::Mixin::ShellOut do end context "with 'command_log_level' option" do - let(:options) { { 'command_log_level' => command_log_level } } + let(:options) { { "command_log_level" => command_log_level } } let(:command_log_level) { :warn } it "should convert 'command_log_level' to :log_level" do @@ -95,8 +95,8 @@ describe Chef::Mixin::ShellOut do end context "with 'command_log_prepend' option" do - let(:options) { { 'command_log_prepend' => command_log_prepend } } - let(:command_log_prepend) { 'PROVIDER:' } + let(:options) { { "command_log_prepend" => command_log_prepend } } + let(:command_log_prepend) { "PROVIDER:" } it "should convert 'command_log_prepend' to :log_tag" do is_expected.to eql [ cmd, { :log_tag => command_log_prepend } ] @@ -124,95 +124,95 @@ describe Chef::Mixin::ShellOut do describe "when the last argument is a Hash" do describe "and environment is an option" do it "should not change environment language settings when they are set to nil" do - options = { :environment => { 'LC_ALL' => nil, 'LANGUAGE' => nil, 'LANG' => nil } } + options = { :environment => { "LC_ALL" => nil, "LANGUAGE" => nil, "LANG" => nil } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, options) end it "should not change environment language settings when they are set to non-nil" do - options = { :environment => { 'LC_ALL' => 'en_US.UTF-8', 'LANGUAGE' => 'en_US.UTF-8', 'LANG' => 'en_US.UTF-8' } } + options = { :environment => { "LC_ALL" => "en_US.UTF-8", "LANGUAGE" => "en_US.UTF-8", "LANG" => "en_US.UTF-8" } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, options) end it "should set environment language settings to the configured internal locale when they are not present" do - options = { :environment => { 'HOME' => '/Users/morty' } } + options = { :environment => { "HOME" => "/Users/morty" } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, { :environment => { - 'HOME' => '/Users/morty', - 'LC_ALL' => Chef::Config[:internal_locale], - 'LANG' => Chef::Config[:internal_locale], - 'LANGUAGE' => Chef::Config[:internal_locale], + "HOME" => "/Users/morty", + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], + "LANGUAGE" => Chef::Config[:internal_locale], } },).and_return(true) shell_out_obj.shell_out(cmd, options) end it "should not mutate the options hash when it adds language settings" do - options = { :environment => { 'HOME' => '/Users/morty' } } + options = { :environment => { "HOME" => "/Users/morty" } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, { :environment => { - 'HOME' => '/Users/morty', - 'LC_ALL' => Chef::Config[:internal_locale], - 'LANG' => Chef::Config[:internal_locale], - 'LANGUAGE' => Chef::Config[:internal_locale], + "HOME" => "/Users/morty", + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], + "LANGUAGE" => Chef::Config[:internal_locale], } },).and_return(true) shell_out_obj.shell_out(cmd, options) - expect(options[:environment].has_key?('LC_ALL')).to be false + expect(options[:environment].has_key?("LC_ALL")).to be false end end describe "and env is an option" do it "should not change env when langauge options are set to nil" do - options = { :env => { 'LC_ALL' => nil, 'LANG' => nil, 'LANGUAGE' => nil } } + options = { :env => { "LC_ALL" => nil, "LANG" => nil, "LANGUAGE" => nil } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, options) end it "should not change env when language options are set to non-nil" do - options = { :env => { 'LC_ALL' => 'de_DE.UTF-8', 'LANG' => 'de_DE.UTF-8', 'LANGUAGE' => 'de_DE.UTF-8' }} + options = { :env => { "LC_ALL" => "de_DE.UTF-8", "LANG" => "de_DE.UTF-8", "LANGUAGE" => "de_DE.UTF-8" }} expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out(cmd, options) end it "should set environment language settings to the configured internal locale when they are not present" do - options = { :env => { 'HOME' => '/Users/morty' } } + options = { :env => { "HOME" => "/Users/morty" } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, { :env => { - 'HOME' => '/Users/morty', - 'LC_ALL' => Chef::Config[:internal_locale], - 'LANG' => Chef::Config[:internal_locale], - 'LANGUAGE' => Chef::Config[:internal_locale], + "HOME" => "/Users/morty", + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], + "LANGUAGE" => Chef::Config[:internal_locale], } },).and_return(true) shell_out_obj.shell_out(cmd, options) end it "should not mutate the options hash when it adds language settings" do - options = { :env => { 'HOME' => '/Users/morty' } } + options = { :env => { "HOME" => "/Users/morty" } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, { :env => { - 'HOME' => '/Users/morty', - 'LC_ALL' => Chef::Config[:internal_locale], - 'LANG' => Chef::Config[:internal_locale], - 'LANGUAGE' => Chef::Config[:internal_locale], + "HOME" => "/Users/morty", + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], + "LANGUAGE" => Chef::Config[:internal_locale], } },).and_return(true) shell_out_obj.shell_out(cmd, options) - expect(options[:env].has_key?('LC_ALL')).to be false + expect(options[:env].has_key?("LC_ALL")).to be false end end describe "and no env/environment option is present" do it "should set environment language settings to the configured internal locale" do - options = { :user => 'morty' } + options = { :user => "morty" } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, { - :user => 'morty', + :user => "morty", :environment => { - 'LC_ALL' => Chef::Config[:internal_locale], - 'LANG' => Chef::Config[:internal_locale], - 'LANGUAGE' => Chef::Config[:internal_locale], + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], + "LANGUAGE" => Chef::Config[:internal_locale], }, },).and_return(true) shell_out_obj.shell_out(cmd, options) @@ -224,9 +224,9 @@ describe Chef::Mixin::ShellOut do it "should set environment language settings to the configured internal locale" do expect(shell_out_obj).to receive(:shell_out_command).with(cmd, { :environment => { - 'LC_ALL' => Chef::Config[:internal_locale], - 'LANG' => Chef::Config[:internal_locale], - 'LANGUAGE' => Chef::Config[:internal_locale], + "LC_ALL" => Chef::Config[:internal_locale], + "LANG" => Chef::Config[:internal_locale], + "LANGUAGE" => Chef::Config[:internal_locale], } },).and_return(true) shell_out_obj.shell_out(cmd) @@ -240,19 +240,19 @@ describe Chef::Mixin::ShellOut do describe "when the last argument is a Hash" do describe "and environment is an option" do it "should not change environment['LC_ALL'] when set to nil" do - options = { :environment => { 'LC_ALL' => nil } } + options = { :environment => { "LC_ALL" => nil } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end it "should not change environment['LC_ALL'] when set to non-nil" do - options = { :environment => { 'LC_ALL' => 'en_US.UTF-8' } } + options = { :environment => { "LC_ALL" => "en_US.UTF-8" } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end it "should no longer set environment['LC_ALL'] to nil when 'LC_ALL' not present" do - options = { :environment => { 'HOME' => '/Users/morty' } } + options = { :environment => { "HOME" => "/Users/morty" } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end @@ -260,19 +260,19 @@ describe Chef::Mixin::ShellOut do describe "and env is an option" do it "should not change env when set to nil" do - options = { :env => { 'LC_ALL' => nil } } + options = { :env => { "LC_ALL" => nil } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end it "should not change env when set to non-nil" do - options = { :env => { 'LC_ALL' => 'en_US.UTF-8'}} + options = { :env => { "LC_ALL" => "en_US.UTF-8"}} expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end it "should no longer set env['LC_ALL'] to nil when 'LC_ALL' not present" do - options = { :env => { 'HOME' => '/Users/morty' } } + options = { :env => { "HOME" => "/Users/morty" } } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end @@ -280,7 +280,7 @@ describe Chef::Mixin::ShellOut do describe "and no env/environment option is present" do it "should no longer add environment option and set environment['LC_ALL'] to nil" do - options = { :user => 'morty' } + options = { :user => "morty" } expect(shell_out_obj).to receive(:shell_out_command).with(cmd, options).and_return(true) shell_out_obj.shell_out_with_systems_locale(cmd, options) end diff --git a/spec/unit/mixin/subclass_directive_spec.rb b/spec/unit/mixin/subclass_directive_spec.rb index 552f26c0c1..38357883d3 100644 --- a/spec/unit/mixin/subclass_directive_spec.rb +++ b/spec/unit/mixin/subclass_directive_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class SubclassDirectiveParent extend Chef::Mixin::SubclassDirective diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb index 95d0eb6711..2fb384866d 100644 --- a/spec/unit/mixin/template_spec.rb +++ b/spec/unit/mixin/template_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'cgi' +require "cgi" describe Chef::Mixin::Template, "render_template" do let(:sep) { Chef::Platform.windows? ? "\r\n" : "\n" } @@ -85,10 +85,10 @@ describe Chef::Mixin::Template, "render_template" do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events) - @rendered_file_location = Dir.tmpdir + '/openldap_stuff.conf' + @rendered_file_location = Dir.tmpdir + "/openldap_stuff.conf" @resource = Chef::Resource::Template.new(@rendered_file_location) - @resource.cookbook_name = 'openldap' + @resource.cookbook_name = "openldap" @current_resource = @resource.dup @content_provider = Chef::Provider::Template::Content.new(@resource, @current_resource, @run_context) @@ -117,7 +117,7 @@ describe Chef::Mixin::Template, "render_template" do end it "should render partials from a different cookbook" do - @template_context[:template_finder] = Chef::Provider::TemplateFinder.new(@run_context, 'apache2', @node) + @template_context[:template_finder] = Chef::Provider::TemplateFinder.new(@run_context, "apache2", @node) output = @template_context.render_template_from_string("before {<%= render('test.erb', :cookbook => 'openldap').strip %>} after") expect(output).to eq("before {We could be diving for pearls!} after") @@ -144,7 +144,7 @@ describe Chef::Mixin::Template, "render_template" do end it "should pass the original variables to partials" do - @template_context[:secret] = 'candy' + @template_context[:secret] = "candy" output = @template_context.render_template_from_string("before {<%= render 'openldap_variable_stuff.conf.erb' %>} after") output == "before {super secret is candy} after" @@ -161,7 +161,7 @@ describe Chef::Mixin::Template, "render_template" do end it "should pass variables to partials even if they are named the same" do - @template_context[:secret] = 'one' + @template_context[:secret] = "one" output = @template_context.render_template_from_string("before {<%= render 'openldap_variable_stuff.conf.erb', :variables => {:secret => 'two' } %>} after <%= @secret %>") expect(output).to eq("before {super secret is two} after one") @@ -206,7 +206,7 @@ describe Chef::Mixin::Template, "render_template" do def render_template_from_string end end - ['node', 'render', 'render_template', 'render_template_from_string'].each do |method_name| + ["node", "render", "render_template", "render_template_from_string"].each do |method_name| expect(Chef::Log).to receive(:warn).with(/^Core template method `#{method_name}' overridden by extension module/) end @template_context._extend_modules([mod]) diff --git a/spec/unit/mixin/unformatter_spec.rb b/spec/unit/mixin/unformatter_spec.rb index 2eae0ac9bb..c63ed62b8d 100644 --- a/spec/unit/mixin/unformatter_spec.rb +++ b/spec/unit/mixin/unformatter_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/unformatter' +require "spec_helper" +require "chef/mixin/unformatter" class Chef::UnformatterTest include Chef::Mixin::Unformatter diff --git a/spec/unit/mixin/uris_spec.rb b/spec/unit/mixin/uris_spec.rb index d4985c4f67..7012ecd861 100644 --- a/spec/unit/mixin/uris_spec.rb +++ b/spec/unit/mixin/uris_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/uris' +require "spec_helper" +require "chef/mixin/uris" class Chef::UrisTest include Chef::Mixin::Uris @@ -28,19 +28,19 @@ describe Chef::Mixin::Uris do describe "#uri_scheme?" do it "matches 'scheme://foo.com'" do - expect(uris.uri_scheme?('scheme://foo.com')).to eq(true) + expect(uris.uri_scheme?("scheme://foo.com")).to eq(true) end it "does not match 'c:/foo.com'" do - expect(uris.uri_scheme?('c:/foo.com')).to eq(false) + expect(uris.uri_scheme?("c:/foo.com")).to eq(false) end it "does not match '/usr/bin/foo.com'" do - expect(uris.uri_scheme?('/usr/bin/foo.com')).to eq(false) + expect(uris.uri_scheme?("/usr/bin/foo.com")).to eq(false) end it "does not match 'c:/foo.com://bar.com'" do - expect(uris.uri_scheme?('c:/foo.com://bar.com')).to eq(false) + expect(uris.uri_scheme?("c:/foo.com://bar.com")).to eq(false) end end diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb index 55eca28dc2..58e1927ea7 100644 --- a/spec/unit/mixin/windows_architecture_helper_spec.rb +++ b/spec/unit/mixin/windows_architecture_helper_spec.rb @@ -17,8 +17,8 @@ # -require 'spec_helper' -require 'chef/mixin/windows_architecture_helper' +require "spec_helper" +require "chef/mixin/windows_architecture_helper" diff --git a/spec/unit/mixin/xml_escape_spec.rb b/spec/unit/mixin/xml_escape_spec.rb index c5156cfb7b..a3f4bc839e 100644 --- a/spec/unit/mixin/xml_escape_spec.rb +++ b/spec/unit/mixin/xml_escape_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class XMLEscapingTestHarness include Chef::Mixin::XMLEscape diff --git a/spec/unit/monkey_patches/uri_spec.rb b/spec/unit/monkey_patches/uri_spec.rb index 9aca1fc9f1..e8ff1a3592 100644 --- a/spec/unit/monkey_patches/uri_spec.rb +++ b/spec/unit/monkey_patches/uri_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe URI do describe "when a URI contains an IPv6 literal" do diff --git a/spec/unit/monologger_spec.rb b/spec/unit/monologger_spec.rb index 8689ea0aaa..92381afffd 100644 --- a/spec/unit/monologger_spec.rb +++ b/spec/unit/monologger_spec.rb @@ -15,9 +15,9 @@ # limitations under the License. # -require 'chef/monologger' -require 'tempfile' -require 'spec_helper' +require "chef/monologger" +require "tempfile" +require "spec_helper" describe MonoLogger do it "should disable buffering when passed an IO stream" do diff --git a/spec/unit/node/attribute_spec.rb b/spec/unit/node/attribute_spec.rb index 9956ef1ec9..dfa6f33122 100644 --- a/spec/unit/node/attribute_spec.rb +++ b/spec/unit/node/attribute_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/node/attribute' +require "spec_helper" +require "chef/node/attribute" describe Chef::Node::Attribute do before(:each) do @@ -488,31 +488,31 @@ describe Chef::Node::Attribute do end it "should create a deep copy of the node attribute" do - @attributes.default['foo']['bar']['baz'] = 'fizz' - hash = @attributes['foo'].to_hash + @attributes.default["foo"]["bar"]["baz"] = "fizz" + hash = @attributes["foo"].to_hash expect(hash).to eql({"bar"=>{"baz"=>"fizz"}}) - hash['bar']['baz'] = 'buzz' + hash["bar"]["baz"] = "buzz" expect(hash).to eql({"bar"=>{"baz"=>"buzz"}}) - expect(@attributes.default['foo']).to eql({"bar"=>{"baz"=>"fizz"}}) + expect(@attributes.default["foo"]).to eql({"bar"=>{"baz"=>"fizz"}}) end it "should create a deep copy of arrays in the node attribute" do - @attributes.default['foo']['bar'] = ['fizz'] - hash = @attributes['foo'].to_hash - expect(hash).to eql({"bar"=>[ 'fizz' ]}) - hash['bar'].push('buzz') - expect(hash).to eql({"bar"=>[ 'fizz', 'buzz' ]}) - expect(@attributes.default['foo']).to eql({"bar"=>[ 'fizz' ]}) + @attributes.default["foo"]["bar"] = ["fizz"] + hash = @attributes["foo"].to_hash + expect(hash).to eql({"bar"=>[ "fizz" ]}) + hash["bar"].push("buzz") + expect(hash).to eql({"bar"=>[ "fizz", "buzz" ]}) + expect(@attributes.default["foo"]).to eql({"bar"=>[ "fizz" ]}) end it "mutating strings should not mutate the attributes" do pending "this is a bug that should be fixed" - @attributes.default['foo']['bar']['baz'] = 'fizz' - hash = @attributes['foo'].to_hash + @attributes.default["foo"]["bar"]["baz"] = "fizz" + hash = @attributes["foo"].to_hash expect(hash).to eql({"bar"=>{"baz"=>"fizz"}}) - hash['bar']['baz'] << 'buzz' + hash["bar"]["baz"] << "buzz" expect(hash).to eql({"bar"=>{"baz"=>"fizzbuzz"}}) - expect(@attributes.default['foo']).to eql({"bar"=>{"baz"=>"fizz"}}) + expect(@attributes.default["foo"]).to eql({"bar"=>{"baz"=>"fizz"}}) end end diff --git a/spec/unit/node/immutable_collections_spec.rb b/spec/unit/node/immutable_collections_spec.rb index 73165c1fba..07176beb76 100644 --- a/spec/unit/node/immutable_collections_spec.rb +++ b/spec/unit/node/immutable_collections_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" require "chef/node/immutable_collections" describe Chef::Node::ImmutableMash do @@ -64,19 +64,19 @@ describe Chef::Node::ImmutableMash do end it "converts an immutable nested mash to a new mutable hash" do - expect(@copy['top_level_4']['level2']).to be_instance_of(Hash) + expect(@copy["top_level_4"]["level2"]).to be_instance_of(Hash) end it "converts an immutable nested array to a new mutable array" do - expect(@copy['top_level_2']).to be_instance_of(Array) + expect(@copy["top_level_2"]).to be_instance_of(Array) end it "should create a mash with the same content" do expect(@copy).to eq(@immutable_mash) end - it 'should allow mutation' do - expect { @copy['m'] = 'm' }.not_to raise_error + it "should allow mutation" do + expect { @copy["m"] = "m" }.not_to raise_error end end @@ -113,7 +113,7 @@ describe Chef::Node::ImmutableArray do before do @immutable_array = Chef::Node::ImmutableArray.new(%w[foo bar baz] + Array(1..3) + [nil, true, false, [ "el", 0, nil ] ]) - immutable_mash = Chef::Node::ImmutableMash.new({:m => 'm'}) + immutable_mash = Chef::Node::ImmutableMash.new({:m => "m"}) @immutable_nested_array = Chef::Node::ImmutableArray.new(["level1",@immutable_array, immutable_mash]) end @@ -189,8 +189,8 @@ describe Chef::Node::ImmutableArray do expect(@copy).to eq(@immutable_nested_array) end - it 'should allow mutation' do - expect { @copy << 'm' }.not_to raise_error + it "should allow mutation" do + expect { @copy << "m" }.not_to raise_error end end diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb index 7b37ea59f4..ec7c042e4e 100644 --- a/spec/unit/node_map_spec.rb +++ b/spec/unit/node_map_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/node_map' +require "spec_helper" +require "chef/node_map" describe Chef::NodeMap do @@ -27,7 +27,7 @@ describe Chef::NodeMap do describe "with a bad filter name" do it "should raise an error" do - expect{ node_map.set(node, :thing, on_platform_family: 'rhel') }.to raise_error + expect{ node_map.set(node, :thing, on_platform_family: "rhel") }.to raise_error end end @@ -156,7 +156,7 @@ describe Chef::NodeMap do expect(node_map.get(node, :chef_gem)).to eql(:foo) end it "should handle :on_platforms => [ 'windows' ]" do - node_map.set(:dsc_script, :foo, :on_platforms => [ 'windows' ]) + node_map.set(:dsc_script, :foo, :on_platforms => [ "windows" ]) allow(node).to receive(:[]).with(:platform).and_return("windows") expect(node_map.get(node, :dsc_script)).to eql(:foo) end diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb index 39ef684f31..dcee5f8eb5 100644 --- a/spec/unit/node_spec.rb +++ b/spec/unit/node_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Node do @@ -27,32 +27,32 @@ describe Chef::Node do it_behaves_like "a platform introspector" it "creates a node and assigns it a name" do - node = Chef::Node.build('solo-node') - expect(node.name).to eq('solo-node') + node = Chef::Node.build("solo-node") + expect(node.name).to eq("solo-node") end it "should validate the name of the node" do - expect{Chef::Node.build('solo node')}.to raise_error(Chef::Exceptions::ValidationFailed) + expect{Chef::Node.build("solo node")}.to raise_error(Chef::Exceptions::ValidationFailed) end it "should be sortable" do - n1 = Chef::Node.build('alpha') - n2 = Chef::Node.build('beta') - n3 = Chef::Node.build('omega') + n1 = Chef::Node.build("alpha") + n2 = Chef::Node.build("beta") + n3 = Chef::Node.build("omega") expect([n3, n1, n2].sort).to eq([n1, n2, n3]) end it "should share identity only with others of the same name" do - n1 = Chef::Node.build('foo') - n2 = Chef::Node.build('foo') - n3 = Chef::Node.build('bar') + n1 = Chef::Node.build("foo") + n2 = Chef::Node.build("foo") + n3 = Chef::Node.build("bar") expect(n1).to eq(n2) expect(n1).not_to eq(n3) end describe "when the node does not exist on the server" do before do - response = OpenStruct.new(:code => '404') + response = OpenStruct.new(:code => "404") exception = Net::HTTPServerException.new("404 not found", response) allow(Chef::Node).to receive(:load).and_raise(exception) node.name("created-node") @@ -62,19 +62,19 @@ describe Chef::Node do allow(Chef::Node).to receive(:new).and_return(node) expect(node).to receive(:create).and_return(node) node = Chef::Node.find_or_create("created-node") - expect(node.name).to eq('created-node') + expect(node.name).to eq("created-node") expect(node).to equal(node) end end describe "when the node exists on the server" do before do - node.name('existing-node') + node.name("existing-node") allow(Chef::Node).to receive(:load).and_return(node) end it "loads the node via the REST API for find_or_create" do - expect(Chef::Node.find_or_create('existing-node')).to equal(node) + expect(Chef::Node.find_or_create("existing-node")).to equal(node) end end @@ -88,7 +88,7 @@ describe Chef::Node do describe "initialize" do it "should default to the '_default' chef_environment" do n = Chef::Node.new - expect(n.chef_environment).to eq('_default') + expect(n.chef_environment).to eq("_default") end end @@ -147,7 +147,7 @@ describe Chef::Node do end it "allows policy_name with every valid character" do - expect { node.policy_name = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:.' }.to_not raise_error + expect { node.policy_name = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:." }.to_not raise_error end it "sets policy_name when given an argument" do @@ -183,7 +183,7 @@ describe Chef::Node do end it "allows policy_group with every valid character" do - expect { node.policy_group = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:.' }.to_not raise_error + expect { node.policy_group = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqurstuvwxyz0123456789-_:." }.to_not raise_error end it "sets an environment with chef_environment(something)" do @@ -291,9 +291,9 @@ describe Chef::Node do end it "should let you use tag as a convience method for the tags attribute" do - node.normal['tags'] = ['one', 'two'] - node.tag('three', 'four') - expect(node['tags']).to eq(['one', 'two', 'three', 'four']) + node.normal["tags"] = ["one", "two"] + node.tag("three", "four") + expect(node["tags"]).to eq(["one", "two", "three", "four"]) end end @@ -706,25 +706,25 @@ describe Chef::Node do # describe "deep merge attribute cache edge conditions" do it "does not error with complicated attribute substitution" do - node.default['chef_attribute_hell']['attr1'] = "attribute1" - node.default['chef_attribute_hell']['attr2'] = "#{node.chef_attribute_hell.attr1}/attr2" - expect { node.default['chef_attribute_hell']['attr3'] = "#{node.chef_attribute_hell.attr2}/attr3" }.not_to raise_error + node.default["chef_attribute_hell"]["attr1"] = "attribute1" + node.default["chef_attribute_hell"]["attr2"] = "#{node.chef_attribute_hell.attr1}/attr2" + expect { node.default["chef_attribute_hell"]["attr3"] = "#{node.chef_attribute_hell.attr2}/attr3" }.not_to raise_error end it "caches both strings and symbols correctly" do - node.force_default[:solr][:version] = '4.10.2' + node.force_default[:solr][:version] = "4.10.2" node.force_default[:solr][:data_dir] = "/opt/solr-#{node['solr'][:version]}/example/solr" node.force_default[:solr][:xms] = "512M" expect(node[:solr][:xms]).to eql("512M") - expect(node['solr'][:xms]).to eql("512M") + expect(node["solr"][:xms]).to eql("512M") end it "method interpolation syntax also works" do - node.default['passenger']['version'] = '4.0.57' - node.default['passenger']['root_path'] = "passenger-#{node['passenger']['version']}" - node.default['passenger']['root_path_2'] = "passenger-#{node.passenger['version']}" - expect(node['passenger']['root_path_2']).to eql("passenger-4.0.57") - expect(node[:passenger]['root_path_2']).to eql("passenger-4.0.57") + node.default["passenger"]["version"] = "4.0.57" + node.default["passenger"]["root_path"] = "passenger-#{node['passenger']['version']}" + node.default["passenger"]["root_path_2"] = "passenger-#{node.passenger['version']}" + expect(node["passenger"]["root_path_2"]).to eql("passenger-4.0.57") + expect(node[:passenger]["root_path_2"]).to eql("passenger-4.0.57") end end @@ -749,7 +749,7 @@ describe Chef::Node do describe "consuming json" do before do - @ohai_data = {:platform => 'foo', :platform_version => 'bar'} + @ohai_data = {:platform => "foo", :platform_version => "bar"} end it "consumes the run list portion of a collection of attributes and returns the remainder" do @@ -762,7 +762,7 @@ describe Chef::Node do attrs = { "chef_environment" => "foo_environment", "bar" => "baz" } expect(node.consume_chef_environment(attrs)).to eq({ "bar" => "baz" }) expect(node.chef_environment).to eq("foo_environment") - expect(node['chef_environment']).to be nil + expect(node["chef_environment"]).to be nil end it "should overwrites the run list with the run list it consumes" do @@ -805,7 +805,7 @@ describe Chef::Node do end it "should set the tags attribute to an empty array if it is nil" do - node.attributes.normal = { 'tags' => nil } + node.attributes.normal = { "tags" => nil } node.consume_external_attrs(@ohai_data, {}) expect(node.tags).to eql([]) end @@ -841,22 +841,22 @@ describe Chef::Node do describe "preparing for a chef client run" do before do - @ohai_data = {:platform => 'foobuntu', :platform_version => '23.42'} + @ohai_data = {:platform => "foobuntu", :platform_version => "23.42"} end it "sets its platform according to platform detection" do node.consume_external_attrs(@ohai_data, {}) - expect(node.automatic_attrs[:platform]).to eq('foobuntu') - expect(node.automatic_attrs[:platform_version]).to eq('23.42') + expect(node.automatic_attrs[:platform]).to eq("foobuntu") + expect(node.automatic_attrs[:platform_version]).to eq("23.42") end it "consumes the run list from provided json attributes" do - node.consume_external_attrs(@ohai_data, {"run_list" => ['recipe[unicorn]']}) - expect(node.run_list).to eq(['recipe[unicorn]']) + node.consume_external_attrs(@ohai_data, {"run_list" => ["recipe[unicorn]"]}) + expect(node.run_list).to eq(["recipe[unicorn]"]) end it "saves non-runlist json attrs for later" do - expansion = Chef::RunList::RunListExpansion.new('_default', []) + expansion = Chef::RunList::RunListExpansion.new("_default", []) allow(node.run_list).to receive(:expand).and_return(expansion) node.consume_external_attrs(@ohai_data, {"foo" => "bar"}) node.expand! @@ -868,7 +868,7 @@ describe Chef::Node do describe "when expanding its run list and merging attributes" do before do @environment = Chef::Environment.new.tap do |e| - e.name('rspec_env') + e.name("rspec_env") e.default_attributes("env default key" => "env default value") e.override_attributes("env override key" => "env override value") end @@ -879,15 +879,15 @@ describe Chef::Node do end it "sets the 'recipes' automatic attribute to the recipes in the expanded run_list" do - @expansion.recipes << 'recipe[chef::client]' << 'recipe[nginx::default]' + @expansion.recipes << "recipe[chef::client]" << "recipe[nginx::default]" node.expand! - expect(node.automatic_attrs[:recipes]).to eq(['recipe[chef::client]', 'recipe[nginx::default]']) + expect(node.automatic_attrs[:recipes]).to eq(["recipe[chef::client]", "recipe[nginx::default]"]) end it "sets the 'roles' automatic attribute to the expanded role list" do - @expansion.instance_variable_set(:@applied_roles, {'arf' => nil, 'countersnark' => nil}) + @expansion.instance_variable_set(:@applied_roles, {"arf" => nil, "countersnark" => nil}) node.expand! - expect(node.automatic_attrs[:roles].sort).to eq(['arf', 'countersnark']) + expect(node.automatic_attrs[:roles].sort).to eq(["arf", "countersnark"]) end it "applies default attributes from the environment as environment defaults" do @@ -1152,7 +1152,7 @@ describe Chef::Node do expect(h["chef_environment"]).to eq("dev") end - it 'should return an empty array for empty run_list' do + it "should return an empty array for empty run_list" do expect(node.to_hash["run_list"]).to eq([]) end end @@ -1170,11 +1170,11 @@ describe Chef::Node do expect(json).to match(/run_list/) end - it 'should serialize valid json with a run list', :json => true do + it "should serialize valid json with a run list", :json => true do #This test came about because activesupport mucks with Chef json serialization #Test should pass with and without Activesupport - node.run_list << {"type" => "role", "name" => 'Cthulu'} - node.run_list << {"type" => "role", "name" => 'Hastur'} + node.run_list << {"type" => "role", "name" => "Cthulu"} + node.run_list << {"type" => "role", "name" => "Hastur"} json = Chef::JSONCompat.to_json(node) expect(json).to match(/\"run_list\":\[\"role\[Cthulu\]\",\"role\[Hastur\]\"\]/) end diff --git a/spec/unit/org_spec.rb b/spec/unit/org_spec.rb index 97e1b87704..cc5c9b45b7 100644 --- a/spec/unit/org_spec.rb +++ b/spec/unit/org_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/org' -require 'tempfile' +require "chef/org" +require "tempfile" describe Chef::Org do let(:org) { Chef::Org.new("an_org") } @@ -135,7 +135,7 @@ describe Chef::Org do describe "API Interactions" do let(:rest) do Chef::Config[:chef_server_root] = "http://www.example.com" - r = double('rest') + r = double("rest") allow(Chef::ServerAPI).to receive(:new).and_return(r) r end diff --git a/spec/unit/platform/query_helpers_spec.rb b/spec/unit/platform/query_helpers_spec.rb index d18b6f7902..3905b15071 100644 --- a/spec/unit/platform/query_helpers_spec.rb +++ b/spec/unit/platform/query_helpers_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe "Chef::Platform#windows_server_2003?" do it "returns false early when not on windows" do @@ -51,8 +51,8 @@ describe "Chef::Platform#windows_nano_server?" do end after do - Win32::Registry.send(:remove_const, 'HKEY_LOCAL_MACHINE') if defined?(Win32::Registry::HKEY_LOCAL_MACHINE) - Win32::Registry.send(:remove_const, 'KEY_QUERY_VALUE') if defined?(Win32::Registry::KEY_QUERY_VALUE) + Win32::Registry.send(:remove_const, "HKEY_LOCAL_MACHINE") if defined?(Win32::Registry::HKEY_LOCAL_MACHINE) + Win32::Registry.send(:remove_const, "KEY_QUERY_VALUE") if defined?(Win32::Registry::KEY_QUERY_VALUE) end it "returns false early when not on windows" do @@ -63,7 +63,7 @@ describe "Chef::Platform#windows_nano_server?" do it "returns true when the registry value is 1" do allow(ChefConfig).to receive(:windows?).and_return(true) - allow(Chef::Platform).to receive(:require).with('win32/registry') + allow(Chef::Platform).to receive(:require).with("win32/registry") expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open). with(key, access). and_yield(registry) @@ -73,7 +73,7 @@ describe "Chef::Platform#windows_nano_server?" do it "returns false when the registry value is not 1" do allow(ChefConfig).to receive(:windows?).and_return(true) - allow(Chef::Platform).to receive(:require).with('win32/registry') + allow(Chef::Platform).to receive(:require).with("win32/registry") expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open). with(key, access). and_yield(registry) @@ -83,7 +83,7 @@ describe "Chef::Platform#windows_nano_server?" do it "returns false when the registry value does not exist" do allow(ChefConfig).to receive(:windows?).and_return(true) - allow(Chef::Platform).to receive(:require).with('win32/registry') + allow(Chef::Platform).to receive(:require).with("win32/registry") expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open). with(key, access). and_yield(registry) @@ -94,7 +94,7 @@ describe "Chef::Platform#windows_nano_server?" do it "returns false when the registry key does not exist" do allow(ChefConfig).to receive(:windows?).and_return(true) - allow(Chef::Platform).to receive(:require).with('win32/registry') + allow(Chef::Platform).to receive(:require).with("win32/registry") expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open). with(key, access). and_raise(Win32::Registry::Error, "The system cannot find the file specified.") @@ -122,8 +122,8 @@ describe "Chef::Platform#supports_msi?" do end after do - Win32::Registry.send(:remove_const, 'HKEY_LOCAL_MACHINE') if defined?(Win32::Registry::HKEY_LOCAL_MACHINE) - Win32::Registry.send(:remove_const, 'KEY_QUERY_VALUE') if defined?(Win32::Registry::KEY_QUERY_VALUE) + Win32::Registry.send(:remove_const, "HKEY_LOCAL_MACHINE") if defined?(Win32::Registry::HKEY_LOCAL_MACHINE) + Win32::Registry.send(:remove_const, "KEY_QUERY_VALUE") if defined?(Win32::Registry::KEY_QUERY_VALUE) end it "returns false early when not on windows" do @@ -134,7 +134,7 @@ describe "Chef::Platform#supports_msi?" do it "returns true when the registry key exists" do allow(ChefConfig).to receive(:windows?).and_return(true) - allow(Chef::Platform).to receive(:require).with('win32/registry') + allow(Chef::Platform).to receive(:require).with("win32/registry") expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open). with(key, access). and_yield(registry) @@ -143,7 +143,7 @@ describe "Chef::Platform#supports_msi?" do it "returns false when the registry key does not exist" do allow(ChefConfig).to receive(:windows?).and_return(true) - allow(Chef::Platform).to receive(:require).with('win32/registry') + allow(Chef::Platform).to receive(:require).with("win32/registry") expect(Win32::Registry::HKEY_LOCAL_MACHINE).to receive(:open). with(key, access). and_raise(Win32::Registry::Error, "The system cannot find the file specified.") @@ -152,12 +152,12 @@ describe "Chef::Platform#supports_msi?" do end describe 'Chef::Platform#supports_dsc?' do - it 'returns false if powershell is not present' do + it "returns false if powershell is not present" do node = Chef::Node.new expect(Chef::Platform.supports_dsc?(node)).to be_falsey end - ['1.0', '2.0', '3.0'].each do |version| + ["1.0", "2.0", "3.0"].each do |version| it "returns false for Powershell #{version}" do node = Chef::Node.new node.automatic[:languages][:powershell][:version] = version @@ -165,7 +165,7 @@ describe 'Chef::Platform#supports_dsc?' do end end - ['4.0', '5.0'].each do |version| + ["4.0", "5.0"].each do |version| it "returns true for Powershell #{version}" do node = Chef::Node.new node.automatic[:languages][:powershell][:version] = version @@ -175,12 +175,12 @@ describe 'Chef::Platform#supports_dsc?' do end describe 'Chef::Platform#supports_dsc_invoke_resource?' do - it 'returns false if powershell is not present' do + it "returns false if powershell is not present" do node = Chef::Node.new expect(Chef::Platform.supports_dsc_invoke_resource?(node)).to be_falsey end - ['1.0', '2.0', '3.0', '4.0', '5.0.10017.9'].each do |version| + ["1.0", "2.0", "3.0", "4.0", "5.0.10017.9"].each do |version| it "returns false for Powershell #{version}" do node = Chef::Node.new node.automatic[:languages][:powershell][:version] = version @@ -196,16 +196,16 @@ describe 'Chef::Platform#supports_dsc_invoke_resource?' do end describe 'Chef::Platform#dsc_refresh_mode_disabled?' do - let(:node) { instance_double('Chef::Node') } - let(:cmdlet) { instance_double('Chef::Util::Powershell::Cmdlet') } - let(:cmdlet_result) { instance_double('Chef::Util::Powershell::CmdletResult')} + let(:node) { instance_double("Chef::Node") } + let(:cmdlet) { instance_double("Chef::Util::Powershell::Cmdlet") } + let(:cmdlet_result) { instance_double("Chef::Util::Powershell::CmdletResult")} it "returns true when RefreshMode is Disabled" do expect(Chef::Util::Powershell::Cmdlet).to receive(:new). with(node, "Get-DscLocalConfigurationManager", :object). and_return(cmdlet) expect(cmdlet).to receive(:run!).and_return(cmdlet_result) - expect(cmdlet_result).to receive(:return_value).and_return({ 'RefreshMode' => 'Disabled' }) + expect(cmdlet_result).to receive(:return_value).and_return({ "RefreshMode" => "Disabled" }) expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be true end @@ -214,7 +214,7 @@ describe 'Chef::Platform#dsc_refresh_mode_disabled?' do with(node, "Get-DscLocalConfigurationManager", :object). and_return(cmdlet) expect(cmdlet).to receive(:run!).and_return(cmdlet_result) - expect(cmdlet_result).to receive(:return_value).and_return({ 'RefreshMode' => 'LaLaLa' }) + expect(cmdlet_result).to receive(:return_value).and_return({ "RefreshMode" => "LaLaLa" }) expect(Chef::Platform.dsc_refresh_mode_disabled?(node)).to be false end end diff --git a/spec/unit/platform_spec.rb b/spec/unit/platform_spec.rb index d16294a8aa..9785108124 100644 --- a/spec/unit/platform_spec.rb +++ b/spec/unit/platform_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Platform do @@ -175,7 +175,7 @@ describe Chef::Platform do end it "does not support finding a provider by resource and node -- a run context is required" do - expect {Chef::Platform.provider_for_node('node', 'resource')}.to raise_error(NotImplementedError) + expect {Chef::Platform.provider_for_node("node", "resource")}.to raise_error(NotImplementedError) end it "should update the provider map with map" do diff --git a/spec/unit/policy_builder/dynamic_spec.rb b/spec/unit/policy_builder/dynamic_spec.rb index aff19f4d11..dd819e59b1 100644 --- a/spec/unit/policy_builder/dynamic_spec.rb +++ b/spec/unit/policy_builder/dynamic_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/policy_builder' +require "spec_helper" +require "chef/policy_builder" describe Chef::PolicyBuilder::Dynamic do diff --git a/spec/unit/policy_builder/expand_node_object_spec.rb b/spec/unit/policy_builder/expand_node_object_spec.rb index 944d4d3387..824e17091b 100644 --- a/spec/unit/policy_builder/expand_node_object_spec.rb +++ b/spec/unit/policy_builder/expand_node_object_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/policy_builder' +require "spec_helper" +require "chef/policy_builder" describe Chef::PolicyBuilder::ExpandNodeObject do diff --git a/spec/unit/policy_builder/policyfile_spec.rb b/spec/unit/policy_builder/policyfile_spec.rb index 98515a4102..8900bc27c4 100644 --- a/spec/unit/policy_builder/policyfile_spec.rb +++ b/spec/unit/policy_builder/policyfile_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/policy_builder' +require "spec_helper" +require "chef/policy_builder" describe Chef::PolicyBuilder::Policyfile do diff --git a/spec/unit/policy_builder_spec.rb b/spec/unit/policy_builder_spec.rb index 506911452c..01a507a8f4 100644 --- a/spec/unit/policy_builder_spec.rb +++ b/spec/unit/policy_builder_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/policy_builder' +require "spec_helper" +require "chef/policy_builder" describe Chef::PolicyBuilder do diff --git a/spec/unit/property/state_spec.rb b/spec/unit/property/state_spec.rb index 032b0aba52..3dce632570 100644 --- a/spec/unit/property/state_spec.rb +++ b/spec/unit/property/state_spec.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" describe "Chef::Resource#identity and #state" do include IntegrationSupport @@ -26,7 +26,7 @@ describe "Chef::Resource#identity and #state" do end def self.english_join(values) - return '<nothing>' if values.size == 0 + return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" end @@ -55,8 +55,8 @@ describe "Chef::Resource#identity and #state" do it "name is the default identity" do expect(resource_class.identity_properties).to eq [ Chef::Resource.properties[:name] ] expect(Chef::Resource.properties[:name].identity?).to be_falsey - expect(resource.name).to eq 'blah' - expect(resource.identity).to eq 'blah' + expect(resource.name).to eq "blah" + expect(resource.identity).to eq "blah" end it "identity_properties :x changes the identity" do @@ -65,11 +65,11 @@ describe "Chef::Resource#identity and #state" do expect(Chef::Resource.properties[:name].identity?).to be_falsey expect(resource_class.properties[:x].identity?).to be_truthy - expect(resource.x 'woo').to eq 'woo' - expect(resource.x).to eq 'woo' + expect(resource.x "woo").to eq "woo" + expect(resource.x).to eq "woo" - expect(resource.name).to eq 'blah' - expect(resource.identity).to eq 'woo' + expect(resource.name).to eq "blah" + expect(resource.identity).to eq "woo" end with_property ":y, identity: true" do @@ -81,19 +81,19 @@ describe "Chef::Resource#identity and #state" do end it "only returns :x as identity" do - resource.x 'foo' - resource.y 'bar' + resource.x "foo" + resource.y "bar" expect(resource_class.identity_properties).to eq [ resource_class.properties[:x] ] - expect(resource.identity).to eq 'foo' + expect(resource.identity).to eq "foo" end it "does not flip y.desired_state off" do - resource.x 'foo' - resource.y 'bar' + resource.x "foo" + resource.y "bar" expect(resource_class.state_properties).to eq [ resource_class.properties[:x], resource_class.properties[:y], ] - expect(resource.state_for_resource_reporter).to eq(x: 'foo', y: 'bar') + expect(resource.state_for_resource_reporter).to eq(x: "foo", y: "bar") end end end @@ -106,14 +106,14 @@ describe "Chef::Resource#identity and #state" do end end let(:subresource) do - subresource_class.new('sub') + subresource_class.new("sub") end it "name is the default identity on the subclass" do expect(subresource_class.identity_properties).to eq [ Chef::Resource.properties[:name] ] expect(Chef::Resource.properties[:name].identity?).to be_falsey - expect(subresource.name).to eq 'sub' - expect(subresource.identity).to eq 'sub' + expect(subresource.name).to eq "sub" + expect(subresource.identity).to eq "sub" end context "With identity_properties :x on the superclass" do @@ -128,8 +128,8 @@ describe "Chef::Resource#identity and #state" do expect(Chef::Resource.properties[:name].identity?).to be_falsey expect(subresource_class.properties[:x].identity?).to be_truthy - subresource.x 'foo' - expect(subresource.identity).to eq 'foo' + subresource.x "foo" + expect(subresource.identity).to eq "foo" end context "With property :y, identity: true on the subclass" do @@ -143,9 +143,9 @@ describe "Chef::Resource#identity and #state" do subresource_class.properties[:x], subresource_class.properties[:y], ] - subresource.x 'foo' - subresource.y 'bar' - expect(subresource.identity).to eq(x: 'foo', y: 'bar') + subresource.x "foo" + subresource.y "bar" + expect(subresource.identity).to eq(x: "foo", y: "bar") end end @@ -157,9 +157,9 @@ describe "Chef::Resource#identity and #state" do end end it "y is part of state" do - subresource.x 'foo' - subresource.y 'bar' - expect(subresource.state_for_resource_reporter).to eq(x: 'foo', y: 'bar') + subresource.x "foo" + subresource.y "bar" + expect(subresource.state_for_resource_reporter).to eq(x: "foo", y: "bar") expect(subresource_class.state_properties).to eq [ subresource_class.properties[:x], subresource_class.properties[:y], @@ -167,9 +167,9 @@ describe "Chef::Resource#identity and #state" do end it "y is the identity" do expect(subresource_class.identity_properties).to eq [ subresource_class.properties[:y] ] - subresource.x 'foo' - subresource.y 'bar' - expect(subresource.identity).to eq 'bar' + subresource.x "foo" + subresource.y "bar" + expect(subresource.identity).to eq "bar" end it "y still has validation" do expect { subresource.y 12 }.to raise_error Chef::Exceptions::ValidationFailed @@ -191,8 +191,8 @@ describe "Chef::Resource#identity and #state" do with_property ":x, desired_state: false" do it "identity_properties does not change desired_state" do resource_class.identity_properties :x - resource.x 'hi' - expect(resource.identity).to eq 'hi' + resource.x "hi" + expect(resource.identity).to eq "hi" expect(resource_class.properties[:x].desired_state?).to be_falsey expect(resource_class.state_properties).to eq [] expect(resource.state_for_resource_reporter).to eq({}) @@ -247,8 +247,8 @@ describe "Chef::Resource#identity and #state" do with_property ":x, identity: true" do it "name is only part of the identity if an identity attribute is defined" do expect(resource_class.identity_properties).to eq [ resource_class.properties[:x] ] - resource.x 'woo' - expect(resource.identity).to eq 'woo' + resource.x "woo" + expect(resource.identity).to eq "woo" end end @@ -262,29 +262,29 @@ describe "Chef::Resource#identity and #state" do expect { resource_class.identity_attr }.to raise_error Chef::Exceptions::MultipleIdentityError end it "identity returns all identity values in a hash if multiple are defined" do - resource.x 'foo' - resource.y 'bar' - resource.z 'baz' - expect(resource.identity).to eq(x: 'foo', y: 'bar', z: 'baz') + resource.x "foo" + resource.y "bar" + resource.z "baz" + expect(resource.identity).to eq(x: "foo", y: "bar", z: "baz") end it "identity returns all values whether any value is set or not" do - expect(resource.identity).to eq(x: 'xxx', y: 'yyy', z: 'zzz') + expect(resource.identity).to eq(x: "xxx", y: "yyy", z: "zzz") end it "identity_properties wipes out any other identity attributes if multiple are defined" do resource_class.identity_properties :y - resource.x 'foo' - resource.y 'bar' - resource.z 'baz' - expect(resource.identity).to eq 'bar' + resource.x "foo" + resource.y "bar" + resource.z "baz" + expect(resource.identity).to eq "bar" end end with_property ":x, identity: true, name_property: true" do it "identity when x is not defined returns the value of x" do - expect(resource.identity).to eq 'blah' + expect(resource.identity).to eq "blah" end it "state when x is not defined returns the value of x" do - expect(resource.state_for_resource_reporter).to eq(x: 'blah') + expect(resource.state_for_resource_reporter).to eq(x: "blah") end end end @@ -397,7 +397,7 @@ describe "Chef::Resource#identity and #state" do end it "state_properties(:x) does not turn off validation" do resource_class.state_properties(:x) - expect { resource.x 'ouch' }.to raise_error Chef::Exceptions::ValidationFailed + expect { resource.x "ouch" }.to raise_error Chef::Exceptions::ValidationFailed end it "state_properties(:x) does not turn off identity" do resource_class.state_properties(:x) @@ -459,7 +459,7 @@ describe "Chef::Resource#identity and #state" do end end let(:subresource) do - subresource_class.new('blah') + subresource_class.new("blah") end it "state_properties(:x) adds x to desired state" do diff --git a/spec/unit/property/validation_spec.rb b/spec/unit/property/validation_spec.rb index fef983ccf4..7e84a651e2 100644 --- a/spec/unit/property/validation_spec.rb +++ b/spec/unit/property/validation_spec.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" describe "Chef::Resource.property validation" do include IntegrationSupport @@ -49,7 +49,7 @@ describe "Chef::Resource.property validation" do end def self.english_join(values) - return '<nothing>' if values.size == 0 + return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" end @@ -79,7 +79,7 @@ describe "Chef::Resource.property validation" do end success_values.each do |v| it "value #{v.inspect} is valid" do - resource.instance_eval { @x = 'default' } + resource.instance_eval { @x = "default" } expect(resource.x v).to eq v expect(resource.x).to eq v end @@ -87,16 +87,16 @@ describe "Chef::Resource.property validation" do failure_values.each do |v| it "value #{v.inspect} is invalid" do expect { resource.x v }.to raise_error Chef::Exceptions::ValidationFailed - resource.instance_eval { @x = 'default' } + resource.instance_eval { @x = "default" } expect { resource.x v }.to raise_error Chef::Exceptions::ValidationFailed end end getter_values.each do |v| it "setting value to #{v.inspect} does not change the value" do Chef::Config[:treat_deprecation_warnings_as_errors] = false - resource.instance_eval { @x = 'default' } - expect(resource.x v).to eq 'default' - expect(resource.x).to eq 'default' + resource.instance_eval { @x = "default" } + expect(resource.x v).to eq "default" + expect(resource.x).to eq "default" end end end @@ -106,14 +106,14 @@ describe "Chef::Resource.property validation" do with_property ":x, kind_of: String" do context "when the variable already has a value" do before do - resource.instance_eval { @x = 'default' } + resource.instance_eval { @x = "default" } end it "get succeeds" do - expect(resource.x).to eq 'default' + expect(resource.x).to eq "default" end it "set to valid value succeeds" do - expect(resource.x 'str').to eq 'str' - expect(resource.x).to eq 'str' + expect(resource.x "str").to eq "str" + expect(resource.x).to eq "str" end it "set to invalid value raises ValidationFailed" do expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed @@ -121,9 +121,9 @@ describe "Chef::Resource.property validation" do it "set to nil emits a deprecation warning and does a get" do expect { resource.x nil }.to raise_error Chef::Exceptions::DeprecatedFeatureError Chef::Config[:treat_deprecation_warnings_as_errors] = false - resource.x 'str' - expect(resource.x nil).to eq 'str' - expect(resource.x).to eq 'str' + resource.x "str" + expect(resource.x nil).to eq "str" + expect(resource.x).to eq "str" end end context "when the variable does not have an initial value" do @@ -131,8 +131,8 @@ describe "Chef::Resource.property validation" do expect(resource.x).to be_nil end it "set to valid value succeeds" do - expect(resource.x 'str').to eq 'str' - expect(resource.x).to eq 'str' + expect(resource.x "str").to eq "str" + expect(resource.x).to eq "str" end it "set to invalid value raises ValidationFailed" do expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed @@ -145,18 +145,18 @@ describe "Chef::Resource.property validation" do with_property ":x, [ String, nil ]" do context "when the variable already has a value" do before do - resource.instance_eval { @x = 'default' } + resource.instance_eval { @x = "default" } end it "get succeeds" do - expect(resource.x).to eq 'default' + expect(resource.x).to eq "default" end it "set(nil) sets the value" do expect(resource.x nil).to be_nil expect(resource.x).to be_nil end it "set to valid value succeeds" do - expect(resource.x 'str').to eq 'str' - expect(resource.x).to eq 'str' + expect(resource.x "str").to eq "str" + expect(resource.x).to eq "str" end it "set to invalid value raises ValidationFailed" do expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed @@ -171,8 +171,8 @@ describe "Chef::Resource.property validation" do expect(resource.x).to be_nil end it "set to valid value succeeds" do - expect(resource.x 'str').to eq 'str' - expect(resource.x).to eq 'str' + expect(resource.x "str").to eq "str" + expect(resource.x).to eq "str" end it "set to invalid value raises ValidationFailed" do expect { resource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed @@ -183,45 +183,45 @@ describe "Chef::Resource.property validation" do # Bare types context "bare types" do - validation_test 'String', - [ 'hi' ], + validation_test "String", + [ "hi" ], [ 10 ], [ nil ] - validation_test ':a', + validation_test ":a", [ :a ], [ :b ], [ nil ] - validation_test ':a, is: :b', + validation_test ":a, is: :b", [ :a, :b ], [ :c ], [ nil ] - validation_test ':a, is: [ :b, :c ]', + validation_test ":a, is: [ :b, :c ]", [ :a, :b, :c ], [ :d ], [ nil ] - validation_test '[ :a, :b ], is: :c', + validation_test "[ :a, :b ], is: :c", [ :a, :b, :c ], [ :d ], [ nil ] - validation_test '[ :a, :b ], is: [ :c, :d ]', + validation_test "[ :a, :b ], is: [ :c, :d ]", [ :a, :b, :c, :d ], [ :e ], [ nil ] - validation_test 'nil', + validation_test "nil", [ nil ], [ :a ] - validation_test '[ nil ]', + validation_test "[ nil ]", [ nil ], [ :a ] - validation_test '[]', + validation_test "[]", [], [ :a ], [ nil ] @@ -230,35 +230,35 @@ describe "Chef::Resource.property validation" do # is context "is" do # Class - validation_test 'is: String', - [ 'a', '' ], + validation_test "is: String", + [ "a", "" ], [ :a, 1 ], [ nil ] # Value - validation_test 'is: :a', + validation_test "is: :a", [ :a ], [ :b ], [ nil ] - validation_test 'is: [ :a, :b ]', + validation_test "is: [ :a, :b ]", [ :a, :b ], [ [ :a, :b ] ], [ nil ] - validation_test 'is: [ [ :a, :b ] ]', + validation_test "is: [ [ :a, :b ] ]", [ [ :a, :b ] ], [ :a, :b ], [ nil ] # Regex - validation_test 'is: /abc/', - [ 'abc', 'wowabcwow' ], - [ '', 'abac' ], + validation_test "is: /abc/", + [ "abc", "wowabcwow" ], + [ "", "abac" ], [ nil ] # Property - validation_test 'is: Chef::Property.new(is: :a)', + validation_test "is: Chef::Property.new(is: :a)", [ :a ], [ :b, nil ] @@ -273,24 +273,24 @@ describe "Chef::Resource.property validation" do [ nil ] # Proc - validation_test 'is: proc { |x| x }', + validation_test "is: proc { |x| x }", [ true, 1 ], [ false ], [ nil ] - validation_test 'is: proc { |x| x > blah }', + validation_test "is: proc { |x| x > blah }", [ 10 ], [ -1 ] - validation_test 'is: nil', + validation_test "is: nil", [ nil ], - [ 'a' ] + [ "a" ] - validation_test 'is: [ String, nil ]', - [ 'a', nil ], + validation_test "is: [ String, nil ]", + [ "a", nil ], [ :b ] - validation_test 'is: []', + validation_test "is: []", [], [ :a ], [ nil ] @@ -299,45 +299,45 @@ describe "Chef::Resource.property validation" do # Combination context "combination" do validation_test 'kind_of: String, equal_to: "a"', - [ 'a' ], - [ 'b' ], + [ "a" ], + [ "b" ], [ nil ] end # equal_to context "equal_to" do # Value - validation_test 'equal_to: :a', + validation_test "equal_to: :a", [ :a ], [ :b ], [ nil ] - validation_test 'equal_to: [ :a, :b ]', + validation_test "equal_to: [ :a, :b ]", [ :a, :b ], [ [ :a, :b ] ], [ nil ] - validation_test 'equal_to: [ [ :a, :b ] ]', + validation_test "equal_to: [ [ :a, :b ] ]", [ [ :a, :b ] ], [ :a, :b ], [ nil ] - validation_test 'equal_to: nil', + validation_test "equal_to: nil", [ ], - [ 'a' ], + [ "a" ], [ nil ] validation_test 'equal_to: [ "a", nil ]', - [ 'a' ], - [ 'b' ], + [ "a" ], + [ "b" ], [ nil ] validation_test 'equal_to: [ nil, "a" ]', - [ 'a' ], - [ 'b' ], + [ "a" ], + [ "b" ], [ nil ] - validation_test 'equal_to: []', + validation_test "equal_to: []", [], [ :a ], [ nil ] @@ -345,37 +345,37 @@ describe "Chef::Resource.property validation" do # kind_of context "kind_of" do - validation_test 'kind_of: String', - [ 'a' ], + validation_test "kind_of: String", + [ "a" ], [ :b ], [ nil ] - validation_test 'kind_of: [ String, Symbol ]', - [ 'a', :b ], + validation_test "kind_of: [ String, Symbol ]", + [ "a", :b ], [ 1 ], [ nil ] - validation_test 'kind_of: [ Symbol, String ]', - [ 'a', :b ], + validation_test "kind_of: [ Symbol, String ]", + [ "a", :b ], [ 1 ], [ nil ] - validation_test 'kind_of: NilClass', + validation_test "kind_of: NilClass", [ ], - [ 'a' ], + [ "a" ], [ nil ] - validation_test 'kind_of: [ NilClass, String ]', - [ 'a' ], + validation_test "kind_of: [ NilClass, String ]", + [ "a" ], [ :a ], [ nil ] - validation_test 'kind_of: []', + validation_test "kind_of: []", [], [ :a ], [ nil ] - validation_test 'kind_of: nil', + validation_test "kind_of: nil", [], [ :a ], [ nil ] @@ -383,32 +383,32 @@ describe "Chef::Resource.property validation" do # regex context "regex" do - validation_test 'regex: /abc/', - [ 'xabcy' ], - [ 'gbh', 123 ], + validation_test "regex: /abc/", + [ "xabcy" ], + [ "gbh", 123 ], [ nil ] - validation_test 'regex: [ /abc/, /z/ ]', - [ 'xabcy', 'aza' ], - [ 'gbh', 123 ], + validation_test "regex: [ /abc/, /z/ ]", + [ "xabcy", "aza" ], + [ "gbh", 123 ], [ nil ] - validation_test 'regex: [ /z/, /abc/ ]', - [ 'xabcy', 'aza' ], - [ 'gbh', 123 ], + validation_test "regex: [ /z/, /abc/ ]", + [ "xabcy", "aza" ], + [ "gbh", 123 ], [ nil ] - validation_test 'regex: [ [ /z/, /abc/ ], [ /n/ ] ]', - [ 'xabcy', 'aza', 'ana' ], - [ 'gbh', 123 ], + validation_test "regex: [ [ /z/, /abc/ ], [ /n/ ] ]", + [ "xabcy", "aza", "ana" ], + [ "gbh", 123 ], [ nil ] - validation_test 'regex: []', + validation_test "regex: []", [], [ :a ], [ nil ] - validation_test 'regex: nil', + validation_test "regex: nil", [], [ :a ], [ nil ] @@ -426,10 +426,10 @@ describe "Chef::Resource.property validation" do validation_test 'callbacks: { "a" => proc { |x| x.nil? } }', [ ], - [ 'a' ], + [ "a" ], [ nil ] - validation_test 'callbacks: {}', + validation_test "callbacks: {}", [ :a ], [], [ nil ] @@ -437,49 +437,49 @@ describe "Chef::Resource.property validation" do # respond_to context "respond_to" do - validation_test 'respond_to: :split', - [ 'hi' ], + validation_test "respond_to: :split", + [ "hi" ], [ 1 ], [ nil ] validation_test 'respond_to: "split"', - [ 'hi' ], + [ "hi" ], [ 1 ], [ nil ] - validation_test 'respond_to: :to_s', + validation_test "respond_to: :to_s", [ :a ], [], [ nil ] - validation_test 'respond_to: [ :split, :to_s ]', - [ 'hi' ], + validation_test "respond_to: [ :split, :to_s ]", + [ "hi" ], [ 1 ], [ nil ] - validation_test 'respond_to: %w(split to_s)', - [ 'hi' ], + validation_test "respond_to: %w(split to_s)", + [ "hi" ], [ 1 ], [ nil ] - validation_test 'respond_to: [ :to_s, :split ]', - [ 'hi' ], + validation_test "respond_to: [ :to_s, :split ]", + [ "hi" ], [ 1 ], [ nil ] - validation_test 'respond_to: []', + validation_test "respond_to: []", [ :a ], [], [ nil ] - validation_test 'respond_to: nil', + validation_test "respond_to: nil", [ :a ], [], [ nil ] end context "cannot_be" do - validation_test 'cannot_be: :empty', + validation_test "cannot_be: :empty", [ 1, [1,2], { a: 10 } ], [ [] ], [ nil ] @@ -489,7 +489,7 @@ describe "Chef::Resource.property validation" do [ [] ], [ nil ] - validation_test 'cannot_be: [ :empty, :nil ]', + validation_test "cannot_be: [ :empty, :nil ]", [ 1, [1,2], { a: 10 } ], [ [] ], [ nil ] @@ -499,22 +499,22 @@ describe "Chef::Resource.property validation" do [ [] ], [ nil ] - validation_test 'cannot_be: [ :nil, :empty ]', + validation_test "cannot_be: [ :nil, :empty ]", [ 1, [1,2], { a: 10 } ], [ [] ], [ nil ] - validation_test 'cannot_be: [ :empty, :nil, :blahblah ]', + validation_test "cannot_be: [ :empty, :nil, :blahblah ]", [ 1, [1,2], { a: 10 } ], [ [] ], [ nil ] - validation_test 'cannot_be: []', + validation_test "cannot_be: []", [ :a ], [], [ nil ] - validation_test 'cannot_be: nil', + validation_test "cannot_be: nil", [ :a ], [], [ nil ] @@ -522,7 +522,7 @@ describe "Chef::Resource.property validation" do end context "required" do - with_property ':x, required: true' do + with_property ":x, required: true" do it "if x is not specified, retrieval fails" do expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed end @@ -545,7 +545,7 @@ describe "Chef::Resource.property validation" do end end - with_property ':x, [String, nil], required: true' do + with_property ":x, [String, nil], required: true" do it "if x is not specified, retrieval fails" do expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed end @@ -554,17 +554,17 @@ describe "Chef::Resource.property validation" do expect(resource.x).to be_nil end it "value '1' is valid" do - expect(resource.x '1').to eq '1' - expect(resource.x).to eq '1' + expect(resource.x "1").to eq "1" + expect(resource.x).to eq "1" end it "value 1 is invalid" do expect { resource.x 1 }.to raise_error Chef::Exceptions::ValidationFailed end end - with_property ':x, name_property: true, required: true' do + with_property ":x, name_property: true, required: true" do it "if x is not specified, the name property is returned" do - expect(resource.x).to eq 'blah' + expect(resource.x).to eq "blah" end it "value 1 is valid" do expect(resource.x 1).to eq 1 @@ -579,7 +579,7 @@ describe "Chef::Resource.property validation" do end end - with_property ':x, default: 10, required: true' do + with_property ":x, default: 10, required: true" do it "if x is not specified, the default is returned" do expect(resource.x).to eq 10 end @@ -602,7 +602,7 @@ describe "Chef::Resource.property validation" do Chef::Config[:treat_deprecation_warnings_as_errors] = false end - with_property ':x, blarghle: 1' do + with_property ":x, blarghle: 1" do context "and a class that implements _pv_blarghle" do before do resource_class.class_eval do @@ -621,7 +621,7 @@ describe "Chef::Resource.property validation" do it "value '1' is invalid" do Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect { resource.x '1' }.to raise_error Chef::Exceptions::ValidationFailed + expect { resource.x "1" }.to raise_error Chef::Exceptions::ValidationFailed end it "value nil does a get" do @@ -633,7 +633,7 @@ describe "Chef::Resource.property validation" do end end - with_property ':x, blarghle: 1' do + with_property ":x, blarghle: 1" do context "and a class that implements _pv_blarghle" do before do resource_class.class_eval do @@ -651,7 +651,7 @@ describe "Chef::Resource.property validation" do end it "value '1' is invalid" do - expect { resource.x '1' }.to raise_error Chef::Exceptions::ValidationFailed + expect { resource.x "1" }.to raise_error Chef::Exceptions::ValidationFailed end it "value nil does a get" do diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb index 095dcc8e98..1fe8abc706 100644 --- a/spec/unit/property_spec.rb +++ b/spec/unit/property_spec.rb @@ -1,4 +1,4 @@ -require 'support/shared/integration/integration_helper' +require "support/shared/integration/integration_helper" describe "Chef::Resource.property" do include IntegrationSupport @@ -46,7 +46,7 @@ describe "Chef::Resource.property" do end def self.english_join(values) - return '<nothing>' if values.size == 0 + return "<nothing>" if values.size == 0 return values[0].inspect if values.size == 1 "#{values[0..-2].map { |v| v.inspect }.join(", ")} and #{values[-1].inspect}" end @@ -74,7 +74,7 @@ describe "Chef::Resource.property" do end # Basic properties - with_property ':bare_property' do + with_property ":bare_property" do it "can be set" do expect(resource.bare_property 10).to eq 10 expect(resource.bare_property).to eq 10 @@ -116,7 +116,7 @@ describe "Chef::Resource.property" do end end let(:subresource) do - subresource_class.new('blah') + subresource_class.new("blah") end context "with property :x on the subclass" do @@ -127,7 +127,7 @@ describe "Chef::Resource.property" do end it "x is still name_property" do - expect(subresource.x).to eq 'blah' + expect(subresource.x).to eq "blah" end end @@ -166,7 +166,7 @@ describe "Chef::Resource.property" do end end let(:subresource) do - subresource_class.new('blah') + subresource_class.new("blah") end it "x is inherited" do @@ -178,7 +178,7 @@ describe "Chef::Resource.property" do end it "x's validation is inherited" do - expect { subresource.x 'ohno' }.to raise_error Chef::Exceptions::ValidationFailed + expect { subresource.x "ohno" }.to raise_error Chef::Exceptions::ValidationFailed end context "with property :y on the subclass" do @@ -225,7 +225,7 @@ describe "Chef::Resource.property" do end it "x's validation is inherited" do - expect { subresource.x 'ohno' }.to raise_error Chef::Exceptions::ValidationFailed + expect { subresource.x "ohno" }.to raise_error Chef::Exceptions::ValidationFailed end end @@ -250,7 +250,7 @@ describe "Chef::Resource.property" do end it "x's validation is inherited" do - expect { subresource.x 'ohno' }.to raise_error Chef::Exceptions::ValidationFailed + expect { subresource.x "ohno" }.to raise_error Chef::Exceptions::ValidationFailed end end @@ -272,12 +272,12 @@ describe "Chef::Resource.property" do it "x's validation is overwritten" do expect { subresource.x 10 }.to raise_error Chef::Exceptions::ValidationFailed - expect(subresource.x 'ohno').to eq 'ohno' - expect(subresource.x).to eq 'ohno' + expect(subresource.x "ohno").to eq "ohno" + expect(subresource.x).to eq "ohno" end it "the superclass's validation for x is still there" do - expect { resource.x 'ohno' }.to raise_error Chef::Exceptions::ValidationFailed + expect { resource.x "ohno" }.to raise_error Chef::Exceptions::ValidationFailed expect(resource.x 10).to eq 10 expect(resource.x).to eq 10 end @@ -297,7 +297,7 @@ describe "Chef::Resource.property" do expect { resource.reset_property(:x) }.to raise_error(ArgumentError) end - with_property ':x' do + with_property ":x" do it "when the resource is newly created, reset_property(:x) does nothing" do expect(resource.property_is_set?(:x)).to be_falsey resource.reset_property(:x) @@ -313,7 +313,7 @@ describe "Chef::Resource.property" do end end - with_property ':x, Integer' do + with_property ":x, Integer" do it "when the resource is newly created, reset_property(:x) does nothing" do expect(resource.property_is_set?(:x)).to be_falsey resource.reset_property(:x) @@ -329,7 +329,7 @@ describe "Chef::Resource.property" do end end - with_property ':x, default: 10' do + with_property ":x, default: 10" do it "when the resource is newly created, reset_property(:x) does nothing" do expect(resource.property_is_set?(:x)).to be_falsey resource.reset_property(:x) @@ -344,7 +344,7 @@ describe "Chef::Resource.property" do end end - with_property ':x, default: lazy { 10 }' do + with_property ":x, default: lazy { 10 }" do it "when the resource is newly created, reset_property(:x) does nothing" do expect(resource.property_is_set?(:x)).to be_falsey resource.reset_property(:x) @@ -369,7 +369,7 @@ describe "Chef::Resource.property" do expect { resource.property_is_set?(:x) }.to raise_error(ArgumentError) end - with_property ':x' do + with_property ":x" do it "when the resource is newly created, property_is_set?(:x) is false" do expect(resource.property_is_set?(:x)).to be_falsey end @@ -391,7 +391,7 @@ describe "Chef::Resource.property" do end end - with_property ':x, default: 10' do + with_property ":x, default: 10" do it "when the resource is newly created, property_is_set?(:x) is false" do expect(resource.property_is_set?(:x)).to be_falsey end @@ -413,7 +413,7 @@ describe "Chef::Resource.property" do end end - with_property ':x, default: nil' do + with_property ":x, default: nil" do it "when the resource is newly created, property_is_set?(:x) is false" do expect(resource.property_is_set?(:x)).to be_falsey end @@ -435,7 +435,7 @@ describe "Chef::Resource.property" do end end - with_property ':x, default: lazy { 10 }' do + with_property ":x, default: lazy { 10 }" do it "when the resource is newly created, property_is_set?(:x) is false" do expect(resource.property_is_set?(:x)).to be_falsey end @@ -455,7 +455,7 @@ describe "Chef::Resource.property" do end context "Chef::Resource::Property#default" do - with_property ':x, default: 10' do + with_property ":x, default: 10" do it "when x is set, it returns its value" do expect(resource.x 20).to eq 20 expect(resource.property_is_set?(:x)).to be_truthy @@ -479,33 +479,33 @@ describe "Chef::Resource.property" do resource_name new_resource_name end end - let(:subresource) { subresource_class.new('blah') } + let(:subresource) { subresource_class.new("blah") } it "The default is inherited" do expect(subresource.x).to eq 10 end end end - with_property ':x, default: 10, identity: true' do + with_property ":x, default: 10, identity: true" do it "when x is not set, it is included in identity" do expect(resource.identity).to eq(10) end end - with_property ':x, default: 1, identity: true', ':y, default: 2, identity: true' do + with_property ":x, default: 1, identity: true", ":y, default: 2, identity: true" do it "when x is not set, it is still included in identity" do resource.y 20 expect(resource.identity).to eq(x: 1, y: 20) end end - with_property ':x, default: nil' do + with_property ":x, default: nil" do it "when x is not set, it returns nil" do expect(resource.x).to be_nil end end - with_property ':x' do + with_property ":x" do it "when x is not set, it returns nil" do expect(resource.x).to be_nil end @@ -515,7 +515,7 @@ describe "Chef::Resource.property" do context "(deprecations allowed)" do before { Chef::Config[:treat_deprecation_warnings_as_errors] = false } - with_property ':x, default: {}' do + with_property ":x, default: {}" do it "when x is not set, it returns {}" do expect(resource.x).to eq({}) end @@ -525,12 +525,12 @@ describe "Chef::Resource.property" do expect(resource.x.object_id).to eq(value.object_id) end it "Multiple instances of x receive the exact same value" do - expect(resource.x.object_id).to eq(resource_class.new('blah2').x.object_id) + expect(resource.x.object_id).to eq(resource_class.new("blah2").x.object_id) end end end - with_property ':x, default: lazy { {} }' do + with_property ":x, default: lazy { {} }" do it "when x is not set, it returns {}" do expect(resource.x).to eq({}) end @@ -540,7 +540,7 @@ describe "Chef::Resource.property" do # expect(resource.x.object_id).not_to eq(value.object_id) # end it "Multiple instances of x receive different values" do - expect(resource.x.object_id).not_to eq(resource_class.new('blah2').x.object_id) + expect(resource.x.object_id).not_to eq(resource_class.new("blah2").x.object_id) end end end @@ -549,7 +549,7 @@ describe "Chef::Resource.property" do before do resource_class.class_eval do def self.blah - 'class' + "class" end def blah "#{name}#{next_index}" @@ -557,13 +557,13 @@ describe "Chef::Resource.property" do end end - with_property ':x, default: lazy { blah }' do + with_property ":x, default: lazy { blah }" do it "x is run in context of the instance" do expect(resource.x).to eq "blah1" end it "x is run in the context of each instance it is run in" do expect(resource.x).to eq "blah1" - expect(resource_class.new('another').x).to eq "another2" + expect(resource_class.new("another").x).to eq "another2" # expect(resource.x).to eq "blah3" end end @@ -574,20 +574,20 @@ describe "Chef::Resource.property" do end it "x is passed the value of each instance it is run in" do expect(resource.x).to eq "classblah1" - expect(resource_class.new('another').x).to eq "classanother2" + expect(resource_class.new("another").x).to eq "classanother2" # expect(resource.x).to eq "classblah3" end end end context "validation of defaults" do - with_property ':x, String, default: 10' do + with_property ":x, String, default: 10" do it "when the resource is created, no error is raised" do resource end it "when x is set, no error is raised" do - expect(resource.x 'hi').to eq 'hi' - expect(resource.x).to eq 'hi' + expect(resource.x "hi").to eq "hi" + expect(resource.x).to eq "hi" end it "when x is retrieved, no validation error is raised" do expect(resource.x).to eq 10 @@ -602,8 +602,8 @@ describe "Chef::Resource.property" do resource end it "when x is set, no error is raised" do - expect(resource.x 'hi').to eq 'hi' - expect(resource.x).to eq 'hi' + expect(resource.x "hi").to eq "hi" + expect(resource.x).to eq "hi" end it "when x is retrieved, no validation error is raised" do expect(resource.x).to eq 1 @@ -617,7 +617,7 @@ describe "Chef::Resource.property" do with_property ":x, default: lazy { Namer.next_index.to_s }, is: proc { |v| Namer.next_index; true }" do it "validation is not run at all on the default value" do - expect(resource.x).to eq '1' + expect(resource.x).to eq "1" expect(Namer.current_index).to eq 1 end # it "validation is run each time" do @@ -630,7 +630,7 @@ describe "Chef::Resource.property" do with_property ":x, default: lazy { Namer.next_index.to_s.freeze }, is: proc { |v| Namer.next_index; true }" do it "validation is not run at all on the default value" do - expect(resource.x).to eq '1' + expect(resource.x).to eq "1" expect(Namer.current_index).to eq 1 end # it "validation is only run the first time" do @@ -650,13 +650,13 @@ describe "Chef::Resource.property" do expect(Namer.current_index).to eq 0 end it "when x is set, coercion is run" do - expect(resource.x 'hi').to eq 'hi1' - expect(resource.x).to eq 'hi1' + expect(resource.x "hi").to eq "hi1" + expect(resource.x).to eq "hi1" expect(Namer.current_index).to eq 1 end it "when x is retrieved, coercion is run exactly once" do - expect(resource.x).to eq '101' - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" + expect(resource.x).to eq "101" expect(Namer.current_index).to eq 1 end end @@ -668,13 +668,13 @@ describe "Chef::Resource.property" do expect(Namer.current_index).to eq 0 end it "when x is set, coercion is run" do - expect(resource.x 'hi').to eq 'hi1' - expect(resource.x).to eq 'hi1' + expect(resource.x "hi").to eq "hi1" + expect(resource.x).to eq "hi1" expect(Namer.current_index).to eq 1 end it "when x is retrieved, coercion is run each time" do - expect(resource.x).to eq '101' - expect(resource.x).to eq '102' + expect(resource.x).to eq "101" + expect(resource.x).to eq "102" expect(Namer.current_index).to eq 2 end end @@ -686,13 +686,13 @@ describe "Chef::Resource.property" do expect(Namer.current_index).to eq 0 end it "when x is set, coercion is run" do - expect(resource.x 'hi').to eq 'hi1' - expect(resource.x).to eq 'hi1' + expect(resource.x "hi").to eq "hi1" + expect(resource.x).to eq "hi1" expect(Namer.current_index).to eq 1 end it "when x is retrieved, coercion is run exactly once" do - expect(resource.x).to eq '101' - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" + expect(resource.x).to eq "101" expect(Namer.current_index).to eq 1 end end @@ -704,13 +704,13 @@ describe "Chef::Resource.property" do expect(Namer.current_index).to eq 0 end it "when x is set, coercion is run" do - expect(resource.x 'hi').to eq 'hi1' - expect(resource.x).to eq 'hi1' + expect(resource.x "hi").to eq "hi1" + expect(resource.x).to eq "hi1" expect(Namer.current_index).to eq 1 end it "when x is retrieved, coercion is run each time" do - expect(resource.x).to eq '101' - expect(resource.x).to eq '102' + expect(resource.x).to eq "101" + expect(resource.x).to eq "102" expect(Namer.current_index).to eq 2 end end @@ -718,9 +718,9 @@ describe "Chef::Resource.property" do with_property ':x, proc { |v| Namer.next_index; true }, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do it "coercion is only run the first time x is retrieved, and validation is not run" do expect(Namer.current_index).to eq 0 - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" expect(Namer.current_index).to eq 1 - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" expect(Namer.current_index).to eq 1 end end @@ -728,12 +728,12 @@ describe "Chef::Resource.property" do context "validation and coercion of defaults" do with_property ':x, String, coerce: proc { |v| "#{v}#{next_index}" }, default: 10' do it "when x is retrieved, it is coerced before validating and passes" do - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" end end with_property ':x, Integer, coerce: proc { |v| "#{v}#{next_index}" }, default: 10' do it "when x is retrieved, it is coerced and not validated" do - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" end # it "when x is retrieved, it is coerced before validating and fails" do # expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed @@ -741,12 +741,12 @@ describe "Chef::Resource.property" do end with_property ':x, String, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do it "when x is retrieved, it is coerced before validating and passes" do - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" end end with_property ':x, Integer, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do it "when x is retrieved, it is coerced and not validated" do - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" end # it "when x is retrieved, it is coerced before validating and fails" do # expect { resource.x }.to raise_error Chef::Exceptions::ValidationFailed @@ -755,9 +755,9 @@ describe "Chef::Resource.property" do with_property ':x, proc { |v| Namer.next_index; true }, coerce: proc { |v| "#{v}#{next_index}" }, default: lazy { 10 }' do it "coercion is only run the first time x is retrieved, and validation is not run" do expect(Namer.current_index).to eq 0 - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" expect(Namer.current_index).to eq 1 - expect(resource.x).to eq '101' + expect(resource.x).to eq "101" expect(Namer.current_index).to eq 1 end end @@ -766,7 +766,7 @@ describe "Chef::Resource.property" do end context "Chef::Resource#lazy" do - with_property ':x' do + with_property ":x" do it "setting x to a lazy value does not run it immediately" do resource.x lazy { Namer.next_index } expect(Namer.current_index).to eq 0 @@ -861,7 +861,7 @@ describe "Chef::Resource.property" do end end - with_property ':x, String' do + with_property ":x, String" do it "lazy values are not validated on set" do resource.x lazy { Namer.next_index } expect(Namer.current_index).to eq 0 @@ -873,7 +873,7 @@ describe "Chef::Resource.property" do end end - with_property ':x, is: proc { |v| Namer.next_index; true }' do + with_property ":x, is: proc { |v| Namer.next_index; true }" do it "lazy values are validated on each access" do resource.x lazy { Namer.next_index } expect(resource.x).to eq 1 @@ -936,7 +936,7 @@ describe "Chef::Resource.property" do expect(Namer.current_index).to eq 2 end end - with_property ':x, coerce: proc { |x| x }' do + with_property ":x, coerce: proc { |x| x }" do it "does not emit a deprecation warning if set to nil" do expect(resource.x nil).to be_nil end @@ -946,19 +946,19 @@ describe "Chef::Resource.property" do resource.x 20 expect(resource.x).to eq 20 expect(Namer.current_index).to eq 2 - expect { resource.x 10 }.to raise_error 'hi' + expect { resource.x 10 }.to raise_error "hi" expect(resource.x).to eq 20 expect(Namer.current_index).to eq 3 end it "validation does not run if coercion fails" do - expect { resource.x 10 }.to raise_error 'hi' + expect { resource.x 10 }.to raise_error "hi" expect(Namer.current_index).to eq 1 end end end context "Chef::Resource::Property validation" do - with_property ':x, is: proc { |v| Namer.next_index; v.is_a?(Integer) }' do + with_property ":x, is: proc { |v| Namer.next_index; v.is_a?(Integer) }" do it "validation runs on set" do expect(resource.x 10).to eq 10 expect(Namer.current_index).to eq 1 @@ -977,31 +977,31 @@ describe "Chef::Resource.property" do it "failed validation fails to set the value" do expect(resource.x 10).to eq 10 expect(Namer.current_index).to eq 1 - expect { resource.x 'blah' }.to raise_error Chef::Exceptions::ValidationFailed + expect { resource.x "blah" }.to raise_error Chef::Exceptions::ValidationFailed expect(resource.x).to eq 10 expect(Namer.current_index).to eq 2 end end end - [ 'name_attribute', 'name_property' ].each do |name| + [ "name_attribute", "name_property" ].each do |name| context "Chef::Resource::Property##{name}" do with_property ":x, #{name}: true" do it "defaults x to resource.name" do - expect(resource.x).to eq 'blah' + expect(resource.x).to eq "blah" end it "does not pick up resource.name if set" do expect(resource.x 10).to eq 10 expect(resource.x).to eq 10 end it "binds to the latest resource.name when run" do - resource.name 'foo' - expect(resource.x).to eq 'foo' + resource.name "foo" + expect(resource.x).to eq "foo" end it "caches resource.name" do - expect(resource.x).to eq 'blah' - resource.name 'foo' - expect(resource.x).to eq 'blah' + expect(resource.x).to eq "blah" + resource.name "foo" + expect(resource.x).to eq "blah" end end @@ -1045,17 +1045,17 @@ describe "Chef::Resource.property" do end with_property ":x, default: nil, #{name}: true" do it "chooses #{name} over default" do - expect(resource.x).to eq 'blah' + expect(resource.x).to eq "blah" end end with_property ":x, #{name}: true, default: 10" do it "chooses #{name} over default" do - expect(resource.x).to eq 'blah' + expect(resource.x).to eq "blah" end end with_property ":x, #{name}: true, default: nil" do it "chooses #{name} over default" do - expect(resource.x).to eq 'blah' + expect(resource.x).to eq "blah" end end end @@ -1117,7 +1117,7 @@ describe "Chef::Resource.property" do end end let(:subresource) do - subresource_class.new('blah') + subresource_class.new("blah") end context "with property :x, default: 10 on the subclass" do diff --git a/spec/unit/provider/breakpoint_spec.rb b/spec/unit/provider/breakpoint_spec.rb index 386e5a1d17..58dc4649c4 100644 --- a/spec/unit/provider/breakpoint_spec.rb +++ b/spec/unit/provider/breakpoint_spec.rb @@ -17,7 +17,7 @@ # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Breakpoint do before do diff --git a/spec/unit/provider/cookbook_file/content_spec.rb b/spec/unit/provider/cookbook_file/content_spec.rb index 6946966153..8c66f3fcc4 100644 --- a/spec/unit/provider/cookbook_file/content_spec.rb +++ b/spec/unit/provider/cookbook_file/content_spec.rb @@ -16,24 +16,24 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::CookbookFile::Content do - let(:new_resource) { double('Chef::Resource::CookbookFile (new)', :cookbook_name => 'apache2', :cookbook => 'apache2') } + let(:new_resource) { double("Chef::Resource::CookbookFile (new)", :cookbook_name => "apache2", :cookbook => "apache2") } let(:content) do - @run_context = double('Chef::RunContext') - @current_resource = double('Chef::Resource::CookbookFile (current)') + @run_context = double("Chef::RunContext") + @current_resource = double("Chef::Resource::CookbookFile (current)") Chef::Provider::CookbookFile::Content.new(new_resource, @current_resource, @run_context) end it "prefers the explicit cookbook name on the resource to the implicit one" do - allow(new_resource).to receive(:cookbook).and_return('nginx') - expect(content.send(:resource_cookbook)).to eq('nginx') + allow(new_resource).to receive(:cookbook).and_return("nginx") + expect(content.send(:resource_cookbook)).to eq("nginx") end it "falls back to the implicit cookbook name on the resource" do - expect(content.send(:resource_cookbook)).to eq('apache2') + expect(content.send(:resource_cookbook)).to eq("apache2") end end diff --git a/spec/unit/provider/cookbook_file_spec.rb b/spec/unit/provider/cookbook_file_spec.rb index a7cbba97cb..bc52cf2f00 100644 --- a/spec/unit/provider/cookbook_file_spec.rb +++ b/spec/unit/provider/cookbook_file_spec.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" -require 'support/shared/unit/provider/file' +require "support/shared/unit/provider/file" describe Chef::Provider::CookbookFile do - let(:node) { double('Chef::Node') } - let(:events) { double('Chef::Events').as_null_object } # mock all the methods - let(:run_context) { double('Chef::RunContext', :node => node, :events => events) } + let(:node) { double("Chef::Node") } + let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) } @@ -44,12 +44,12 @@ describe Chef::Provider::CookbookFile do let(:resource) do resource = Chef::Resource::CookbookFile.new("seattle", @run_context) resource.path(resource_path) - resource.cookbook_name = 'apache2' + resource.cookbook_name = "apache2" resource end let(:content) do - content = double('Chef::Provider::CookbookFile::Content') + content = double("Chef::Provider::CookbookFile::Content") end it_behaves_like Chef::Provider::File diff --git a/spec/unit/provider/cron/unix_spec.rb b/spec/unit/provider/cron/unix_spec.rb index 3d7a5675fc..615ae608f2 100644 --- a/spec/unit/provider/cron/unix_spec.rb +++ b/spec/unit/provider/cron/unix_spec.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Cron::Unix do @@ -37,9 +37,9 @@ describe Chef::Provider::Cron::Unix do end end - let(:status) { double('Process::Status', :exitstatus => exitstatus) } + let(:status) { double("Process::Status", :exitstatus => exitstatus) } let(:exitstatus) { 0 } - let(:shell_out) { double('Mixlib::ShellOut', :status => status, :stdout => stdout, :stderr => stderr) } + let(:shell_out) { double("Mixlib::ShellOut", :status => status, :stdout => stdout, :stderr => stderr) } it "is a Chef::Provider:Cron" do expect(provider).to be_a(Chef::Provider::Cron) @@ -61,12 +61,12 @@ describe Chef::Provider::Cron::Unix do before do allow(Chef::Log).to receive(:debug) allow(shell_out).to receive(:format_for_exception).and_return("formatted command output") - allow(provider).to receive(:shell_out).with('/usr/bin/crontab -l', :user => username).and_return(shell_out) + allow(provider).to receive(:shell_out).with("/usr/bin/crontab -l", :user => username).and_return(shell_out) end it "should call crontab -l with the user" do provider.send(:read_crontab) - expect(provider).to have_received(:shell_out).with('/usr/bin/crontab -l', :user => username) + expect(provider).to have_received(:shell_out).with("/usr/bin/crontab -l", :user => username) end it "should return the contents of the crontab" do diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb index 7a917a4f27..cf9680775c 100644 --- a/spec/unit/provider/cron_spec.rb +++ b/spec/unit/provider/cron_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Cron do describe "when with special time string" do @@ -56,7 +56,7 @@ CRONTAB it "should pull the details out of the cron line" do cron = @provider.load_current_resource expect(cron.time).to eq(:reboot) - expect(cron.command).to eq('/bin/true param1 param2') + expect(cron.command).to eq("/bin/true param1 param2") end it "should pull env vars out" do @@ -75,12 +75,12 @@ HOME=/home/foo # Another comment CRONTAB cron = @provider.load_current_resource - expect(cron.mailto).to eq('foo@example.com') - expect(cron.shell).to eq('/bin/foosh') - expect(cron.path).to eq('/bin:/foo') - expect(cron.home).to eq('/home/foo') + expect(cron.mailto).to eq("foo@example.com") + expect(cron.shell).to eq("/bin/foosh") + expect(cron.path).to eq("/bin:/foo") + expect(cron.home).to eq("/home/foo") expect(cron.time).to eq(:reboot) - expect(cron.command).to eq('/bin/true param1 param2') + expect(cron.command).to eq("/bin/true param1 param2") end it "should parse and load generic and standard environment variables from cron entry" do @@ -227,13 +227,13 @@ CRONTAB it "should pull the details out of the cron line" do cron = @provider.load_current_resource - expect(cron.minute).to eq('*') - expect(cron.hour).to eq('5') - expect(cron.day).to eq('*') - expect(cron.month).to eq('1') - expect(cron.weekday).to eq('*') + expect(cron.minute).to eq("*") + expect(cron.hour).to eq("5") + expect(cron.day).to eq("*") + expect(cron.month).to eq("1") + expect(cron.weekday).to eq("*") expect(cron.time).to eq(nil) - expect(cron.command).to eq('/bin/true param1 param2') + expect(cron.command).to eq("/bin/true param1 param2") end it "should pull env vars out" do @@ -252,17 +252,17 @@ HOME=/home/foo # Another comment CRONTAB cron = @provider.load_current_resource - expect(cron.mailto).to eq('foo@example.com') - expect(cron.shell).to eq('/bin/foosh') - expect(cron.path).to eq('/bin:/foo') - expect(cron.home).to eq('/home/foo') - expect(cron.minute).to eq('*') - expect(cron.hour).to eq('5') - expect(cron.day).to eq('*') - expect(cron.month).to eq('1') - expect(cron.weekday).to eq('*') + expect(cron.mailto).to eq("foo@example.com") + expect(cron.shell).to eq("/bin/foosh") + expect(cron.path).to eq("/bin:/foo") + expect(cron.home).to eq("/home/foo") + expect(cron.minute).to eq("*") + expect(cron.hour).to eq("5") + expect(cron.day).to eq("*") + expect(cron.month).to eq("1") + expect(cron.weekday).to eq("*") expect(cron.time).to eq(nil) - expect(cron.command).to eq('/bin/true param1 param2') + expect(cron.command).to eq("/bin/true param1 param2") end it "should parse and load generic and standard environment variables from cron entry" do @@ -290,8 +290,8 @@ ENVIRONMENT=production CRONTAB cron = @provider.load_current_resource - expect(cron.minute).to eq('*') - expect(cron.hour).to eq('5') + expect(cron.minute).to eq("*") + expect(cron.hour).to eq("5") expect(cron.environment).to eq({"MINUTE" => "40", "HOUR" => "midnight", "TEST" => "lol", "ENVIRONMENT" => "production"}) end @@ -323,12 +323,12 @@ CRONTAB it "should pull the details out of the cron line" do cron = @provider.load_current_resource - expect(cron.minute).to eq('*') - expect(cron.hour).to eq('5') - expect(cron.day).to eq('*') - expect(cron.month).to eq('Jan') - expect(cron.weekday).to eq('Mon') - expect(cron.command).to eq('/bin/true param1 param2') + expect(cron.minute).to eq("*") + expect(cron.hour).to eq("5") + expect(cron.day).to eq("*") + expect(cron.month).to eq("Jan") + expect(cron.weekday).to eq("Mon") + expect(cron.command).to eq("/bin/true param1 param2") end it "should report the match" do @@ -346,11 +346,11 @@ CRONTAB CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) - expect(cron.minute).to eq('*') - expect(cron.hour).to eq('*') - expect(cron.day).to eq('*') - expect(cron.month).to eq('*') - expect(cron.weekday).to eq('*') + expect(cron.minute).to eq("*") + expect(cron.hour).to eq("*") + expect(cron.day).to eq("*") + expect(cron.month).to eq("*") + expect(cron.weekday).to eq("*") expect(cron.time).to eq(nil) expect(cron.command).to eq(nil) end @@ -364,11 +364,11 @@ CRONTAB CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) - expect(cron.minute).to eq('*') - expect(cron.hour).to eq('*') - expect(cron.day).to eq('*') - expect(cron.month).to eq('*') - expect(cron.weekday).to eq('*') + expect(cron.minute).to eq("*") + expect(cron.hour).to eq("*") + expect(cron.day).to eq("*") + expect(cron.month).to eq("*") + expect(cron.weekday).to eq("*") expect(cron.time).to eq(nil) expect(cron.command).to eq(nil) end @@ -386,11 +386,11 @@ CRONTAB CRONTAB cron = @provider.load_current_resource expect(@provider.cron_exists).to eq(true) - expect(cron.minute).to eq('*') - expect(cron.hour).to eq('*') - expect(cron.day).to eq('*') - expect(cron.month).to eq('*') - expect(cron.weekday).to eq('*') + expect(cron.minute).to eq("*") + expect(cron.hour).to eq("*") + expect(cron.day).to eq("*") + expect(cron.month).to eq("*") + expect(cron.weekday).to eq("*") expect(cron.time).to eq(nil) expect(cron.command).to eq(nil) end @@ -455,10 +455,10 @@ CRONTAB end it "should include env variables that are set" do - @new_resource.mailto 'foo@example.com' - @new_resource.path '/usr/bin:/my/custom/path' - @new_resource.shell '/bin/foosh' - @new_resource.home '/home/foo' + @new_resource.mailto "foo@example.com" + @new_resource.path "/usr/bin:/my/custom/path" + @new_resource.shell "/bin/foosh" + @new_resource.home "/home/foo" @new_resource.environment "TEST" => "LOL" expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) # Chef Name: cronhole some stuff @@ -511,10 +511,10 @@ TEST=LOL end it "should include env variables that are set" do - @new_resource.mailto 'foo@example.com' - @new_resource.path '/usr/bin:/my/custom/path' - @new_resource.shell '/bin/foosh' - @new_resource.home '/home/foo' + @new_resource.mailto "foo@example.com" + @new_resource.path "/usr/bin:/my/custom/path" + @new_resource.shell "/bin/foosh" + @new_resource.home "/home/foo" @new_resource.environment "TEST" => "LOL" expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) 0 2 * * * /some/other/command @@ -576,10 +576,10 @@ TEST=LOL end it "should include env variables that are set" do - @new_resource.mailto 'foo@example.com' - @new_resource.path '/usr/bin:/my/custom/path' - @new_resource.shell '/bin/foosh' - @new_resource.home '/home/foo' + @new_resource.mailto "foo@example.com" + @new_resource.path "/usr/bin:/my/custom/path" + @new_resource.shell "/bin/foosh" + @new_resource.home "/home/foo" @new_resource.environment "TEST" => "LOL" expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) 0 2 * * * /some/other/command @@ -671,10 +671,10 @@ HOME=/home/foo # Another comment CRONTAB - @new_resource.mailto 'foo@example.com' - @new_resource.path '/usr/bin:/my/custom/path' - @new_resource.shell '/bin/foosh' - @new_resource.home '/home/foo' + @new_resource.mailto "foo@example.com" + @new_resource.path "/usr/bin:/my/custom/path" + @new_resource.shell "/bin/foosh" + @new_resource.home "/home/foo" expect(@provider).to receive(:write_crontab).with(<<-ENDCRON) 0 2 * * * /some/other/command diff --git a/spec/unit/provider/deploy/revision_spec.rb b/spec/unit/provider/deploy/revision_spec.rb index caa60878e1..1b77c472e0 100644 --- a/spec/unit/provider/deploy/revision_spec.rb +++ b/spec/unit/provider/deploy/revision_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Deploy::Revision do diff --git a/spec/unit/provider/deploy/timestamped_spec.rb b/spec/unit/provider/deploy/timestamped_spec.rb index b189d33502..b665ac3101 100644 --- a/spec/unit/provider/deploy/timestamped_spec.rb +++ b/spec/unit/provider/deploy/timestamped_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Deploy::Timestamped do diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb index adcb9431eb..a7f7375752 100644 --- a/spec/unit/provider/deploy_spec.rb +++ b/spec/unit/provider/deploy_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Deploy do @@ -163,9 +163,9 @@ describe Chef::Provider::Deploy do end it "dont care by default if error happens on deploy" do - allow(@provider).to receive(:all_releases).and_return(['previous_release']) + allow(@provider).to receive(:all_releases).and_return(["previous_release"]) allow(@provider).to receive(:deploy){ raise "Unexpected error" } - allow(@provider).to receive(:previous_release_path).and_return('previous_release') + allow(@provider).to receive(:previous_release_path).and_return("previous_release") expect(@provider).not_to receive(:rollback) expect { @provider.run_action(:deploy) @@ -174,9 +174,9 @@ describe Chef::Provider::Deploy do it "rollbacks to previous release if error happens on deploy" do @resource.rollback_on_error true - allow(@provider).to receive(:all_releases).and_return(['previous_release']) + allow(@provider).to receive(:all_releases).and_return(["previous_release"]) allow(@provider).to receive(:deploy){ raise "Unexpected error" } - allow(@provider).to receive(:previous_release_path).and_return('previous_release') + allow(@provider).to receive(:previous_release_path).and_return("previous_release") expect(@provider).to receive(:rollback) expect { @provider.run_action(:deploy) @@ -552,7 +552,7 @@ describe Chef::Provider::Deploy do expect(@provider).to receive(:execute).with("iGoToHell4this").and_return(mock_execution) @resource.user("notCoolMan") @resource.group("Ggroup") - @resource.environment("APP_ENV" => 'staging') + @resource.environment("APP_ENV" => "staging") @resource.deploy_to("/my/app") expect(mock_execution).to receive(:user).with("notCoolMan") expect(mock_execution).to receive(:group).with("Ggroup") diff --git a/spec/unit/provider/directory_spec.rb b/spec/unit/provider/directory_spec.rb index 4fad8c8906..6157c6c200 100644 --- a/spec/unit/provider/directory_spec.rb +++ b/spec/unit/provider/directory_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tmpdir' +require "spec_helper" +require "tmpdir" describe Chef::Provider::Directory do let(:tmp_dir) { Dir.mktmpdir } @@ -200,14 +200,14 @@ describe Chef::Provider::Directory do describe "on OS X" do before do - allow(node).to receive(:[]).with("platform").and_return('mac_os_x') + allow(node).to receive(:[]).with("platform").and_return("mac_os_x") new_resource.path "/usr/bin/chef_test" new_resource.recursive false allow_any_instance_of(Chef::Provider::File).to receive(:do_selinux) end it "os x 10.10 can write to sip locations" do - allow(node).to receive(:[]).with("platform_version").and_return('10.10') + allow(node).to receive(:[]).with("platform_version").and_return("10.10") allow(Dir).to receive(:mkdir).and_return([true], []) allow(::File).to receive(:directory?).and_return(true) allow(Chef::FileAccessControl).to receive(:writable?).and_return(true) @@ -216,7 +216,7 @@ describe Chef::Provider::Directory do end it "os x 10.11 cannot write to sip locations" do - allow(node).to receive(:[]).with("platform_version").and_return('10.11') + allow(node).to receive(:[]).with("platform_version").and_return("10.11") allow(::File).to receive(:directory?).and_return(true) allow(Chef::FileAccessControl).to receive(:writable?).and_return(false) expect {directory.run_action(:create) }.to raise_error(Chef::Exceptions::InsufficientPermissions) @@ -224,7 +224,7 @@ describe Chef::Provider::Directory do it "os x 10.11 can write to sip exlcusions" do new_resource.path "/usr/local/chef_test" - allow(node).to receive(:[]).with("platform_version").and_return('10.11') + allow(node).to receive(:[]).with("platform_version").and_return("10.11") allow(::File).to receive(:directory?).and_return(true) allow(Dir).to receive(:mkdir).and_return([true], []) allow(Chef::FileAccessControl).to receive(:writable?).and_return(false) diff --git a/spec/unit/provider/dsc_resource_spec.rb b/spec/unit/provider/dsc_resource_spec.rb index 46cdbd93a6..afa8ce3975 100644 --- a/spec/unit/provider/dsc_resource_spec.rb +++ b/spec/unit/provider/dsc_resource_spec.rb @@ -16,8 +16,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'chef' -require 'spec_helper' +require "chef" +require "spec_helper" describe Chef::Provider::DscResource do let (:events) { Chef::EventDispatch::Dispatcher.new } @@ -27,41 +27,41 @@ describe Chef::Provider::DscResource do Chef::Provider::DscResource.new(resource, run_context) end - context 'when Powershell does not support Invoke-DscResource' do + context "when Powershell does not support Invoke-DscResource" do let (:node) { node = Chef::Node.new - node.automatic[:languages][:powershell][:version] = '4.0' + node.automatic[:languages][:powershell][:version] = "4.0" node } - it 'raises a ProviderNotFound exception' do + it "raises a ProviderNotFound exception" do expect(provider).not_to receive(:meta_configuration) expect{provider.run_action(:run)}.to raise_error( Chef::Exceptions::ProviderNotFound, /5\.0\.10018\.0/) end end - context 'when Powershell supports Invoke-DscResource' do + context "when Powershell supports Invoke-DscResource" do - context 'when RefreshMode is not set to Disabled' do - context 'and the WMF 5 is a preview release' do + context "when RefreshMode is not set to Disabled" do + context "and the WMF 5 is a preview release" do let (:node) { node = Chef::Node.new - node.automatic[:languages][:powershell][:version] = '5.0.10018.0' + node.automatic[:languages][:powershell][:version] = "5.0.10018.0" node } - it 'raises an exception' do + it "raises an exception" do expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(false) expect { provider.run_action(:run) }.to raise_error( Chef::Exceptions::ProviderNotFound, /Disabled/) end end - context 'and the WMF is 5 RTM or newer' do + context "and the WMF is 5 RTM or newer" do let (:node) { node = Chef::Node.new - node.automatic[:languages][:powershell][:version] = '5.0.10586.0' + node.automatic[:languages][:powershell][:version] = "5.0.10586.0" node } - it 'does not raises an exception' do + it "does not raises an exception" do expect(provider).to receive(:test_resource) expect(provider).to receive(:set_resource) expect(provider).to receive(:reboot_if_required) @@ -71,21 +71,21 @@ describe Chef::Provider::DscResource do end end - context 'when the LCM supports Invoke-DscResource' do + context "when the LCM supports Invoke-DscResource" do let (:node) { node = Chef::Node.new - node.automatic[:languages][:powershell][:version] = '5.0.10018.0' + node.automatic[:languages][:powershell][:version] = "5.0.10018.0" node } - it 'does not update the resource if it is up to date' do + it "does not update the resource if it is up to date" do expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true) expect(provider).to receive(:test_resource).and_return(true) provider.run_action(:run) expect(resource).not_to be_updated end - it 'converges the resource if it is not up to date' do + it "converges the resource if it is not up to date" do expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true) expect(provider).to receive(:test_resource).and_return(false) expect(provider).to receive(:set_resource) @@ -93,21 +93,21 @@ describe Chef::Provider::DscResource do expect(resource).to be_updated end - it 'flags the resource as reboot required when required' do + it "flags the resource as reboot required when required" do expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true) expect(provider).to receive(:test_resource).and_return(false) expect(provider).to receive(:invoke_resource). - and_return(double(:stdout => '', :return_value =>nil)) + and_return(double(:stdout => "", :return_value =>nil)) expect(provider).to receive(:return_dsc_resource_result).and_return(true) expect(provider).to receive(:create_reboot_resource) provider.run_action(:run) end - it 'does not flag the resource as reboot required when not required' do + it "does not flag the resource as reboot required when not required" do expect(provider).to receive(:dsc_refresh_mode_disabled?).and_return(true) expect(provider).to receive(:test_resource).and_return(false) expect(provider).to receive(:invoke_resource). - and_return(double(:stdout => '', :return_value =>nil)) + and_return(double(:stdout => "", :return_value =>nil)) expect(provider).to receive(:return_dsc_resource_result).and_return(false) expect(provider).to_not receive(:create_reboot_resource) provider.run_action(:run) diff --git a/spec/unit/provider/dsc_script_spec.rb b/spec/unit/provider/dsc_script_spec.rb index 76589e71c1..ebde817010 100644 --- a/spec/unit/provider/dsc_script_spec.rb +++ b/spec/unit/provider/dsc_script_spec.rb @@ -17,15 +17,15 @@ # limitations under the License. # -require 'chef' -require 'chef/util/dsc/resource_info' -require 'spec_helper' +require "chef" +require "chef/util/dsc/resource_info" +require "spec_helper" describe Chef::Provider::DscScript do - context 'when DSC is available' do + context "when DSC is available" do let (:node) { node = Chef::Node.new - node.automatic[:languages][:powershell][:version] = '4.0' + node.automatic[:languages][:powershell][:version] = "4.0" node } let (:events) { Chef::EventDispatch::Dispatcher.new } @@ -39,75 +39,75 @@ describe Chef::Provider::DscScript do it "describes the resource as converged if there were 0 DSC resources" do allow(provider).to receive(:run_configuration).with(:test).and_return([]) provider.load_current_resource - expect(provider.instance_variable_get('@resource_converged')).to be_truthy + expect(provider.instance_variable_get("@resource_converged")).to be_truthy end it "describes the resource as not converged if there is 1 DSC resources that is converged" do - dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something']) + dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info]) provider.load_current_resource - expect(provider.instance_variable_get('@resource_converged')).to be_truthy + expect(provider.instance_variable_get("@resource_converged")).to be_truthy end it "describes the resource as not converged if there is 1 DSC resources that is not converged" do - dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something']) + dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info]) provider.load_current_resource - expect(provider.instance_variable_get('@resource_converged')).to be_falsey + expect(provider.instance_variable_get("@resource_converged")).to be_falsey end it "describes the resource as not converged if there are any DSC resources that are not converged" do - dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something']) - dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something']) + dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"]) + dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2]) provider.load_current_resource - expect(provider.instance_variable_get('@resource_converged')).to be_falsey + expect(provider.instance_variable_get("@resource_converged")).to be_falsey end it "describes the resource as converged if all DSC resources that are converged" do - dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something']) - dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new('resource', false, ['nothing will change something']) + dsc_resource_info1 = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"]) + dsc_resource_info2 = Chef::Util::DSC::ResourceInfo.new("resource", false, ["nothing will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info1, dsc_resource_info2]) provider.load_current_resource - expect(provider.instance_variable_get('@resource_converged')).to be_truthy + expect(provider.instance_variable_get("@resource_converged")).to be_truthy end end describe '#generate_configuration_document' do # I think integration tests should cover these cases - it 'uses configuration_document_from_script_path when a dsc script file is given' do + it "uses configuration_document_from_script_path when a dsc script file is given" do allow(provider).to receive(:load_current_resource) resource.command("path_to_script") - generator = double('Chef::Util::DSC::ConfigurationGenerator') + generator = double("Chef::Util::DSC::ConfigurationGenerator") expect(generator).to receive(:configuration_document_from_script_path) allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator) - provider.send(:generate_configuration_document, 'tmp', nil) + provider.send(:generate_configuration_document, "tmp", nil) end - it 'uses configuration_document_from_script_code when a the dsc resource is given' do + it "uses configuration_document_from_script_code when a the dsc resource is given" do allow(provider).to receive(:load_current_resource) resource.code("ImADSCResource{}") - generator = double('Chef::Util::DSC::ConfigurationGenerator') + generator = double("Chef::Util::DSC::ConfigurationGenerator") expect(generator).to receive(:configuration_document_from_script_code) allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator) - provider.send(:generate_configuration_document, 'tmp', nil) + provider.send(:generate_configuration_document, "tmp", nil) end - it 'should noop if neither code or command are provided' do + it "should noop if neither code or command are provided" do allow(provider).to receive(:load_current_resource) - generator = double('Chef::Util::DSC::ConfigurationGenerator') - expect(generator).to receive(:configuration_document_from_script_code).with('', anything(), anything(), anything()) + generator = double("Chef::Util::DSC::ConfigurationGenerator") + expect(generator).to receive(:configuration_document_from_script_code).with("", anything(), anything(), anything()) allow(Chef::Util::DSC::ConfigurationGenerator).to receive(:new).and_return(generator) - provider.send(:generate_configuration_document, 'tmp', nil) + provider.send(:generate_configuration_document, "tmp", nil) end end - describe 'action_run' do - it 'should converge the script if it is not converged' do - dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resource', true, ['will change something']) + describe "action_run" do + it "should converge the script if it is not converged" do + dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resource", true, ["will change something"]) allow(provider).to receive(:run_configuration).with(:test).and_return([dsc_resource_info]) allow(provider).to receive(:run_configuration).with(:set) @@ -115,7 +115,7 @@ describe Chef::Provider::DscScript do expect(resource).to be_updated end - it 'should not converge if the script is already converged' do + it "should not converge if the script is already converged" do allow(provider).to receive(:run_configuration).with(:test).and_return([]) provider.run_action(:run) @@ -124,35 +124,35 @@ describe Chef::Provider::DscScript do end describe '#generate_description' do - it 'removes the resource name from the beginning of any log line from the LCM' do - dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', true, ['resourcename doing something', 'lastline']) - provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info]) + it "removes the resource name from the beginning of any log line from the LCM" do + dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"]) + provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing something/) end - it 'ignores the last line' do - dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', true, ['resourcename doing something', 'lastline']) - provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info]) + it "ignores the last line" do + dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", true, ["resourcename doing something", "lastline"]) + provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) expect(provider.send(:generate_description)[1]).not_to match(/lastline/) end - it 'reports a dsc resource has not been changed if the LCM reported no change was required' do - dsc_resource_info = Chef::Util::DSC::ResourceInfo.new('resourcename', false, ['resourcename does nothing', 'lastline']) - provider.instance_variable_set('@dsc_resources_info', [dsc_resource_info]) + it "reports a dsc resource has not been changed if the LCM reported no change was required" do + dsc_resource_info = Chef::Util::DSC::ResourceInfo.new("resourcename", false, ["resourcename does nothing", "lastline"]) + provider.instance_variable_set("@dsc_resources_info", [dsc_resource_info]) expect(provider.send(:generate_description)[1]).to match(/converge DSC resource resourcename by doing nothing/) end end end - context 'when Dsc is not available' do + context "when Dsc is not available" do let (:node) { Chef::Node.new } let (:events) { Chef::EventDispatch::Dispatcher.new } let (:run_context) { Chef::RunContext.new(node, {}, events) } - let (:resource) { Chef::Resource::DscScript.new('script', run_context) } + let (:resource) { Chef::Resource::DscScript.new("script", run_context) } let (:provider) { Chef::Provider::DscScript.new(resource, run_context) } - describe 'action_run' do - ['1.0', '2.0', '3.0'].each do |version| + describe "action_run" do + ["1.0", "2.0", "3.0"].each do |version| it "raises an exception for powershell version '#{version}'" do node.automatic[:languages][:powershell][:version] = version @@ -162,7 +162,7 @@ describe Chef::Provider::DscScript do end end - it 'raises an exception if Powershell is not present' do + it "raises an exception if Powershell is not present" do expect { provider.run_action(:run) }.to raise_error(Chef::Exceptions::ProviderNotFound) diff --git a/spec/unit/provider/env/windows_spec.rb b/spec/unit/provider/env/windows_spec.rb index 99f33d392a..b72e41884f 100644 --- a/spec/unit/provider/env/windows_spec.rb +++ b/spec/unit/provider/env/windows_spec.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Env::Windows, :windows_only do let(:node) { Chef::Node.new } let(:events) {Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } - context 'when environment variable is not PATH' do + context "when environment variable is not PATH" do let(:new_resource) { new_resource = Chef::Resource::Env.new("CHEF_WINDOWS_ENV_TEST") new_resource.value("foo") @@ -31,71 +31,71 @@ describe Chef::Provider::Env::Windows, :windows_only do } let(:provider) { provider = Chef::Provider::Env::Windows.new(new_resource, run_context) - allow(provider).to receive(:env_obj).and_return(double('null object').as_null_object) + allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object) provider } describe "action_create" do before do - ENV.delete('CHEF_WINDOWS_ENV_TEST') + ENV.delete("CHEF_WINDOWS_ENV_TEST") provider.key_exists = false end it "should update the ruby ENV object when it creates the key" do provider.action_create - expect(ENV['CHEF_WINDOWS_ENV_TEST']).to eql('foo') + expect(ENV["CHEF_WINDOWS_ENV_TEST"]).to eql("foo") end end describe "action_modify" do before do - ENV['CHEF_WINDOWS_ENV_TEST'] = 'foo' + ENV["CHEF_WINDOWS_ENV_TEST"] = "foo" end it "should update the ruby ENV object when it updates the value" do expect(provider).to receive(:requires_modify_or_create?).and_return(true) new_resource.value("foobar") provider.action_modify - expect(ENV['CHEF_WINDOWS_ENV_TEST']).to eql('foobar') + expect(ENV["CHEF_WINDOWS_ENV_TEST"]).to eql("foobar") end describe "action_delete" do before do - ENV['CHEF_WINDOWS_ENV_TEST'] = 'foo' + ENV["CHEF_WINDOWS_ENV_TEST"] = "foo" end it "should update the ruby ENV object when it deletes the key" do provider.action_delete - expect(ENV['CHEF_WINDOWS_ENV_TEST']).to eql(nil) + expect(ENV["CHEF_WINDOWS_ENV_TEST"]).to eql(nil) end end end end - context 'when environment is PATH' do + context "when environment is PATH" do describe "for PATH" do - let(:system_root) {'%SystemRoot%'} + let(:system_root) {"%SystemRoot%"} let(:system_root_value) { 'D:\Windows' } let(:new_resource) { - new_resource = Chef::Resource::Env.new('PATH') + new_resource = Chef::Resource::Env.new("PATH") new_resource.value(system_root) new_resource } let(:provider) { provider = Chef::Provider::Env::Windows.new(new_resource, run_context) - allow(provider).to receive(:env_obj).and_return(double('null object').as_null_object) + allow(provider).to receive(:env_obj).and_return(double("null object").as_null_object) provider } before do - stub_const('ENV', {'PATH' => ''}) + stub_const("ENV", {"PATH" => ""}) end it "replaces Windows system variables" do expect(provider).to receive(:requires_modify_or_create?).and_return(true) expect(provider).to receive(:expand_path).with(system_root).and_return(system_root_value) provider.action_modify - expect(ENV['PATH']).to eql(system_root_value) + expect(ENV["PATH"]).to eql(system_root_value) end end diff --git a/spec/unit/provider/env_spec.rb b/spec/unit/provider/env_spec.rb index 230603dcb3..f0e74f347f 100644 --- a/spec/unit/provider/env_spec.rb +++ b/spec/unit/provider/env_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Env do diff --git a/spec/unit/provider/erl_call_spec.rb b/spec/unit/provider/erl_call_spec.rb index 2fb7e5b737..6526de0087 100644 --- a/spec/unit/provider/erl_call_spec.rb +++ b/spec/unit/provider/erl_call_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::ErlCall do before(:each) do @@ -33,7 +33,7 @@ describe Chef::Provider::ErlCall do allow(@provider).to receive(:popen4).and_return(@status) @stdin = StringIO.new - @stdout = StringIO.new('{ok, woohoo}') + @stdout = StringIO.new("{ok, woohoo}") @stderr = StringIO.new @pid = 2342999 end diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index 8a55025d9e..c656607ca7 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Execute do diff --git a/spec/unit/provider/file/content_spec.rb b/spec/unit/provider/file/content_spec.rb index 0a45d15bc9..7271772e2c 100644 --- a/spec/unit/provider/file/content_spec.rb +++ b/spec/unit/provider/file/content_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::File::Content do diff --git a/spec/unit/provider/file_spec.rb b/spec/unit/provider/file_spec.rb index 504ae045d9..4e8b4507ba 100644 --- a/spec/unit/provider/file_spec.rb +++ b/spec/unit/provider/file_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'support/shared/unit/provider/file' +require "support/shared/unit/provider/file" describe Chef::Provider::File do @@ -29,12 +29,12 @@ describe Chef::Provider::File do end let(:content) do - content = double('Chef::Provider::File::Content') + content = double("Chef::Provider::File::Content") end - let(:node) { double('Chef::Node') } - let(:events) { double('Chef::Events').as_null_object } # mock all the methods - let(:run_context) { double('Chef::RunContext', :node => node, :events => events) } + let(:node) { double("Chef::Node") } + let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) } diff --git a/spec/unit/provider/git_spec.rb b/spec/unit/provider/git_spec.rb index 41536a450f..4ec0439092 100644 --- a/spec/unit/provider/git_spec.rb +++ b/spec/unit/provider/git_spec.rb @@ -17,7 +17,7 @@ # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Git do before(:each) do @@ -59,7 +59,7 @@ describe Chef::Provider::Git do it "determines the current revision when there is one" do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stdout = "9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13\n" - expect(@provider).to receive(:shell_out!).with('git rev-parse HEAD', {:cwd => '/my/deploy/dir', :returns => [0,128]}).and_return(double("ShellOut result", :stdout => @stdout)) + expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", {:cwd => "/my/deploy/dir", :returns => [0,128]}).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.find_current_revision).to eql("9b4d8dc38dd471246e7cfb1c3c1ad14b0f2bee13") end @@ -67,7 +67,7 @@ describe Chef::Provider::Git do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) @stderr = "fatal: Not a git repository (or any of the parent directories): .git" @stdout = "" - expect(@provider).to receive(:shell_out!).with('git rev-parse HEAD', :cwd => '/my/deploy/dir', :returns => [0,128]).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr)) + expect(@provider).to receive(:shell_out!).with("git rev-parse HEAD", :cwd => "/my/deploy/dir", :returns => [0,128]).and_return(double("ShellOut result", :stdout => "", :stderr => @stderr)) expect(@provider.find_current_revision).to be_nil end end @@ -206,7 +206,7 @@ d7b9957f67236fa54e660cc3ab45ffecd6e0ba38\trefs/tags/0.7.8 b7d19519a1c15f1c1a324e2683bd728b6198ce5a\trefs/tags/0.7.8^{} ebc1b392fe7e8f0fbabc305c299b4d365d2b4d9b\trefs/tags/chef-server-package SHAS - @resource.revision '' + @resource.revision "" expect(@provider).to receive(:shell_out!).with(@git_ls_remote + "\"HEAD\"", {:log_tag=>"git[web2.0 app]"}).and_return(double("ShellOut result", :stdout => @stdout)) expect(@provider.target_revision).to eql("28af684d8460ba4793eda3e7ac238c864a5d029a") end @@ -284,8 +284,8 @@ SHAS it "compiles a clone command using --depth for shallow cloning" do @resource.depth 5 expected_cmd = "git clone --depth 5 \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\"" - version_response = double('shell_out') - allow(version_response).to receive(:stdout) { 'git version 1.7.9' } + version_response = double("shell_out") + allow(version_response).to receive(:stdout) { "git version 1.7.9" } expect(@provider).to receive(:shell_out!).with("git --version", :log_tag => "git[web2.0 app]").and_return(version_response) expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]") @@ -295,8 +295,8 @@ SHAS it "compiles a clone command using --no-single-branch for shallow cloning when git >= 1.7.10" do @resource.depth 5 expected_cmd = "git clone --depth 5 --no-single-branch \"git://github.com/opscode/chef.git\" \"/my/deploy/dir\"" - version_response = double('shell_out') - allow(version_response).to receive(:stdout) { 'git version 1.7.10' } + version_response = double("shell_out") + allow(version_response).to receive(:stdout) { "git version 1.7.10" } expect(@provider).to receive(:shell_out!).with("git --version", :log_tag => "git[web2.0 app]").and_return(version_response) expect(@provider).to receive(:shell_out!).with(expected_cmd, :log_tag => "git[web2.0 app]") @@ -311,9 +311,9 @@ SHAS end it "runs a checkout command with default options" do - expect(@provider).to receive(:shell_out!).with('git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c', :cwd => "/my/deploy/dir", + expect(@provider).to receive(:shell_out!).with("git branch -f deploy d35af14d41ae22b19da05d7d03a0bafc321b244c", :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]").ordered - expect(@provider).to receive(:shell_out!).with('git checkout deploy', :cwd => "/my/deploy/dir", + expect(@provider).to receive(:shell_out!).with("git checkout deploy", :cwd => "/my/deploy/dir", :log_tag => "git[web2.0 app]").ordered @provider.checkout end @@ -372,7 +372,7 @@ SHAS context "configuring remote tracking branches" do it "checks if a remote with this name already exists" do - command_response = double('shell_out') + command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 1 } expected_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(expected_command, @@ -390,7 +390,7 @@ SHAS @resource.user("whois") @resource.group("thisis") allow(Etc).to receive(:getpwnam).and_return(double("Struct::Passwd", :name => @resource.user, :dir => "/home/whois")) - command_response = double('shell_out') + command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 1 } expected_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(expected_command, @@ -412,7 +412,7 @@ SHAS describe "when a remote with a given name hasn't been configured yet" do it "adds a new remote " do - command_response = double('shell_out') + command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 1 } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, @@ -429,7 +429,7 @@ SHAS describe "when a remote with a given name has already been configured" do it "updates remote url when the url is different" do - command_response = double('shell_out') + command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 0 } allow(command_response).to receive(:stdout) { "some_other_url" } check_remote_command = "git config --get remote.#{@resource.remote}.url" @@ -445,7 +445,7 @@ SHAS end it "doesn't update remote url when the url is the same" do - command_response = double('shell_out') + command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 0 } allow(command_response).to receive(:stdout) { @resource.repository } check_remote_command = "git config --get remote.#{@resource.remote}.url" @@ -461,7 +461,7 @@ SHAS end it "resets remote url when it has multiple values" do - command_response = double('shell_out') + command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 2 } check_remote_command = "git config --get remote.#{@resource.remote}.url" expect(@provider).to receive(:shell_out!).with(check_remote_command, @@ -488,7 +488,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(['.','..']) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".",".."]) expect(@provider).to receive(:clone) expect(@provider).to receive(:checkout) expect(@provider).to receive(:enable_submodules) @@ -504,7 +504,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(['.','..']) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".",".."]) @resource.enable_checkout false expect(@provider).to receive(:clone) @@ -519,7 +519,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(false) allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(false) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(['..','.']) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(["..","."]) expect(@provider).to receive(:clone) expect(@provider).to receive(:checkout) expect(@provider).to receive(:enable_submodules) @@ -534,7 +534,7 @@ SHAS allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(['.','..','foo','bar']) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".","..","foo","bar"]) expect(@provider).not_to receive(:clone) expect(@provider).not_to receive(:checkout) expect(@provider).not_to receive(:enable_submodules) @@ -546,7 +546,7 @@ SHAS it "syncs the code by updating the source when the repo has already been checked out" do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - expect(@provider).to receive(:find_current_revision).exactly(1).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c') + expect(@provider).to receive(:find_current_revision).exactly(1).and_return("d35af14d41ae22b19da05d7d03a0bafc321b244c") expect(@provider).not_to receive(:fetch_updates) expect(@provider).to receive(:add_remotes) @provider.run_action(:sync) @@ -557,8 +557,8 @@ SHAS expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) # invoked twice - first time from load_current_resource - expect(@provider).to receive(:find_current_revision).exactly(1).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c') - allow(@provider).to receive(:target_revision).and_return('28af684d8460ba4793eda3e7ac238c864a5d029a') + expect(@provider).to receive(:find_current_revision).exactly(1).and_return("d35af14d41ae22b19da05d7d03a0bafc321b244c") + allow(@provider).to receive(:target_revision).and_return("28af684d8460ba4793eda3e7ac238c864a5d029a") expect(@provider).to receive(:fetch_updates) expect(@provider).to receive(:enable_submodules) expect(@provider).to receive(:add_remotes) @@ -569,8 +569,8 @@ SHAS it "does not fetch any updates if the remote revision matches the current revision" do expect(::File).to receive(:exist?).with("/my/deploy/dir/.git").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(@provider).to receive(:find_current_revision).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c') - allow(@provider).to receive(:target_revision).and_return('d35af14d41ae22b19da05d7d03a0bafc321b244c') + allow(@provider).to receive(:find_current_revision).and_return("d35af14d41ae22b19da05d7d03a0bafc321b244c") + allow(@provider).to receive(:target_revision).and_return("d35af14d41ae22b19da05d7d03a0bafc321b244c") expect(@provider).not_to receive(:fetch_updates) expect(@provider).to receive(:add_remotes) @provider.run_action(:sync) @@ -609,7 +609,7 @@ SHAS @resource.additional_remotes({:opscode => "opscode_repo_url", :another_repo => "some_other_repo_url"}) allow(STDOUT).to receive(:tty?).and_return(false) - command_response = double('shell_out') + command_response = double("shell_out") allow(command_response).to receive(:exitstatus) { 0 } @resource.additional_remotes.each_pair do |remote_name, remote_url| expect(@provider).to receive(:setup_remote_tracking_branches).with(remote_name, remote_url) @@ -620,7 +620,7 @@ SHAS describe "calling multiple_remotes?" do before(:each) do - @command_response = double('shell_out') + @command_response = double("shell_out") end describe "when check remote command returns with status 2" do @@ -647,7 +647,7 @@ SHAS describe "calling remote_matches?" do before(:each) do - @command_response = double('shell_out') + @command_response = double("shell_out") end describe "when output of the check remote command matches the repository url" do diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index d84e4e1d57..1a61fc2383 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Group::Dscl do before do @@ -293,7 +293,7 @@ describe Chef::Provider::Group::Dscl do end end -describe 'Test DSCL loading' do +describe "Test DSCL loading" do before do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @@ -320,12 +320,12 @@ EOF end - it 'should parse gid properly' do + it "should parse gid properly" do allow(File).to receive(:exists?).and_return(true) expect(@current_resource.gid).to eq("999") end - it 'should parse members properly' do + it "should parse members properly" do allow(File).to receive(:exists?).and_return(true) - expect(@current_resource.members).to eq(['waka', 'bar']) + expect(@current_resource.members).to eq(["waka", "bar"]) end end diff --git a/spec/unit/provider/group/gpasswd_spec.rb b/spec/unit/provider/group/gpasswd_spec.rb index 55d978fa7e..a24424182d 100644 --- a/spec/unit/provider/group/gpasswd_spec.rb +++ b/spec/unit/provider/group/gpasswd_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Group::Gpasswd, "modify_group_members" do before do diff --git a/spec/unit/provider/group/groupadd_spec.rb b/spec/unit/provider/group/groupadd_spec.rb index 47021a9af3..8cdc096c68 100644 --- a/spec/unit/provider/group/groupadd_spec.rb +++ b/spec/unit/provider/group/groupadd_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Group::Groupadd, "set_options" do before do diff --git a/spec/unit/provider/group/groupmod_spec.rb b/spec/unit/provider/group/groupmod_spec.rb index 496d1e28fa..a69774a309 100644 --- a/spec/unit/provider/group/groupmod_spec.rb +++ b/spec/unit/provider/group/groupmod_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Group::Groupmod do before do diff --git a/spec/unit/provider/group/pw_spec.rb b/spec/unit/provider/group/pw_spec.rb index 531d0a52a2..ed1f06efe0 100644 --- a/spec/unit/provider/group/pw_spec.rb +++ b/spec/unit/provider/group/pw_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Group::Pw do before do diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb index 6c4c4d2e07..cd532f8b8d 100644 --- a/spec/unit/provider/group/usermod_spec.rb +++ b/spec/unit/provider/group/usermod_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Group::Usermod do before do diff --git a/spec/unit/provider/group/windows_spec.rb b/spec/unit/provider/group/windows_spec.rb index 23dfa8315f..4f071f3b94 100644 --- a/spec/unit/provider/group/windows_spec.rb +++ b/spec/unit/provider/group/windows_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class Chef class Util @@ -94,7 +94,7 @@ describe Chef::Provider::Group::Windows, "NetGroup" do @new_resource = Chef::Resource::Group.new("Creating a new group") @new_resource.group_name "Remote Desktop Users" end - it 'sets group_name correctly' do + it "sets group_name correctly" do expect(Chef::Util::Windows::NetGroup).to receive(:new).with("Remote Desktop Users") Chef::Provider::Group::Windows.new(@new_resource, @run_context) end diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index 55a2f97aa5..957e7b14df 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::User do @@ -41,7 +41,7 @@ describe Chef::Provider::User do :gid => 20, :mem => [ "root", "aj" ], ) - allow(Etc).to receive(:getgrnam).with('wheel').and_return(@pw_group) + allow(Etc).to receive(:getgrnam).with("wheel").and_return(@pw_group) end it "assumes the group exists by default" do @@ -52,7 +52,7 @@ describe Chef::Provider::User do it "sets the group name of the current resource to the group name of the new resource" do @provider.load_current_resource - expect(@provider.current_resource.group_name).to eq('wheel') + expect(@provider.current_resource.group_name).to eq("wheel") end it "does not modify the desired gid if set" do diff --git a/spec/unit/provider/http_request_spec.rb b/spec/unit/provider/http_request_spec.rb index 980458abd3..33c9167c33 100644 --- a/spec/unit/provider/http_request_spec.rb +++ b/spec/unit/provider/http_request_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::HttpRequest do before(:each) do @@ -24,7 +24,7 @@ describe Chef::Provider::HttpRequest do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::HttpRequest.new('adam') + @new_resource = Chef::Resource::HttpRequest.new("adam") @new_resource.name "adam" @new_resource.url "http://www.opscode.com/" @new_resource.message "is cool" diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb index 0b6fa33614..6213de4803 100644 --- a/spec/unit/provider/ifconfig/aix_spec.rb +++ b/spec/unit/provider/ifconfig/aix_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/exceptions' +require "spec_helper" +require "chef/exceptions" describe Chef::Provider::Ifconfig::Aix do diff --git a/spec/unit/provider/ifconfig/debian_spec.rb b/spec/unit/provider/ifconfig/debian_spec.rb index 0c02ae9cd4..b116ecf127 100644 --- a/spec/unit/provider/ifconfig/debian_spec.rb +++ b/spec/unit/provider/ifconfig/debian_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/exceptions' +require "spec_helper" +require "chef/exceptions" describe Chef::Provider::Ifconfig::Debian do diff --git a/spec/unit/provider/ifconfig/redhat_spec.rb b/spec/unit/provider/ifconfig/redhat_spec.rb index 620fd341d7..bdcaa57330 100644 --- a/spec/unit/provider/ifconfig/redhat_spec.rb +++ b/spec/unit/provider/ifconfig/redhat_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/exceptions' +require "spec_helper" +require "chef/exceptions" describe Chef::Provider::Ifconfig::Redhat do before do diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index 90109ca1c0..e4335ed3e7 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -17,8 +17,8 @@ # #require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper")) -require 'spec_helper' -require 'chef/exceptions' +require "spec_helper" +require "chef/exceptions" describe Chef::Provider::Ifconfig do before do diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index 0f95ce997e..80ebc62f2a 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -17,12 +17,12 @@ # limitations under the License. # -require 'ostruct' +require "ostruct" -require 'spec_helper' +require "spec_helper" if Chef::Platform.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, :not_supported_on_win2k3 do @@ -39,7 +39,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do end def canonicalize(path) - Chef::Platform.windows? ? path.gsub('/', '\\') : path + Chef::Platform.windows? ? path.gsub("/", '\\') : path end describe "when the target is a symlink" do @@ -80,13 +80,13 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do # We test create in unit tests because there is no other way to ensure # it does no work. Other create and delete scenarios are covered in # the functional tests for links. - context 'when the desired state is identical' do + context "when the desired state is identical" do let(:new_resource) do result = Chef::Resource::Link.new("#{CHEF_SPEC_DATA}/fofile-link") result.to "#{CHEF_SPEC_DATA}/fofile" result end - it 'create does no work' do + it "create does no work" do expect(provider.access_controls).not_to receive(:set_all) provider.run_action(:create) end @@ -164,7 +164,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do expect(provider.current_resource.target_file).to eq("#{CHEF_SPEC_DATA}/fofile-link") end it "should update the current source of the existing link with an empty string" do - expect(provider.current_resource.to).to eq('') + expect(provider.current_resource.to).to eq("") end it "should not set the owner" do expect(provider.current_resource.owner).to eq(nil) @@ -191,7 +191,7 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do expect(provider.current_resource.target_file).to eq("#{CHEF_SPEC_DATA}/fofile-link") end it "should update the current source of the existing link with an empty string" do - expect(provider.current_resource.to).to eq('') + expect(provider.current_resource.to).to eq("") end it "should not set the owner" do expect(provider.current_resource.owner).to eq(nil) @@ -233,14 +233,14 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do # We test create in unit tests because there is no other way to ensure # it does no work. Other create and delete scenarios are covered in # the functional tests for links. - context 'when the desired state is identical' do + context "when the desired state is identical" do let(:new_resource) do result = Chef::Resource::Link.new("#{CHEF_SPEC_DATA}/fofile-link") result.to "#{CHEF_SPEC_DATA}/fofile" result.link_type :hard result end - it 'create does no work' do + it "create does no work" do expect(provider.file_class).not_to receive(:symlink) expect(provider.file_class).not_to receive(:link) expect(provider.access_controls).not_to receive(:set_all) diff --git a/spec/unit/provider/log_spec.rb b/spec/unit/provider/log_spec.rb index 1ecc633ce1..5aadcbf7cd 100644 --- a/spec/unit/provider/log_spec.rb +++ b/spec/unit/provider/log_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Log::ChefLog do diff --git a/spec/unit/provider/mdadm_spec.rb b/spec/unit/provider/mdadm_spec.rb index 38401b7225..ec5f6237d1 100644 --- a/spec/unit/provider/mdadm_spec.rb +++ b/spec/unit/provider/mdadm_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Mdadm do @@ -25,7 +25,7 @@ describe Chef::Provider::Mdadm do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Mdadm.new('/dev/md1') + @new_resource = Chef::Resource::Mdadm.new("/dev/md1") @new_resource.devices ["/dev/sdz1","/dev/sdz2","/dev/sdz3"] @provider = Chef::Provider::Mdadm.new(@new_resource, @run_context) end @@ -34,8 +34,8 @@ describe Chef::Provider::Mdadm do it "should set the current resources mount point to the new resources mount point" do allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:status => 0)) @provider.load_current_resource - expect(@provider.current_resource.name).to eq('/dev/md1') - expect(@provider.current_resource.raid_device).to eq('/dev/md1') + expect(@provider.current_resource.name).to eq("/dev/md1") + expect(@provider.current_resource.raid_device).to eq("/dev/md1") end it "determines that the metadevice exists when mdadm exit code is zero" do @@ -53,7 +53,7 @@ describe Chef::Provider::Mdadm do describe "after the metadevice status is known" do before(:each) do - @current_resource = Chef::Resource::Mdadm.new('/dev/md1') + @current_resource = Chef::Resource::Mdadm.new("/dev/md1") @new_resource.level 5 allow(@provider).to receive(:load_current_resource).and_return(true) @provider.current_resource = @current_resource @@ -69,7 +69,7 @@ describe Chef::Provider::Mdadm do it "should specify a bitmap only if set" do @current_resource.exists(false) - @new_resource.bitmap('grow') + @new_resource.bitmap("grow") expected_command = "yes | mdadm --create /dev/md1 --level 5 --chunk=16 --metadata=0.90 --bitmap=grow --raid-devices 3 /dev/sdz1 /dev/sdz2 /dev/sdz3" expect(@provider).to receive(:shell_out!).with(expected_command) @provider.run_action(:create) diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb index e232592275..1aa64967af 100644 --- a/spec/unit/provider/mount/aix_spec.rb +++ b/spec/unit/provider/mount/aix_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Mount::Aix do @@ -114,7 +114,7 @@ ENABLED expect(@provider.current_resource.mounted).to be_truthy expect(@provider.current_resource.mount_point).to eql(@new_resource.mount_point) expect(@provider.current_resource.fstype).to eql("jfs2") - expect(@provider.current_resource.options).to eql(['rw']) + expect(@provider.current_resource.options).to eql(["rw"]) end describe "mount_fs" do diff --git a/spec/unit/provider/mount/mount_spec.rb b/spec/unit/provider/mount/mount_spec.rb index 124d51b367..c267dc706c 100644 --- a/spec/unit/provider/mount/mount_spec.rb +++ b/spec/unit/provider/mount/mount_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Mount::Mount do before(:each) do @@ -42,15 +42,15 @@ describe Chef::Provider::Mount::Mount do describe "when discovering the current fs state" do before do - allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => '')) + allow(@provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "")) allow(::File).to receive(:foreach).with("/etc/fstab") end it "should create a current resource with the same mount point and device" do @provider.load_current_resource - expect(@provider.current_resource.name).to eq('/tmp/foo') - expect(@provider.current_resource.mount_point).to eq('/tmp/foo') - expect(@provider.current_resource.device).to eq('/dev/sdz1') + expect(@provider.current_resource.name).to eq("/tmp/foo") + expect(@provider.current_resource.mount_point).to eq("/tmp/foo") + expect(@provider.current_resource.device).to eq("/dev/sdz1") end it "should accecpt device_type :uuid", :not_supported_on_solaris do @@ -134,7 +134,7 @@ describe Chef::Provider::Mount::Mount do it "should set mounted true if the symlink target of the device is found in the mounts list" do # expand the target path to correct specs on Windows - target = ::File.expand_path('/dev/mapper/target') + target = ::File.expand_path("/dev/mapper/target") allow(::File).to receive(:symlink?).with("#{@new_resource.device}").and_return(true) allow(::File).to receive(:readlink).with("#{@new_resource.device}").and_return(target) @@ -266,7 +266,7 @@ describe Chef::Provider::Mount::Mount do fstab = "#{@new_resource.device} #{@new_resource.mount_point} #{@new_resource.fstype} #{options} 1 2\n" allow(::File).to receive(:foreach).with("/etc/fstab").and_yield fstab @provider.load_current_resource - expect(@provider.current_resource.options).to eq(options.split(',')) + expect(@provider.current_resource.options).to eq(options.split(",")) end it "should not mangle the mount options if the symlink target is in fstab" do @@ -279,7 +279,7 @@ describe Chef::Provider::Mount::Mount do fstab = "#{target} #{@new_resource.mount_point} #{@new_resource.fstype} #{options} 1 2\n" allow(::File).to receive(:foreach).with("/etc/fstab").and_yield fstab @provider.load_current_resource - expect(@provider.current_resource.options).to eq(options.split(',')) + expect(@provider.current_resource.options).to eq(options.split(",")) end end @@ -311,7 +311,7 @@ describe Chef::Provider::Mount::Mount do @new_resource.device "d21afe51-a0fe-4dc6-9152-ac733763ae0a" @new_resource.device_type :uuid allow(@provider).to receive(:shell_out).with("/sbin/findfs UUID=d21afe51-a0fe-4dc6-9152-ac733763ae0a").and_return(status) - @stdout_mock = double('stdout mock') + @stdout_mock = double("stdout mock") allow(@stdout_mock).to receive(:each).and_yield("#{@new_resource.device} on #{@new_resource.mount_point}") expect(@provider).to receive(:shell_out!).with("mount -t #{@new_resource.fstype} -o defaults -U #{@new_resource.device} #{@new_resource.mount_point}").and_return(@stdout_mock) @provider.mount_fs() diff --git a/spec/unit/provider/mount/solaris_spec.rb b/spec/unit/provider/mount/solaris_spec.rb index 9a9b09b531..707a06ceee 100644 --- a/spec/unit/provider/mount/solaris_spec.rb +++ b/spec/unit/provider/mount/solaris_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" # Do not run these tests on windows because some path handling # code is not implemented to handle windows paths. @@ -57,7 +57,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do } let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" #device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # @@ -84,7 +84,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do } let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t0d0s0 on / type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012 /dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012 EOF @@ -215,7 +215,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when loading a normal UFS filesystem with noauto, don't mount at boot" do let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" #device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # @@ -245,12 +245,12 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the device is an smbfs mount" do let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" //solarsystem/tmp on /mnt type smbfs read/write/setuid/devices/dev=5080000 on Tue Mar 29 11:40:18 2011 EOF } let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" //WORKGROUP;username:password@host/share - /mountpoint smbfs - no fileperms=0777,dirperms=0777 EOF } @@ -264,13 +264,13 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the device is an NFS mount" do let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" cartman:/share2 on /cartman type nfs rsize=32768,wsize=32768,NFSv4,dev=4000004 on Tue Mar 29 11:40:18 2011 EOF } let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" cartman:/share2 - /cartman nfs - yes rw,soft EOF } @@ -335,13 +335,13 @@ describe Chef::Provider::Mount::Solaris, :unix_only do let(:target) { "/dev/mapper/target" } let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" #{target} on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012 EOF } let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" #{target} /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes - EOF } @@ -372,13 +372,13 @@ describe Chef::Provider::Mount::Solaris, :unix_only do let(:absolute_target) { File.expand_path(target, File.dirname(device)) } let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" #{absolute_target} on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012 EOF } let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" #{absolute_target} /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes - EOF } @@ -405,7 +405,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the matching mount point is last in the mounts list" do let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t0d0s0 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012 /dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012 EOF @@ -418,7 +418,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the matching mount point is not last in the mounts list" do let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t2d0s7 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012 /dev/dsk/c0t0d0s0 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200000 on Tue Jul 31 22:34:46 2012 EOF @@ -431,7 +431,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the matching mount point is not in the mounts list (mountpoint wrong)" do let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t2d0s7 on /mnt/foob type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012 EOF } @@ -443,7 +443,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the matching mount point is not in the mounts list (raw device wrong)" do let(:mount_output) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t2d0s72 on /mnt/foo type ufs read/write/setuid/intr/largefiles/xattr/onerror=panic/dev=2200007 on Tue Jul 31 22:34:46 2012 EOF } @@ -455,7 +455,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the mount point is last in fstab" do let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes - /dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes - EOF @@ -469,7 +469,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the mount point is not last in fstab and is a substring of another mount" do let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes - /dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s7 /mnt/foo/bar ufs 2 yes - EOF @@ -483,7 +483,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the mount point is not last in fstab" do let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes - /dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s72 /mnt/foo ufs 2 yes - EOF @@ -497,7 +497,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the mount point is not in fstab, but the mountpoint is a substring of one that is" do let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foob ufs 2 yes - EOF } @@ -510,7 +510,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the mount point is not in fstab, but the device is a substring of one that is" do let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" /dev/dsk/c0t2d0s72 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes - EOF } @@ -523,7 +523,7 @@ describe Chef::Provider::Mount::Solaris, :unix_only do context "when the mountpoint line is commented out" do let(:vfstab_file_contents) { - <<-EOF.gsub /^\s*/, '' + <<-EOF.gsub /^\s*/, "" #/dev/dsk/c0t2d0s7 /dev/rdsk/c0t2d0s7 /mnt/foo ufs 2 yes - EOF } diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb index 2de6f11d43..c3c1934fa0 100644 --- a/spec/unit/provider/mount/windows_spec.rb +++ b/spec/unit/provider/mount/windows_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class Chef class Util diff --git a/spec/unit/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb index cc2a456440..3d36a921b3 100644 --- a/spec/unit/provider/mount_spec.rb +++ b/spec/unit/provider/mount_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Mount do @@ -28,7 +28,7 @@ describe Chef::Provider::Mount do let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:new_resource) do - new_resource = Chef::Resource::Mount.new('/tmp/foo') + new_resource = Chef::Resource::Mount.new("/tmp/foo") new_resource.device "/dev/sdz1" new_resource.name "/tmp/foo" new_resource.mount_point "/tmp/foo" @@ -38,7 +38,7 @@ describe Chef::Provider::Mount do let(:current_resource) do # this abstract superclass has no load_current_resource to call - current_resource = Chef::Resource::Mount.new('/tmp/foo') + current_resource = Chef::Resource::Mount.new("/tmp/foo") current_resource.device "/dev/sdz1" current_resource.name "/tmp/foo" current_resource.mount_point "/tmp/foo" diff --git a/spec/unit/provider/ohai_spec.rb b/spec/unit/provider/ohai_spec.rb index 4072487f35..b5ce1e8fc5 100644 --- a/spec/unit/provider/ohai_spec.rb +++ b/spec/unit/provider/ohai_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/run_context' +require "chef/run_context" describe Chef::Provider::Ohai do before(:each) do @@ -63,22 +63,22 @@ describe Chef::Provider::Ohai do describe "when reloading ohai" do before do - @node.automatic_attrs[:origdata] = 'somevalue' + @node.automatic_attrs[:origdata] = "somevalue" end it "applies updated ohai data to the node" do - expect(@node[:origdata]).to eq('somevalue') + expect(@node[:origdata]).to eq("somevalue") expect(@node[:newdata]).to be_nil @provider.run_action(:reload) - expect(@node[:origdata]).to eq('somevalue') - expect(@node[:newdata]).to eq('somevalue') + expect(@node[:origdata]).to eq("somevalue") + expect(@node[:newdata]).to eq("somevalue") end it "should reload a specific plugin and cause node to pick up new values" do @new_resource.plugin "someplugin" @provider.run_action(:reload) - expect(@node[:origdata]).to eq('somevalue') - expect(@node[:newdata]).to eq('somevalue') + expect(@node[:origdata]).to eq("somevalue") + expect(@node[:newdata]).to eq("somevalue") end end end diff --git a/spec/unit/provider/osx_profile_spec.rb b/spec/unit/provider/osx_profile_spec.rb index 2e87faeb48..76bfc3b4eb 100644 --- a/spec/unit/provider/osx_profile_spec.rb +++ b/spec/unit/provider/osx_profile_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::OsxProfile do let(:shell_out_success) do - double('shell_out', :exitstatus => 0, :error? => false) + double("shell_out", :exitstatus => 0, :error? => false) end - describe 'action_create' do + describe "action_create" do let(:node) { Chef::Node.new } let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } @@ -74,28 +74,28 @@ describe Chef::Provider::OsxProfile do # ProfileUUID in all_profiles to match the new config specific UUID let(:test_profile) do { - 'PayloadIdentifier' => 'com.testprofile.screensaver', - 'PayloadRemovalDisallowed' => false, - 'PayloadScope' => 'System', - 'PayloadType' => 'Configuration', - 'PayloadUUID' => '1781fbec-3325-565f-9022-8aa28135c3cc', - 'PayloadOrganization' => 'Chef', - 'PayloadVersion' => 1, - 'PayloadDisplayName' => 'Screensaver Settings', - 'PayloadContent'=> [ + "PayloadIdentifier" => "com.testprofile.screensaver", + "PayloadRemovalDisallowed" => false, + "PayloadScope" => "System", + "PayloadType" => "Configuration", + "PayloadUUID" => "1781fbec-3325-565f-9022-8aa28135c3cc", + "PayloadOrganization" => "Chef", + "PayloadVersion" => 1, + "PayloadDisplayName" => "Screensaver Settings", + "PayloadContent"=> [ { - 'PayloadType' => 'com.apple.ManagedClient.preferences', - 'PayloadVersion' => 1, - 'PayloadIdentifier' => 'com.testprofile.screensaver', - 'PayloadUUID' => '73fc30e0-1e57-0131-c32d-000c2944c108', - 'PayloadEnabled' => true, - 'PayloadDisplayName' => 'com.apple.screensaver', - 'PayloadContent' => { - 'com.apple.screensaver' => { - 'Forced' => [ + "PayloadType" => "com.apple.ManagedClient.preferences", + "PayloadVersion" => 1, + "PayloadIdentifier" => "com.testprofile.screensaver", + "PayloadUUID" => "73fc30e0-1e57-0131-c32d-000c2944c108", + "PayloadEnabled" => true, + "PayloadDisplayName" => "com.apple.screensaver", + "PayloadContent" => { + "com.apple.screensaver" => { + "Forced" => [ { - 'mcx_preference_settings' => { - 'idleTime' => 0 + "mcx_preference_settings" => { + "idleTime" => 0 } }, ] @@ -111,16 +111,16 @@ describe Chef::Provider::OsxProfile do before(:each) do allow(provider).to receive(:cookbook_file_available?).and_return(true) - allow(provider).to receive(:cache_cookbook_profile).and_return('/tmp/test.mobileconfig.remote') + allow(provider).to receive(:cache_cookbook_profile).and_return("/tmp/test.mobileconfig.remote") allow(provider).to receive(:get_new_profile_hash).and_return(test_profile) allow(provider).to receive(:get_installed_profiles).and_return(all_profiles) allow(provider).to receive(:read_plist).and_return(all_profiles) allow(::File).to receive(:unlink).and_return(true) end - it 'should build the get all profiles shellout command correctly' do - profile_name = 'com.testprofile.screensaver.mobileconfig' - tempfile = '/tmp/allprofiles.plist' + it "should build the get all profiles shellout command correctly" do + profile_name = "com.testprofile.screensaver.mobileconfig" + tempfile = "/tmp/allprofiles.plist" new_resource.profile_name profile_name allow(provider).to receive(:generate_tempfile).and_return(tempfile) allow(provider).to receive(:get_installed_profiles).and_call_original @@ -129,29 +129,29 @@ describe Chef::Provider::OsxProfile do provider.load_current_resource end - it 'should use profile name as profile when no profile is set' do - profile_name = 'com.testprofile.screensaver.mobileconfig' + it "should use profile name as profile when no profile is set" do + profile_name = "com.testprofile.screensaver.mobileconfig" new_resource.profile_name profile_name provider.load_current_resource expect(new_resource.profile_name).to eql(profile_name) end - it 'should use identifier from specified profile' do + it "should use identifier from specified profile" do new_resource.profile test_profile provider.load_current_resource expect( provider.instance_variable_get(:@new_profile_identifier) - ).to eql(test_profile['PayloadIdentifier']) + ).to eql(test_profile["PayloadIdentifier"]) end - it 'should install when not installed' do + it "should install when not installed" do new_resource.profile test_profile allow(provider).to receive(:get_installed_profiles).and_return(no_profiles) provider.load_current_resource expect { provider.run_action(:install) }.to_not raise_error end - it 'does not install if the profile is already installed' do + it "does not install if the profile is already installed" do new_resource.profile test_profile allow(provider).to receive(:get_installed_profiles).and_return(all_profiles) provider.load_current_resource @@ -159,40 +159,40 @@ describe Chef::Provider::OsxProfile do expect { provider.action_install }.to_not raise_error end - it 'should install when installed but uuid differs' do + it "should install when installed but uuid differs" do new_resource.profile test_profile - all_profiles['_computerlevel'][1]['ProfileUUID'] = '1781fbec-3325-565f-9022-9bb39245d4dd' + all_profiles["_computerlevel"][1]["ProfileUUID"] = "1781fbec-3325-565f-9022-9bb39245d4dd" provider.load_current_resource expect { provider.run_action(:install) }.to_not raise_error end - it 'should build the shellout install command correctly' do - profile_path = '/tmp/test.mobileconfig' + it "should build the shellout install command correctly" do + profile_path = "/tmp/test.mobileconfig" new_resource.profile test_profile # Change the profile so it triggers an install - all_profiles['_computerlevel'][1]['ProfileUUID'] = '1781fbec-3325-565f-9022-9bb39245d4dd' + all_profiles["_computerlevel"][1]["ProfileUUID"] = "1781fbec-3325-565f-9022-9bb39245d4dd" provider.load_current_resource allow(provider).to receive(:write_profile_to_disk).and_return(profile_path) expect(provider).to receive(:shell_out).with("profiles -I -F '#{profile_path}'").and_return(shell_out_success) provider.action_install() end - it 'should fail if there is no identifier inside the profile' do - test_profile.delete('PayloadIdentifier') + it "should fail if there is no identifier inside the profile" do + test_profile.delete("PayloadIdentifier") new_resource.profile test_profile - error_message = 'The specified profile does not seem to be valid' + error_message = "The specified profile does not seem to be valid" expect{provider.run_action(:install)}.to raise_error(RuntimeError, error_message) end end - describe 'action_remove' do + describe "action_remove" do let(:node) { Chef::Node.new } let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:new_resource) { Chef::Resource::OsxProfile.new("Profile Test", run_context) } let(:provider) { Chef::Provider::OsxProfile.new(new_resource, run_context) } - let(:current_resource) { Chef::Resource::OsxProfile.new('Profile Test') } + let(:current_resource) { Chef::Resource::OsxProfile.new("Profile Test") } let(:all_profiles) do {"_computerlevel"=> [{"ProfileDisplayName"=>"ScreenSaver Settings", @@ -240,24 +240,24 @@ describe Chef::Provider::OsxProfile do allow(provider).to receive(:get_installed_profiles).and_return(all_profiles) end - it 'should use resource name for identifier when not specified' do - new_resource.profile_name 'com.testprofile.screensaver' + it "should use resource name for identifier when not specified" do + new_resource.profile_name "com.testprofile.screensaver" new_resource.action(:remove) provider.load_current_resource expect(provider.instance_variable_get(:@new_profile_identifier) ).to eql(new_resource.profile_name) end - it 'should use specified identifier' do - new_resource.identifier 'com.testprofile.screensaver' + it "should use specified identifier" do + new_resource.identifier "com.testprofile.screensaver" new_resource.action(:remove) provider.load_current_resource expect(provider.instance_variable_get(:@new_profile_identifier) ).to eql(new_resource.identifier) end - it 'should build the shellout remove command correctly' do - new_resource.identifier 'com.testprofile.screensaver' + it "should build the shellout remove command correctly" do + new_resource.identifier "com.testprofile.screensaver" new_resource.action(:remove) provider.load_current_resource expect(provider).to receive(:shell_out).with("profiles -R -p '#{new_resource.identifier}'").and_return(shell_out_success) diff --git a/spec/unit/provider/package/aix_spec.rb b/spec/unit/provider/package/aix_spec.rb index 13992cb8d1..9eb980f5cb 100644 --- a/spec/unit/provider/package/aix_spec.rb +++ b/spec/unit/provider/package/aix_spec.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Aix do before(:each) do diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index f1845abfb1..1f4322041d 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Package::Apt do # XXX: sorry this is ugly and was done quickly to get 12.0.2 out, this file needs a rewrite to use @@ -356,7 +356,7 @@ mpg123 1.12.1-0ubuntu1 describe "when installing a virtual package" do it "should install the package without specifying a version" do - @provider.is_virtual_package['libmysqlclient-dev'] = true + @provider.is_virtual_package["libmysqlclient-dev"] = true expect(@provider).to receive(:shell_out!).with( "apt-get -q -y install libmysqlclient-dev", :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, @@ -369,8 +369,8 @@ mpg123 1.12.1-0ubuntu1 describe "when installing multiple packages" do it "can install a virtual package followed by a non-virtual package" do # https://github.com/chef/chef/issues/2914 - @provider.is_virtual_package['libmysqlclient-dev'] = true - @provider.is_virtual_package['irssi'] = false + @provider.is_virtual_package["libmysqlclient-dev"] = true + @provider.is_virtual_package["irssi"] = false expect(@provider).to receive(:shell_out!).with( "apt-get -q -y install libmysqlclient-dev irssi=0.8.12-7", :env => {"DEBIAN_FRONTEND" => "noninteractive", "LC_ALL" => nil }, diff --git a/spec/unit/provider/package/chocolatey_spec.rb b/spec/unit/provider/package/chocolatey_spec.rb index b2e1d2daaf..406ebcd184 100644 --- a/spec/unit/provider/package/chocolatey_spec.rb +++ b/spec/unit/provider/package/chocolatey_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Chocolatey do let(:timeout) { 900 } diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb index 5b77e7788b..e0bf2accde 100644 --- a/spec/unit/provider/package/dpkg_spec.rb +++ b/spec/unit/provider/package/dpkg_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Dpkg do let(:node) { Chef::Node.new } @@ -114,7 +114,7 @@ Conflicts: wget-ssl expect(provider.current_resource.package_name).to eq(["wget"]) end - describe 'gets the source package version from dpkg-deb' do + describe "gets the source package version from dpkg-deb" do def check_version(version) status = double(:stdout => "wget\t#{version}", :exitstatus => 0) expect(provider).to receive(:shell_out!).with("dpkg-deb -W #{source}", timeout: 900).and_return(status) @@ -123,20 +123,20 @@ Conflicts: wget-ssl expect(provider.candidate_version).to eq([version]) end - it 'if short version provided' do - check_version('1.11.4') + it "if short version provided" do + check_version("1.11.4") end - it 'if extended version provided' do - check_version('1.11.4-1ubuntu1') + it "if extended version provided" do + check_version("1.11.4-1ubuntu1") end - it 'if distro-specific version provided' do - check_version('1.11.4-1ubuntu1~lucid') + it "if distro-specific version provided" do + check_version("1.11.4-1ubuntu1~lucid") end - it 'returns the version if an epoch is used' do - check_version('1:1.8.3-2') + it "returns the version if an epoch is used" do + check_version("1:1.8.3-2") end end @@ -156,7 +156,7 @@ Conflicts: wget-ssl it "gets the source package version from dpkg-deb correctly when the package version has `~', `-', `+' or `.' characters" do provider.load_current_resource - expect(provider.candidate_version).to eq(['1.2.3+3141592-1ubuntu1~lucid']) + expect(provider.candidate_version).to eq(["1.2.3+3141592-1ubuntu1~lucid"]) end end diff --git a/spec/unit/provider/package/easy_install_spec.rb b/spec/unit/provider/package/easy_install_spec.rb index 4ac325e7d4..09d295fec3 100644 --- a/spec/unit/provider/package/easy_install_spec.rb +++ b/spec/unit/provider/package/easy_install_spec.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::EasyInstall do before(:each) do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::EasyInstallPackage.new('boto') - @new_resource.version('1.8d') + @new_resource = Chef::Resource::EasyInstallPackage.new("boto") + @new_resource.version("1.8d") @provider = Chef::Provider::Package::EasyInstall.new(@new_resource, @run_context) diff --git a/spec/unit/provider/package/freebsd/pkg_spec.rb b/spec/unit/provider/package/freebsd/pkg_spec.rb index d1f5a649bc..05660d196a 100644 --- a/spec/unit/provider/package/freebsd/pkg_spec.rb +++ b/spec/unit/provider/package/freebsd/pkg_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do before(:each) do @@ -30,7 +30,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do @provider = Chef::Provider::Package::Freebsd::Pkg.new(@new_resource, @run_context) @provider.current_resource = @current_resource - allow(::File).to receive(:exist?).with('/usr/ports/Makefile').and_return(false) + allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(false) end describe "when determining the current package state" do @@ -107,7 +107,7 @@ describe Chef::Provider::Package::Freebsd::Pkg, "load_current_resource" do end it "should figure out the package name when we have ports" do - allow(::File).to receive(:exist?).with('/usr/ports/Makefile').and_return(true) + allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true) allow(@provider).to receive(:port_path).and_return("/usr/ports/shells/zsh") make_v = OpenStruct.new(:stdout => "zsh-4.3.6_7\n", :exitstatus => 0) expect(@provider).to receive(:shell_out!).with("make -V PKGNAME", {cwd: "/usr/ports/shells/zsh", env: nil, returns: [0, 1], timeout: 900}).and_return(make_v) diff --git a/spec/unit/provider/package/freebsd/pkgng_spec.rb b/spec/unit/provider/package/freebsd/pkgng_spec.rb index 59215f855b..0052300e45 100644 --- a/spec/unit/provider/package/freebsd/pkgng_spec.rb +++ b/spec/unit/provider/package/freebsd/pkgng_spec.rb @@ -17,8 +17,8 @@ # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Package::Freebsd::Port do before(:each) do @@ -34,7 +34,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "initialization" do it "should create a current resource with the name of the new resource" do expect(@provider.current_resource.is_a?(Chef::Resource::Package)).to be_truthy - expect(@provider.current_resource.name).to eq('zsh') + expect(@provider.current_resource.name).to eq("zsh") end end @@ -85,7 +85,7 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should query specified repository when given option" do - @provider.new_resource.options('-r LocalMirror') # This requires LocalMirror repo configuration. + @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration. pkg_query = OpenStruct.new(:stdout => "5.0.3\n", :exitstatus => 0) expect(@provider).to receive(:shell_out!).with("pkg rquery -r LocalMirror '%v' zsh", env: nil, timeout: 900).and_return(pkg_query) expect(@provider.candidate_version).to eq("5.0.3") @@ -106,7 +106,7 @@ describe Chef::Provider::Package::Freebsd::Port do it "should handle package source from file" do @provider.new_resource.source("/nas/pkg/repo/zsh-5.0.1.txz") expect(@provider).to receive(:shell_out!). - with("pkg add /nas/pkg/repo/zsh-5.0.1.txz", env: { 'LC_ALL' => nil }, timeout: 900). + with("pkg add /nas/pkg/repo/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900). and_return(@install_result) @provider.install_package("zsh", "5.0.1") end @@ -114,21 +114,21 @@ describe Chef::Provider::Package::Freebsd::Port do it "should handle package source over ftp or http" do @provider.new_resource.source("http://repo.example.com/zsh-5.0.1.txz") expect(@provider).to receive(:shell_out!). - with("pkg add http://repo.example.com/zsh-5.0.1.txz", env: { 'LC_ALL' => nil }, timeout: 900). + with("pkg add http://repo.example.com/zsh-5.0.1.txz", env: { "LC_ALL" => nil }, timeout: 900). and_return(@install_result) @provider.install_package("zsh", "5.0.1") end it "should handle a package name" do expect(@provider).to receive(:shell_out!). - with("pkg install -y zsh", env: { 'LC_ALL' => nil }, timeout: 900).and_return(@install_result) + with("pkg install -y zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result) @provider.install_package("zsh", "5.0.1") end it "should handle a package name with a specified repo" do - @provider.new_resource.options('-r LocalMirror') # This requires LocalMirror repo configuration. + @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration. expect(@provider).to receive(:shell_out!). - with("pkg install -y -r LocalMirror zsh", env: { 'LC_ALL' => nil }, timeout: 900).and_return(@install_result) + with("pkg install -y -r LocalMirror zsh", env: { "LC_ALL" => nil }, timeout: 900).and_return(@install_result) @provider.install_package("zsh", "5.0.1") end end @@ -146,7 +146,7 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should not include repo option in pkg delete" do - @provider.new_resource.options('-r LocalMirror') # This requires LocalMirror repo configuration. + @provider.new_resource.options("-r LocalMirror") # This requires LocalMirror repo configuration. expect(@provider).to receive(:shell_out!). with("pkg delete -y zsh-5.0.1", env: nil, timeout: 900).and_return(@install_result) @provider.remove_package("zsh", "5.0.1") diff --git a/spec/unit/provider/package/freebsd/port_spec.rb b/spec/unit/provider/package/freebsd/port_spec.rb index 4b23575740..958d505187 100644 --- a/spec/unit/provider/package/freebsd/port_spec.rb +++ b/spec/unit/provider/package/freebsd/port_spec.rb @@ -17,8 +17,8 @@ # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Package::Freebsd::Port do before(:each) do @@ -34,7 +34,7 @@ describe Chef::Provider::Package::Freebsd::Port do describe "initialization" do it "should create a current resource with the name of the new resource" do expect(@provider.current_resource.is_a?(Chef::Resource::Package)).to be_truthy - expect(@provider.current_resource.name).to eq('zsh') + expect(@provider.current_resource.name).to eq("zsh") end end @@ -80,7 +80,7 @@ describe Chef::Provider::Package::Freebsd::Port do pkg_enabled = OpenStruct.new(:stdout => "yes\n") [1000016, 1000000, 901503, 902506, 802511].each do |__freebsd_version| @node.automatic_attrs[:os_version] = __freebsd_version - expect(@new_resource).to receive(:shell_out!).with('make -V WITH_PKGNG', env: nil).and_return(pkg_enabled) + expect(@new_resource).to receive(:shell_out!).with("make -V WITH_PKGNG", env: nil).and_return(pkg_enabled) expect(@provider).to receive(:shell_out!).with('pkg info "zsh"', env: nil, returns: [0,70], timeout: 900).and_return(@pkg_info) expect(@provider.current_installed_version).to eq("3.1.7") end @@ -100,15 +100,15 @@ describe Chef::Provider::Package::Freebsd::Port do end it "should return candidate version if port exists" do - allow(::File).to receive(:exist?).with('/usr/ports/Makefile').and_return(true) - allow(@provider).to receive(:port_dir).and_return('/usr/ports/shells/zsh') + allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(true) + allow(@provider).to receive(:port_dir).and_return("/usr/ports/shells/zsh") expect(@provider).to receive(:shell_out!).with("make -V PORTVERSION", cwd: "/usr/ports/shells/zsh", env: nil, returns: [0,1], timeout: 900). and_return(@port_version) expect(@provider.candidate_version).to eq("5.0.5") end it "should raise exception if ports tree not found" do - allow(::File).to receive(:exist?).with('/usr/ports/Makefile').and_return(false) + allow(::File).to receive(:exist?).with("/usr/ports/Makefile").and_return(false) expect { @provider.candidate_version }.to raise_error(Chef::Exceptions::Package, "Ports collection could not be found") end end diff --git a/spec/unit/provider/package/homebrew_spec.rb b/spec/unit/provider/package/homebrew_spec.rb index 926c1a0ff0..b4a2e16f87 100644 --- a/spec/unit/provider/package/homebrew_spec.rb +++ b/spec/unit/provider/package/homebrew_spec.rb @@ -15,14 +15,14 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Homebrew do let(:node) { Chef::Node.new } - let(:events) { double('Chef::Events').as_null_object } - let(:run_context) { double('Chef::RunContext', node: node, events: events) } - let(:new_resource) { Chef::Resource::HomebrewPackage.new('emacs') } - let(:current_resource) { Chef::Resource::HomebrewPackage.new('emacs')} + let(:events) { double("Chef::Events").as_null_object } + let(:run_context) { double("Chef::RunContext", node: node, events: events) } + let(:new_resource) { Chef::Resource::HomebrewPackage.new("emacs") } + let(:current_resource) { Chef::Resource::HomebrewPackage.new("emacs")} let(:provider) do Chef::Provider::Package::Homebrew.new(new_resource, run_context) @@ -32,85 +32,85 @@ describe Chef::Provider::Package::Homebrew do let(:uninstalled_brew_info) do { - 'name' => 'emacs', - 'homepage' => 'http://www.gnu.org/software/emacs', - 'versions' => { - 'stable' => '24.3', - 'bottle' => false, - 'devel' => nil, - 'head' => nil, + "name" => "emacs", + "homepage" => "http://www.gnu.org/software/emacs", + "versions" => { + "stable" => "24.3", + "bottle" => false, + "devel" => nil, + "head" => nil, }, - 'revision' => 0, - 'installed' => [], - 'linked_keg' => nil, - 'keg_only' => nil, - 'dependencies' => [], - 'conflicts_with' => [], - 'caveats' => nil, - 'options' => [], + "revision" => 0, + "installed" => [], + "linked_keg" => nil, + "keg_only" => nil, + "dependencies" => [], + "conflicts_with" => [], + "caveats" => nil, + "options" => [], } end let(:installed_brew_info) do { - 'name' => 'emacs', - 'homepage' => 'http://www.gnu.org/software/emacs/', - 'versions' => { - 'stable' => '24.3', - 'bottle' => false, - 'devel' => nil, - 'head' => 'HEAD', + "name" => "emacs", + "homepage" => "http://www.gnu.org/software/emacs/", + "versions" => { + "stable" => "24.3", + "bottle" => false, + "devel" => nil, + "head" => "HEAD", }, - 'revision' => 0, - 'installed' => [{ 'version' => '24.3' }], - 'linked_keg' => '24.3', - 'keg_only' => nil, - 'dependencies' => [], - 'conflicts_with' => [], - 'caveats' => '', - 'options' => [], + "revision" => 0, + "installed" => [{ "version" => "24.3" }], + "linked_keg" => "24.3", + "keg_only" => nil, + "dependencies" => [], + "conflicts_with" => [], + "caveats" => "", + "options" => [], } end let(:keg_only_brew_info) do { - 'name' => 'emacs-kegger', - 'homepage' => 'http://www.gnu.org/software/emacs/', - 'versions' => { - 'stable' => '24.3-keggy', - 'bottle' => false, - 'devel' => nil, - 'head' => 'HEAD', + "name" => "emacs-kegger", + "homepage" => "http://www.gnu.org/software/emacs/", + "versions" => { + "stable" => "24.3-keggy", + "bottle" => false, + "devel" => nil, + "head" => "HEAD", }, - 'revision' => 0, - 'installed' => [{ 'version' => '24.3-keggy' }], - 'linked_keg' => nil, - 'keg_only' => true, - 'dependencies' => [], - 'conflicts_with' => [], - 'caveats' => '', - 'options' => [], + "revision" => 0, + "installed" => [{ "version" => "24.3-keggy" }], + "linked_keg" => nil, + "keg_only" => true, + "dependencies" => [], + "conflicts_with" => [], + "caveats" => "", + "options" => [], } end let(:keg_only_uninstalled_brew_info) do { - 'name' => 'emacs-kegger', - 'homepage' => 'http://www.gnu.org/software/emacs/', - 'versions' => { - 'stable' => '24.3-keggy', - 'bottle' => false, - 'devel' => nil, - 'head' => 'HEAD', + "name" => "emacs-kegger", + "homepage" => "http://www.gnu.org/software/emacs/", + "versions" => { + "stable" => "24.3-keggy", + "bottle" => false, + "devel" => nil, + "head" => "HEAD", }, - 'revision' => 0, - 'installed' => [], - 'linked_keg' => nil, - 'keg_only' => true, - 'dependencies' => [], - 'conflicts_with' => [], - 'caveats' => '', - 'options' => [], + "revision" => 0, + "installed" => [], + "linked_keg" => nil, + "keg_only" => true, + "dependencies" => [], + "conflicts_with" => [], + "caveats" => "", + "options" => [], } end @@ -118,174 +118,174 @@ describe Chef::Provider::Package::Homebrew do end - describe 'load_current_resource' do + describe "load_current_resource" do before(:each) do allow(provider).to receive(:current_installed_version).and_return(nil) - allow(provider).to receive(:candidate_version).and_return('24.3') + allow(provider).to receive(:candidate_version).and_return("24.3") end - it 'creates a current resource with the name of the new resource' do + it "creates a current resource with the name of the new resource" do provider.load_current_resource expect(provider.current_resource).to be_a(Chef::Resource::Package) - expect(provider.current_resource.name).to eql('emacs') + expect(provider.current_resource.name).to eql("emacs") end - it 'creates a current resource with the version if the package is installed' do - expect(provider).to receive(:current_installed_version).and_return('24.3') + it "creates a current resource with the version if the package is installed" do + expect(provider).to receive(:current_installed_version).and_return("24.3") provider.load_current_resource - expect(provider.current_resource.version).to eql('24.3') + expect(provider.current_resource.version).to eql("24.3") end - it 'creates a current resource with a nil version if the package is not installed' do + it "creates a current resource with a nil version if the package is not installed" do provider.load_current_resource expect(provider.current_resource.version).to be_nil end - it 'sets a candidate version if one exists' do + it "sets a candidate version if one exists" do provider.load_current_resource - expect(provider.candidate_version).to eql('24.3') + expect(provider.candidate_version).to eql("24.3") end end - describe 'current_installed_version' do - it 'returns the latest version from brew info if the package is keg only' do + describe "current_installed_version" do + it "returns the latest version from brew info if the package is keg only" do allow(provider).to receive(:brew_info).and_return(keg_only_brew_info) - expect(provider.current_installed_version).to eql('24.3-keggy') + expect(provider.current_installed_version).to eql("24.3-keggy") end - it 'returns the linked keg version if the package is not keg only' do + it "returns the linked keg version if the package is not keg only" do allow(provider).to receive(:brew_info).and_return(installed_brew_info) - expect(provider.current_installed_version).to eql('24.3') + expect(provider.current_installed_version).to eql("24.3") end - it 'returns nil if the package is not installed' do + it "returns nil if the package is not installed" do allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info) expect(provider.current_installed_version).to be_nil end - it 'returns nil if the package is keg only and not installed' do + it "returns nil if the package is keg only and not installed" do allow(provider).to receive(:brew_info).and_return(keg_only_uninstalled_brew_info) expect(provider.current_installed_version).to be_nil end end - describe 'brew' do + describe "brew" do before do expect(provider).to receive(:find_homebrew_uid).and_return(homebrew_uid) expect(Etc).to receive(:getpwuid).with(homebrew_uid).and_return(OpenStruct.new(:name => "name", :dir => "/")) end - it 'passes a single to the brew command and return stdout' do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => 'zombo')) - expect(provider.brew).to eql('zombo') + it "passes a single to the brew command and return stdout" do + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo")) + expect(provider.brew).to eql("zombo") end - it 'takes multiple arguments as an array' do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => 'homestarrunner')) - expect(provider.brew('info', 'opts', 'bananas')).to eql('homestarrunner') + it "takes multiple arguments as an array" do + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "homestarrunner")) + expect(provider.brew("info", "opts", "bananas")).to eql("homestarrunner") end context "when new_resource is Package" do - let(:new_resource) { Chef::Resource::Package.new('emacs') } + let(:new_resource) { Chef::Resource::Package.new("emacs") } it "does not try to read homebrew_user from Package, which does not have it" do - allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => 'zombo')) - expect(provider.brew).to eql('zombo') + allow(provider).to receive(:shell_out!).and_return(OpenStruct.new(:stdout => "zombo")) + expect(provider.brew).to eql("zombo") end end end - context 'when testing actions' do + context "when testing actions" do before(:each) do provider.current_resource = current_resource end - describe 'install_package' do + describe "install_package" do before(:each) do - allow(provider).to receive(:candidate_version).and_return('24.3') + allow(provider).to receive(:candidate_version).and_return("24.3") end - it 'installs the named package with brew install' do - allow(provider.new_resource).to receive(:version).and_return('24.3') + it "installs the named package with brew install" do + allow(provider.new_resource).to receive(:version).and_return("24.3") allow(provider.current_resource).to receive(:version).and_return(nil) allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info) - expect(provider).to receive(:get_response_from_command).with('brew install emacs') - provider.install_package('emacs', '24.3') + expect(provider).to receive(:get_response_from_command).with("brew install emacs") + provider.install_package("emacs", "24.3") end - it 'does not do anything if the package is installed' do - allow(provider.current_resource).to receive(:version).and_return('24.3') + it "does not do anything if the package is installed" do + allow(provider.current_resource).to receive(:version).and_return("24.3") allow(provider).to receive(:brew_info).and_return(installed_brew_info) expect(provider).not_to receive(:get_response_from_command) - provider.install_package('emacs', '24.3') + provider.install_package("emacs", "24.3") end - it 'uses options to the brew command if specified' do - allow(provider.new_resource).to receive(:options).and_return('--cocoa') - allow(provider.current_resource).to receive(:version).and_return('24.3') - allow(provider).to receive(:get_response_from_command).with('brew install --cocoa emacs') - provider.install_package('emacs', '24.3') + it "uses options to the brew command if specified" do + allow(provider.new_resource).to receive(:options).and_return("--cocoa") + allow(provider.current_resource).to receive(:version).and_return("24.3") + allow(provider).to receive(:get_response_from_command).with("brew install --cocoa emacs") + provider.install_package("emacs", "24.3") end end - describe 'upgrade_package' do - it 'uses brew upgrade to upgrade the package if it is installed' do - allow(provider.current_resource).to receive(:version).and_return('24') + describe "upgrade_package" do + it "uses brew upgrade to upgrade the package if it is installed" do + allow(provider.current_resource).to receive(:version).and_return("24") allow(provider).to receive(:brew_info).and_return(installed_brew_info) - expect(provider).to receive(:get_response_from_command).with('brew upgrade emacs') - provider.upgrade_package('emacs', '24.3') + expect(provider).to receive(:get_response_from_command).with("brew upgrade emacs") + provider.upgrade_package("emacs", "24.3") end - it 'does not do anything if the package version is already installed' do - allow(provider.current_resource).to receive(:version).and_return('24.3') + it "does not do anything if the package version is already installed" do + allow(provider.current_resource).to receive(:version).and_return("24.3") allow(provider).to receive(:brew_info).and_return(installed_brew_info) expect(provider).not_to receive(:get_response_from_command) - provider.install_package('emacs', '24.3') + provider.install_package("emacs", "24.3") end - it 'uses brew install to install the package if it is not installed' do + it "uses brew install to install the package if it is not installed" do allow(provider.current_resource).to receive(:version).and_return(nil) allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info) - expect(provider).to receive(:get_response_from_command).with('brew install emacs') - provider.upgrade_package('emacs', '24.3') + expect(provider).to receive(:get_response_from_command).with("brew install emacs") + provider.upgrade_package("emacs", "24.3") end - it 'uses options to the brew command if specified' do - allow(provider.current_resource).to receive(:version).and_return('24') + it "uses options to the brew command if specified" do + allow(provider.current_resource).to receive(:version).and_return("24") allow(provider).to receive(:brew_info).and_return(installed_brew_info) - allow(provider.new_resource).to receive(:options).and_return('--cocoa') - expect(provider).to receive(:get_response_from_command).with('brew upgrade --cocoa emacs') - provider.upgrade_package('emacs', '24.3') + allow(provider.new_resource).to receive(:options).and_return("--cocoa") + expect(provider).to receive(:get_response_from_command).with("brew upgrade --cocoa emacs") + provider.upgrade_package("emacs", "24.3") end end - describe 'remove_package' do - it 'uninstalls the package with brew uninstall' do - allow(provider.current_resource).to receive(:version).and_return('24.3') + describe "remove_package" do + it "uninstalls the package with brew uninstall" do + allow(provider.current_resource).to receive(:version).and_return("24.3") allow(provider).to receive(:brew_info).and_return(installed_brew_info) - expect(provider).to receive(:get_response_from_command).with('brew uninstall emacs') - provider.remove_package('emacs', '24.3') + expect(provider).to receive(:get_response_from_command).with("brew uninstall emacs") + provider.remove_package("emacs", "24.3") end - it 'does not do anything if the package is not installed' do + it "does not do anything if the package is not installed" do allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info) expect(provider).not_to receive(:get_response_from_command) - provider.remove_package('emacs', '24.3') + provider.remove_package("emacs", "24.3") end end - describe 'purge_package' do - it 'uninstalls the package with brew uninstall --force' do - allow(provider.current_resource).to receive(:version).and_return('24.3') + describe "purge_package" do + it "uninstalls the package with brew uninstall --force" do + allow(provider.current_resource).to receive(:version).and_return("24.3") allow(provider).to receive(:brew_info).and_return(installed_brew_info) - expect(provider).to receive(:get_response_from_command).with('brew uninstall --force emacs') - provider.purge_package('emacs', '24.3') + expect(provider).to receive(:get_response_from_command).with("brew uninstall --force emacs") + provider.purge_package("emacs", "24.3") end - it 'does not do anything if the package is not installed' do + it "does not do anything if the package is not installed" do allow(provider).to receive(:brew_info).and_return(uninstalled_brew_info) expect(provider).not_to receive(:get_response_from_command) - provider.purge_package('emacs', '24.3') + provider.purge_package("emacs", "24.3") end end end diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb index ad69dffb10..bc29e30fd8 100644 --- a/spec/unit/provider/package/ips_spec.rb +++ b/spec/unit/provider/package/ips_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" # based on the apt specs @@ -34,7 +34,7 @@ describe Chef::Provider::Package::Ips do def local_output stdin = StringIO.new - stdout = '' + stdout = "" stderr =<<-PKG_STATUS pkg: info: no packages matching the following patterns you specified are installed on the system. Try specifying -r to query remotely: @@ -59,7 +59,7 @@ Packaging Date: April 1, 2012 05:55:52 PM FMRI: pkg://omnios/security/sudo@1.8.4.1,5.11-0.151002:20120401T175552Z PKG_STATUS stdin = StringIO.new - stderr = '' + stderr = "" return OpenStruct.new(:stdout => stdout,:stdin => stdin,:stderr => stderr,:status => @status,:exitstatus => 0) end diff --git a/spec/unit/provider/package/macports_spec.rb b/spec/unit/provider/package/macports_spec.rb index eef84113b4..83b6e04be9 100644 --- a/spec/unit/provider/package/macports_spec.rb +++ b/spec/unit/provider/package/macports_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Macports do before(:each) do diff --git a/spec/unit/provider/package/openbsd_spec.rb b/spec/unit/provider/package/openbsd_spec.rb index 8407f83785..0801b4b233 100644 --- a/spec/unit/provider/package/openbsd_spec.rb +++ b/spec/unit/provider/package/openbsd_spec.rb @@ -16,14 +16,14 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Package::Openbsd do let(:node) do node = Chef::Node.new - node.default['kernel'] = {'name' => 'OpenBSD', 'release' => '5.5', 'machine' => 'amd64'} + node.default["kernel"] = {"name" => "OpenBSD", "release" => "5.5", "machine" => "amd64"} node end @@ -36,24 +36,24 @@ describe Chef::Provider::Package::Openbsd do let(:new_resource) { Chef::Resource::Package.new(name)} before(:each) do - ENV['PKG_PATH'] = nil + ENV["PKG_PATH"] = nil end describe "install a package" do - let(:name) { 'ihavetoes' } - let(:version) {'0.0'} + let(:name) { "ihavetoes" } + let(:version) {"0.0"} - context 'when not already installed' do + context "when not already installed" do before do - allow(provider).to receive(:shell_out!).with("pkg_info -e \"#{name}->0\"", anything()).and_return(instance_double('shellout', :stdout => '')) + allow(provider).to receive(:shell_out!).with("pkg_info -e \"#{name}->0\"", anything()).and_return(instance_double("shellout", :stdout => "")) end - context 'when there is a single candidate' do + context "when there is a single candidate" do - context 'when source is not provided' do - it 'should run the installation command' do + context "when source is not provided" do + it "should run the installation command" do expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return( - instance_double('shellout', :stdout => "#{name}-#{version}\n")) + instance_double("shellout", :stdout => "#{name}-#{version}\n")) expect(provider).to receive(:shell_out!).with( "pkg_add -r #{name}-#{version}", {:env => {"PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/"}, timeout: 900} @@ -63,29 +63,29 @@ describe Chef::Provider::Package::Openbsd do end end - context 'when there are multiple candidates' do - let(:flavor_a) { 'flavora' } - let(:flavor_b) { 'flavorb' } + context "when there are multiple candidates" do + let(:flavor_a) { "flavora" } + let(:flavor_b) { "flavorb" } - context 'if no version is specified' do - it 'should raise an exception' do + context "if no version is specified" do + it "should raise an exception" do expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return( - instance_double('shellout', :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n")) + instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n#{name}-#{version}-#{flavor_b}\n")) expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package, /multiple matching candidates/) end end - context 'if a flavor is specified' do + context "if a flavor is specified" do - let(:flavor) { 'flavora' } - let(:package_name) {'ihavetoes' } + let(:flavor) { "flavora" } + let(:package_name) {"ihavetoes" } let(:name) { "#{package_name}--#{flavor}" } - context 'if no version is specified' do - it 'should run the installation command' do - expect(provider).to receive(:shell_out!).with("pkg_info -e \"#{package_name}->0\"", anything()).and_return(instance_double('shellout', :stdout => '')) + context "if no version is specified" do + it "should run the installation command" do + expect(provider).to receive(:shell_out!).with("pkg_info -e \"#{package_name}->0\"", anything()).and_return(instance_double("shellout", :stdout => "")) expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}\"", anything()).and_return( - instance_double('shellout', :stdout => "#{name}-#{version}-#{flavor}\n")) + instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor}\n")) expect(provider).to receive(:shell_out!).with( "pkg_add -r #{name}-#{version}-#{flavor}", {env: {"PKG_PATH" => "http://ftp.OpenBSD.org/pub/OpenBSD/5.5/packages/amd64/"}, timeout: 900} @@ -96,10 +96,10 @@ describe Chef::Provider::Package::Openbsd do end - context 'if a version is specified' do - it 'should use the flavor from the version' do + context "if a version is specified" do + it "should use the flavor from the version" do expect(provider).to receive(:shell_out!).with("pkg_info -I \"#{name}-#{version}-#{flavor_b}\"", anything()).and_return( - instance_double('shellout', :stdout => "#{name}-#{version}-#{flavor_a}\n")) + instance_double("shellout", :stdout => "#{name}-#{version}-#{flavor_a}\n")) new_resource.version("#{version}-#{flavor_b}") expect(provider).to receive(:shell_out!).with( @@ -115,7 +115,7 @@ describe Chef::Provider::Package::Openbsd do describe "delete a package" do before do - @name = 'ihavetoes' + @name = "ihavetoes" @new_resource = Chef::Resource::Package.new(@name) @current_resource = Chef::Resource::Package.new(@name) @provider = Chef::Provider::Package::Openbsd.new(@new_resource, @run_context) diff --git a/spec/unit/provider/package/pacman_spec.rb b/spec/unit/provider/package/pacman_spec.rb index da27edafeb..4b715da8b6 100644 --- a/spec/unit/provider/package/pacman_spec.rb +++ b/spec/unit/provider/package/pacman_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Pacman do before(:each) do diff --git a/spec/unit/provider/package/paludis_spec.rb b/spec/unit/provider/package/paludis_spec.rb index 4ed5dfc003..05c1e529b7 100644 --- a/spec/unit/provider/package/paludis_spec.rb +++ b/spec/unit/provider/package/paludis_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" # based on the ips specs diff --git a/spec/unit/provider/package/portage_spec.rb b/spec/unit/provider/package/portage_spec.rb index 55743dbeaf..a73db877b6 100644 --- a/spec/unit/provider/package/portage_spec.rb +++ b/spec/unit/provider/package/portage_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Portage, "load_current_resource" do before(:each) do diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb index ad9d694e34..409b5268ee 100644 --- a/spec/unit/provider/package/rpm_spec.rb +++ b/spec/unit/provider/package/rpm_spec.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Rpm do let(:provider) { Chef::Provider::Package::Rpm.new(new_resource, run_context) } @@ -35,10 +35,10 @@ describe Chef::Provider::Package::Rpm do end # `rpm -qp [stuff] $source` - let(:rpm_qp_status) { instance_double('Mixlib::ShellOut', exitstatus: rpm_qp_exitstatus, stdout: rpm_qp_stdout) } + let(:rpm_qp_status) { instance_double("Mixlib::ShellOut", exitstatus: rpm_qp_exitstatus, stdout: rpm_qp_stdout) } # `rpm -q [stuff] $package_name` - let(:rpm_q_status) { instance_double('Mixlib::ShellOut', exitstatus: rpm_q_exitstatus, stdout: rpm_q_stdout) } + let(:rpm_q_status) { instance_double("Mixlib::ShellOut", exitstatus: rpm_q_exitstatus, stdout: rpm_q_stdout) } before(:each) do allow(::File).to receive(:exists?).with("PLEASE STUB File.exists? EXACTLY").and_return(true) diff --git a/spec/unit/provider/package/rubygems_spec.rb b/spec/unit/provider/package/rubygems_spec.rb index 5e4d8a6224..85de24fdb4 100644 --- a/spec/unit/provider/package/rubygems_spec.rb +++ b/spec/unit/provider/package/rubygems_spec.rb @@ -16,7 +16,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'pp' +require "pp" module GemspecBackcompatCreator def gemspec(name, version) @@ -28,8 +28,8 @@ module GemspecBackcompatCreator end end -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do include GemspecBackcompatCreator @@ -43,18 +43,18 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do end it "determines the installed versions of gems from Gem.source_index" do - gems = [gemspec('rspec-core', Gem::Version.new('1.2.9')), gemspec('rspec-core', Gem::Version.new('1.3.0'))] - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0') - expect(Gem::Specification).to receive(:find_all_by_name).with('rspec-core', Gem::Dependency.new('rspec-core').requirement).and_return(gems) + gems = [gemspec("rspec-core", Gem::Version.new("1.2.9")), gemspec("rspec-core", Gem::Version.new("1.3.0"))] + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0") + expect(Gem::Specification).to receive(:find_all_by_name).with("rspec-core", Gem::Dependency.new("rspec-core").requirement).and_return(gems) else - expect(Gem.source_index).to receive(:search).with(Gem::Dependency.new('rspec-core', nil)).and_return(gems) + expect(Gem.source_index).to receive(:search).with(Gem::Dependency.new("rspec-core", nil)).and_return(gems) end - expect(@gem_env.installed_versions(Gem::Dependency.new('rspec-core', nil))).to eq(gems) + expect(@gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil))).to eq(gems) end it "determines the installed versions of gems from the source index (part2: the unmockening)" do - expected = ['rspec-core', Gem::Version.new(RSpec::Core::Version::STRING)] - actual = @gem_env.installed_versions(Gem::Dependency.new('rspec-core', nil)).map { |spec| [spec.name, spec.version] } + expected = ["rspec-core", Gem::Version.new(RSpec::Core::Version::STRING)] + actual = @gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil)).map { |spec| [spec.name, spec.version] } expect(actual).to include(expected) end @@ -87,16 +87,16 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do end it "finds a matching gem candidate version" do - dep = Gem::Dependency.new('rspec', '>= 0') + dep = Gem::Dependency.new("rspec", ">= 0") dep_installer = Gem::DependencyInstaller.new allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer) latest = [[gemspec("rspec", Gem::Version.new("1.3.0")), "https://rubygems.org/"]] expect(dep_installer).to receive(:find_gems_with_sources).with(dep).and_return(latest) - expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0'))).to eq(Gem::Version.new('1.3.0')) + expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new("rspec", ">= 0"))).to eq(Gem::Version.new("1.3.0")) end it "finds a matching gem candidate version on rubygems 2.0.0+" do - dep = Gem::Dependency.new('rspec', '>= 0') + dep = Gem::Dependency.new("rspec", ">= 0") dep_installer = Gem::DependencyInstaller.new allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer) best_gem = double("best gem match", :spec => gemspec("rspec", Gem::Version.new("1.3.0")), :source => "https://rubygems.org") @@ -104,62 +104,62 @@ describe Chef::Provider::Package::Rubygems::CurrentGemEnvironment do expect(available_set).to receive(:pick_best!) expect(available_set).to receive(:set).and_return([best_gem]) expect(dep_installer).to receive(:find_gems_with_sources).with(dep).and_return(available_set) - expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0'))).to eq(Gem::Version.new('1.3.0')) + expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new("rspec", ">= 0"))).to eq(Gem::Version.new("1.3.0")) end it "gives the candidate version as nil if none is found" do - dep = Gem::Dependency.new('rspec', '>= 0') + dep = Gem::Dependency.new("rspec", ">= 0") latest = [] dep_installer = Gem::DependencyInstaller.new allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer) expect(dep_installer).to receive(:find_gems_with_sources).with(dep).and_return(latest) - expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>= 0'))).to be_nil + expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new("rspec", ">= 0"))).to be_nil end it "finds a matching candidate version from a .gem file when the path to the gem is supplied" do - location = CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem' - expect(@gem_env.candidate_version_from_file(Gem::Dependency.new('chef-integration-test', '>= 0'), location)).to eq(Gem::Version.new('0.1.0')) - expect(@gem_env.candidate_version_from_file(Gem::Dependency.new('chef-integration-test', '>= 0.2.0'), location)).to be_nil + location = CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem" + expect(@gem_env.candidate_version_from_file(Gem::Dependency.new("chef-integration-test", ">= 0"), location)).to eq(Gem::Version.new("0.1.0")) + expect(@gem_env.candidate_version_from_file(Gem::Dependency.new("chef-integration-test", ">= 0.2.0"), location)).to be_nil end it "finds a matching gem from a specific gemserver when explicit sources are given" do - dep = Gem::Dependency.new('rspec', '>= 0') + dep = Gem::Dependency.new("rspec", ">= 0") latest = [[gemspec("rspec", Gem::Version.new("1.3.0")), "https://rubygems.org/"]] - expect(@gem_env).to receive(:with_gem_sources).with('http://gems.example.com').and_yield + expect(@gem_env).to receive(:with_gem_sources).with("http://gems.example.com").and_yield dep_installer = Gem::DependencyInstaller.new allow(@gem_env).to receive(:dependency_installer).and_return(dep_installer) expect(dep_installer).to receive(:find_gems_with_sources).with(dep).and_return(latest) - expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new('rspec', '>=0'), 'http://gems.example.com')).to eq(Gem::Version.new('1.3.0')) + expect(@gem_env.candidate_version_from_remote(Gem::Dependency.new("rspec", ">=0"), "http://gems.example.com")).to eq(Gem::Version.new("1.3.0")) end it "installs a gem with a hash of options for the dependency installer" do dep_installer = Gem::DependencyInstaller.new - expect(@gem_env).to receive(:dependency_installer).with(:install_dir => '/foo/bar').and_return(dep_installer) - expect(@gem_env).to receive(:with_gem_sources).with('http://gems.example.com').and_yield - expect(dep_installer).to receive(:install).with(Gem::Dependency.new('rspec', '>= 0')) - @gem_env.install(Gem::Dependency.new('rspec', '>= 0'), :install_dir => '/foo/bar', :sources => ['http://gems.example.com']) + expect(@gem_env).to receive(:dependency_installer).with(:install_dir => "/foo/bar").and_return(dep_installer) + expect(@gem_env).to receive(:with_gem_sources).with("http://gems.example.com").and_yield + expect(dep_installer).to receive(:install).with(Gem::Dependency.new("rspec", ">= 0")) + @gem_env.install(Gem::Dependency.new("rspec", ">= 0"), :install_dir => "/foo/bar", :sources => ["http://gems.example.com"]) end it "builds an uninstaller for a gem with options set to avoid requiring user input" do # default options for uninstaller should be: # :ignore => true, :executables => true - expect(Gem::Uninstaller).to receive(:new).with('rspec', :ignore => true, :executables => true) - @gem_env.uninstaller('rspec') + expect(Gem::Uninstaller).to receive(:new).with("rspec", :ignore => true, :executables => true) + @gem_env.uninstaller("rspec") end it "uninstalls all versions of a gem" do - uninstaller = double('gem uninstaller') + uninstaller = double("gem uninstaller") expect(uninstaller).to receive(:uninstall) - expect(@gem_env).to receive(:uninstaller).with('rspec', :all => true).and_return(uninstaller) - @gem_env.uninstall('rspec') + expect(@gem_env).to receive(:uninstaller).with("rspec", :all => true).and_return(uninstaller) + @gem_env.uninstall("rspec") end it "uninstalls a specific version of a gem" do - uninstaller = double('gem uninstaller') + uninstaller = double("gem uninstaller") expect(uninstaller).to receive(:uninstall) - expect(@gem_env).to receive(:uninstaller).with('rspec', :version => '1.2.3').and_return(uninstaller) - @gem_env.uninstall('rspec', '1.2.3') + expect(@gem_env).to receive(:uninstaller).with("rspec", :version => "1.2.3").and_return(uninstaller) + @gem_env.uninstall("rspec", "1.2.3") end end @@ -170,54 +170,54 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do before do Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache.clear Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache.clear - @gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new('/usr/weird/bin/gem') + @gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new("/usr/weird/bin/gem") end it "determines the gem paths from shelling out to gem env" do - gem_env_output = ['/path/to/gems', '/another/path/to/gems'].join(File::PATH_SEPARATOR) + gem_env_output = ["/path/to/gems", "/another/path/to/gems"].join(File::PATH_SEPARATOR) shell_out_result = OpenStruct.new(:stdout => gem_env_output) - expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env gempath').and_return(shell_out_result) - expect(@gem_env.gem_paths).to eq(['/path/to/gems', '/another/path/to/gems']) + expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env gempath").and_return(shell_out_result) + expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"]) end it "caches the gempaths by gem_binary" do - gem_env_output = ['/path/to/gems', '/another/path/to/gems'].join(File::PATH_SEPARATOR) + gem_env_output = ["/path/to/gems", "/another/path/to/gems"].join(File::PATH_SEPARATOR) shell_out_result = OpenStruct.new(:stdout => gem_env_output) - expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env gempath').and_return(shell_out_result) - expected = ['/path/to/gems', '/another/path/to/gems'] - expect(@gem_env.gem_paths).to eq(['/path/to/gems', '/another/path/to/gems']) - expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache['/usr/weird/bin/gem']).to eq(expected) + expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env gempath").and_return(shell_out_result) + expected = ["/path/to/gems", "/another/path/to/gems"] + expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"]) + expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"]).to eq(expected) end it "uses the cached result for gem paths when available" do expect(@gem_env).not_to receive(:shell_out!) - expected = ['/path/to/gems', '/another/path/to/gems'] - Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache['/usr/weird/bin/gem']= expected - expect(@gem_env.gem_paths).to eq(['/path/to/gems', '/another/path/to/gems']) + expected = ["/path/to/gems", "/another/path/to/gems"] + Chef::Provider::Package::Rubygems::AlternateGemEnvironment.gempath_cache["/usr/weird/bin/gem"]= expected + expect(@gem_env.gem_paths).to eq(["/path/to/gems", "/another/path/to/gems"]) end it "builds the gems source index from the gem paths" do - allow(@gem_env).to receive(:gem_paths).and_return(['/path/to/gems', '/another/path/to/gems']) - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0') + allow(@gem_env).to receive(:gem_paths).and_return(["/path/to/gems", "/another/path/to/gems"]) + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0") @gem_env.gem_specification - expect(Gem::Specification.dirs).to eq([ '/path/to/gems/specifications', '/another/path/to/gems/specifications' ]) + expect(Gem::Specification.dirs).to eq([ "/path/to/gems/specifications", "/another/path/to/gems/specifications" ]) else - expect(Gem::SourceIndex).to receive(:from_gems_in).with('/path/to/gems/specifications', '/another/path/to/gems/specifications') + expect(Gem::SourceIndex).to receive(:from_gems_in).with("/path/to/gems/specifications", "/another/path/to/gems/specifications") @gem_env.gem_source_index end end it "determines the installed versions of gems from the source index" do - gems = [gemspec('rspec', Gem::Version.new('1.2.9')), gemspec('rspec', Gem::Version.new('1.3.0'))] - rspec_dep = Gem::Dependency.new('rspec', nil) - if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.8.0') + gems = [gemspec("rspec", Gem::Version.new("1.2.9")), gemspec("rspec", Gem::Version.new("1.3.0"))] + rspec_dep = Gem::Dependency.new("rspec", nil) + if Gem::Version.new(Gem::VERSION) >= Gem::Version.new("1.8.0") allow(@gem_env).to receive(:gem_specification).and_return(Gem::Specification) expect(@gem_env.gem_specification).to receive(:find_all_by_name).with(rspec_dep.name, rspec_dep.requirement).and_return(gems) else allow(@gem_env).to receive(:gem_source_index).and_return(Gem.source_index) expect(@gem_env.gem_source_index).to receive(:search).with(rspec_dep).and_return(gems) end - expect(@gem_env.installed_versions(Gem::Dependency.new('rspec', nil))).to eq(gems) + expect(@gem_env.installed_versions(Gem::Dependency.new("rspec", nil))).to eq(gems) end it "determines the installed versions of gems from the source index (part2: the unmockening)" do @@ -229,8 +229,8 @@ describe Chef::Provider::Package::Rubygems::AlternateGemEnvironment do end skip("cant find your gem executable") if path_to_gem.empty? gem_env = Chef::Provider::Package::Rubygems::AlternateGemEnvironment.new(path_to_gem) - expected = ['rspec-core', Gem::Version.new(RSpec::Core::Version::STRING)] - actual = gem_env.installed_versions(Gem::Dependency.new('rspec-core', nil)).map { |s| [s.name, s.version] } + expected = ["rspec-core", Gem::Version.new(RSpec::Core::Version::STRING)] + actual = gem_env.installed_versions(Gem::Dependency.new("rspec-core", nil)).map { |s| [s.name, s.version] } expect(actual).to include(expected) end @@ -262,17 +262,17 @@ RubyGems Environment: - https://rubygems.org/ - http://gems.github.com/ JRUBY_GEM_ENV - expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(double('jruby_gem_env', :stdout => gem_env_out)) - expected = ['ruby', Gem::Platform.new('universal-java-1.6')] + expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env").and_return(double("jruby_gem_env", :stdout => gem_env_out)) + expected = ["ruby", Gem::Platform.new("universal-java-1.6")] expect(@gem_env.gem_platforms).to eq(expected) # it should also cache the result - expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache['/usr/weird/bin/gem']).to eq(expected) + expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]).to eq(expected) end it "uses the cached result for gem platforms if available" do expect(@gem_env).not_to receive(:shell_out!) - expected = ['ruby', Gem::Platform.new('universal-java-1.6')] - Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache['/usr/weird/bin/gem']= expected + expected = ["ruby", Gem::Platform.new("universal-java-1.6")] + Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]= expected expect(@gem_env.gem_platforms).to eq(expected) end @@ -304,22 +304,22 @@ RubyGems Environment: - https://rubygems.org/ - http://gems.github.com/ RBX_GEM_ENV - expect(@gem_env).to receive(:shell_out!).with('/usr/weird/bin/gem env').and_return(double('rbx_gem_env', :stdout => gem_env_out)) + expect(@gem_env).to receive(:shell_out!).with("/usr/weird/bin/gem env").and_return(double("rbx_gem_env", :stdout => gem_env_out)) expect(@gem_env.gem_platforms).to eq(Gem.platforms) - expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache['/usr/weird/bin/gem']).to eq(Gem.platforms) + expect(Chef::Provider::Package::Rubygems::AlternateGemEnvironment.platform_cache["/usr/weird/bin/gem"]).to eq(Gem.platforms) end it "yields to a block while masquerading as a different gems platform" do original_platforms = Gem.platforms platforms_in_block = nil begin - @gem_env.with_gem_platforms(['ruby', Gem::Platform.new('sparc64-java-1.7')]) do + @gem_env.with_gem_platforms(["ruby", Gem::Platform.new("sparc64-java-1.7")]) do platforms_in_block = Gem.platforms raise "gem platforms should get set to the correct value even when an error occurs" end rescue RuntimeError end - expect(platforms_in_block).to eq(['ruby', Gem::Platform.new('sparc64-java-1.7')]) + expect(platforms_in_block).to eq(["ruby", Gem::Platform.new("sparc64-java-1.7")]) expect(Gem.platforms).to eq(original_platforms) end @@ -336,9 +336,9 @@ describe Chef::Provider::Package::Rubygems do @run_context = Chef::RunContext.new(@node, {}, @events) # We choose detect omnibus via RbConfig::CONFIG['bindir'] in Chef::Provider::Package::Rubygems.new - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/usr/bin/ruby") + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/usr/bin/ruby") # Rubygems uses this interally - allow(RbConfig::CONFIG).to receive(:[]).with('arch').and_call_original + allow(RbConfig::CONFIG).to receive(:[]).with("arch").and_call_original @provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context) end @@ -364,45 +364,45 @@ describe Chef::Provider::Package::Rubygems do end it "uses the AlternateGemEnvironment implementation when a gem_binary_path is provided" do - @new_resource.gem_binary('/usr/weird/bin/gem') + @new_resource.gem_binary("/usr/weird/bin/gem") provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context) - expect(provider.gem_env.gem_binary_location).to eq('/usr/weird/bin/gem') + expect(provider.gem_env.gem_binary_location).to eq("/usr/weird/bin/gem") end it "recognizes chef as omnibus" do - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/opt/chef/embedded/bin") + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/chef/embedded/bin") provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context) expect(provider.is_omnibus?).to be true end it "recognizes opscode as omnibus" do - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/opt/opscode/embedded/bin") + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/opscode/embedded/bin") provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context) expect(provider.is_omnibus?).to be true end it "recognizes chefdk as omnibus" do - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/opt/chefdk/embedded/bin") + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/chefdk/embedded/bin") provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context) expect(provider.is_omnibus?).to be true end it "searches for a gem binary when running on Omnibus on Unix" do platform_mock :unix do - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("/opt/chef/embedded/bin") - allow(ENV).to receive(:[]).with('PATH').and_return("/usr/bin:/usr/sbin:/opt/chef/embedded/bin") - allow(File).to receive(:exists?).with('/usr/bin/gem').and_return(false) - allow(File).to receive(:exists?).with('/usr/sbin/gem').and_return(true) - allow(File).to receive(:exists?).with('/opt/chef/embedded/bin/gem').and_return(true) # should not get here + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("/opt/chef/embedded/bin") + allow(ENV).to receive(:[]).with("PATH").and_return("/usr/bin:/usr/sbin:/opt/chef/embedded/bin") + allow(File).to receive(:exists?).with("/usr/bin/gem").and_return(false) + allow(File).to receive(:exists?).with("/usr/sbin/gem").and_return(true) + allow(File).to receive(:exists?).with("/opt/chef/embedded/bin/gem").and_return(true) # should not get here provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context) - expect(provider.gem_env.gem_binary_location).to eq('/usr/sbin/gem') + expect(provider.gem_env.gem_binary_location).to eq("/usr/sbin/gem") end end it "searches for a gem binary when running on Omnibus on Windows" do platform_mock :windows do - allow(RbConfig::CONFIG).to receive(:[]).with('bindir').and_return("d:/opscode/chef/embedded/bin") - allow(ENV).to receive(:[]).with('PATH').and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin;d:\opscode\chef\embedded\bin') + allow(RbConfig::CONFIG).to receive(:[]).with("bindir").and_return("d:/opscode/chef/embedded/bin") + allow(ENV).to receive(:[]).with("PATH").and_return('C:\windows\system32;C:\windows;C:\Ruby186\bin;d:\opscode\chef\embedded\bin') allow(File).to receive(:exists?).with('C:\\windows\\system32\\gem').and_return(false) allow(File).to receive(:exists?).with('C:\\windows\\gem').and_return(false) allow(File).to receive(:exists?).with('C:\\Ruby186\\bin\\gem').and_return(true) @@ -414,15 +414,15 @@ describe Chef::Provider::Package::Rubygems do end it "smites you when you try to use a hash of install options with an explicit gem binary" do - @new_resource.gem_binary('/foo/bar') + @new_resource.gem_binary("/foo/bar") @new_resource.options(:fail => :burger) expect {Chef::Provider::Package::Rubygems.new(@new_resource, @run_context)}.to raise_error(ArgumentError) end it "converts the new resource into a gem dependency" do - expect(@provider.gem_dependency).to eq(Gem::Dependency.new('rspec-core', @spec_version)) - @new_resource.version('~> 1.2.0') - expect(@provider.gem_dependency).to eq(Gem::Dependency.new('rspec-core', '~> 1.2.0')) + expect(@provider.gem_dependency).to eq(Gem::Dependency.new("rspec-core", @spec_version)) + @new_resource.version("~> 1.2.0") + expect(@provider.gem_dependency).to eq(Gem::Dependency.new("rspec-core", "~> 1.2.0")) end describe "when determining the currently installed version" do @@ -433,7 +433,7 @@ describe Chef::Provider::Package::Rubygems do end it "sets the current version to the highest installed version if the requested version is not installed" do - @new_resource.version('9000.0.2') + @new_resource.version("9000.0.2") @provider.load_current_resource expect(@provider.current_resource.version).to eq(@spec_version) end @@ -454,31 +454,31 @@ describe Chef::Provider::Package::Rubygems do end it "determines the candidate version by querying the remote gem servers" do - @new_resource.source('http://mygems.example.com') + @new_resource.source("http://mygems.example.com") @provider.load_current_resource - @provider.current_resource.version('0.0.1') + @provider.current_resource.version("0.0.1") version = Gem::Version.new(@spec_version) expect(@provider.gem_env).to receive(:candidate_version_from_remote). - with(Gem::Dependency.new('rspec-core', @spec_version), "http://mygems.example.com"). + with(Gem::Dependency.new("rspec-core", @spec_version), "http://mygems.example.com"). and_return(version) expect(@provider.candidate_version).to eq(@spec_version) end it "parses the gem's specification if the requested source is a file" do - @new_resource.package_name('chef-integration-test') - @new_resource.source(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') - @new_resource.version('>= 0') + @new_resource.package_name("chef-integration-test") + @new_resource.source(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") + @new_resource.version(">= 0") @provider.load_current_resource - expect(@provider.candidate_version).to eq('0.1.0') + expect(@provider.candidate_version).to eq("0.1.0") end end describe "when installing a gem" do before do - @current_resource = Chef::Resource::GemPackage.new('rspec-core') + @current_resource = Chef::Resource::GemPackage.new("rspec-core") @provider.current_resource = @current_resource - @gem_dep = Gem::Dependency.new('rspec-core', @spec_version) + @gem_dep = Gem::Dependency.new("rspec-core", @spec_version) allow(@provider).to receive(:load_current_resource) end @@ -490,26 +490,26 @@ describe Chef::Provider::Package::Rubygems do end it "installs the gem via the gems api when a remote source is provided" do - @new_resource.source('http://gems.example.org') - sources = ['http://gems.example.org'] + @new_resource.source("http://gems.example.org") + sources = ["http://gems.example.org"] expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => sources) @provider.run_action(:install) expect(@new_resource).to be_updated_by_last_action end it "installs the gem from file via the gems api when no explicit options are used" do - @new_resource.source(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') - expect(@provider.gem_env).to receive(:install).with(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') + @new_resource.source(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") + expect(@provider.gem_env).to receive(:install).with(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") @provider.run_action(:install) expect(@new_resource).to be_updated_by_last_action end it "installs the gem from file via the gems api when the package is a path and the source is nil" do - @new_resource = Chef::Resource::GemPackage.new(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') + @new_resource = Chef::Resource::GemPackage.new(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") @provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context) @provider.current_resource = @current_resource - expect(@new_resource.source).to eq(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') - expect(@provider.gem_env).to receive(:install).with(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') + expect(@new_resource.source).to eq(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") + expect(@provider.gem_env).to receive(:install).with(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") @provider.run_action(:install) expect(@new_resource).to be_updated_by_last_action end @@ -517,14 +517,14 @@ describe Chef::Provider::Package::Rubygems do # this catches 'gem_package "foo"' when "./foo" is a file in the cwd, and instead of installing './foo' it fetches the remote gem it "installs the gem via the gems api, when the package has no file separator characters in it, but a matching file exists in cwd" do allow(::File).to receive(:exists?).and_return(true) - @new_resource.package_name('rspec-core') + @new_resource.package_name("rspec-core") expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => nil) @provider.run_action(:install) expect(@new_resource).to be_updated_by_last_action end it "installs the gem by shelling out when options are provided as a String" do - @new_resource.options('-i /alt/install/location') + @new_resource.options("-i /alt/install/location") expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\" -i /alt/install/location" expect(@provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900) @provider.run_action(:install) @@ -532,8 +532,8 @@ describe Chef::Provider::Package::Rubygems do end it "installs the gem with rubygems.org as an added source" do - @new_resource.gem_binary('/foo/bar') - @new_resource.source('http://mirror.ops.rhcloud.com/mirror/ruby') + @new_resource.gem_binary("/foo/bar") + @new_resource.source("http://mirror.ops.rhcloud.com/mirror/ruby") expected ="/foo/bar install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\" --source=#{@new_resource.source} --source=https://rubygems.org" expect(@provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900) @provider.run_action(:install) @@ -541,8 +541,8 @@ describe Chef::Provider::Package::Rubygems do end it "installs the gem with cleared sources and explict source when specified" do - @new_resource.gem_binary('/foo/bar') - @new_resource.source('http://mirror.ops.rhcloud.com/mirror/ruby') + @new_resource.gem_binary("/foo/bar") + @new_resource.source("http://mirror.ops.rhcloud.com/mirror/ruby") @new_resource.clear_sources(true) expected ="/foo/bar install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\" --clear-sources --source=#{@new_resource.source}" expect(@provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900) @@ -554,7 +554,7 @@ describe Chef::Provider::Package::Rubygems do let(:target_version) { nil } it "installs the gem by shelling out when options are provided but no version is given" do - @new_resource.options('-i /alt/install/location') + @new_resource.options("-i /alt/install/location") expected ="gem install rspec-core -q --no-rdoc --no-ri -v \"#{@provider.candidate_version}\" -i /alt/install/location" expect(@provider).to receive(:shell_out!).with(expected, env: nil, timeout: 900) @provider.run_action(:install) @@ -563,15 +563,15 @@ describe Chef::Provider::Package::Rubygems do end it "installs the gem via the gems api when options are given as a Hash" do - @new_resource.options(:install_dir => '/alt/install/location') - expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => nil, :install_dir => '/alt/install/location') + @new_resource.options(:install_dir => "/alt/install/location") + expect(@provider.gem_env).to receive(:install).with(@gem_dep, :sources => nil, :install_dir => "/alt/install/location") @provider.run_action(:install) expect(@new_resource).to be_updated_by_last_action end describe "at a specific version" do before do - @gem_dep = Gem::Dependency.new('rspec-core', @spec_version) + @gem_dep = Gem::Dependency.new("rspec-core", @spec_version) end it "installs the gem via the gems api" do @@ -601,28 +601,28 @@ describe Chef::Provider::Package::Rubygems do describe "in an alternate gem environment" do it "installs the gem by shelling out to gem install" do - @new_resource.gem_binary('/usr/weird/bin/gem') + @new_resource.gem_binary("/usr/weird/bin/gem") expect(@provider).to receive(:shell_out!).with("/usr/weird/bin/gem install rspec-core -q --no-rdoc --no-ri -v \"#{@spec_version}\"", env: nil, timeout: 900) @provider.run_action(:install) expect(@new_resource).to be_updated_by_last_action end it "installs the gem from file by shelling out to gem install" do - @new_resource.gem_binary('/usr/weird/bin/gem') - @new_resource.source(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') - @new_resource.version('>= 0') + @new_resource.gem_binary("/usr/weird/bin/gem") + @new_resource.source(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") + @new_resource.version(">= 0") expect(@provider).to receive(:shell_out!).with("/usr/weird/bin/gem install #{CHEF_SPEC_DATA}/gems/chef-integration-test-0.1.0.gem -q --no-rdoc --no-ri -v \">= 0\"", env: nil, timeout: 900) @provider.run_action(:install) expect(@new_resource).to be_updated_by_last_action end it "installs the gem from file by shelling out to gem install when the package is a path and the source is nil" do - @new_resource = Chef::Resource::GemPackage.new(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') + @new_resource = Chef::Resource::GemPackage.new(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") @provider = Chef::Provider::Package::Rubygems.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @new_resource.gem_binary('/usr/weird/bin/gem') - @new_resource.version('>= 0') - expect(@new_resource.source).to eq(CHEF_SPEC_DATA + '/gems/chef-integration-test-0.1.0.gem') + @new_resource.gem_binary("/usr/weird/bin/gem") + @new_resource.version(">= 0") + expect(@new_resource.source).to eq(CHEF_SPEC_DATA + "/gems/chef-integration-test-0.1.0.gem") expect(@provider).to receive(:shell_out!).with("/usr/weird/bin/gem install #{CHEF_SPEC_DATA}/gems/chef-integration-test-0.1.0.gem -q --no-rdoc --no-ri -v \">= 0\"", env: nil, timeout: 900) @provider.run_action(:install) expect(@new_resource).to be_updated_by_last_action @@ -635,7 +635,7 @@ describe Chef::Provider::Package::Rubygems do before do @new_resource = Chef::Resource::GemPackage.new("rspec") @current_resource = @new_resource.dup - @current_resource.version('1.2.3') + @current_resource.version("1.2.3") @provider.new_resource = @new_resource @provider.current_resource = @current_resource end @@ -646,7 +646,7 @@ describe Chef::Provider::Package::Rubygems do expect(@provider.new_resource.version).to be_nil expect(@provider.current_resource.version).not_to be_nil # the behavior we're testing: - expect(@provider.gem_env).to receive(:uninstall).with('rspec', nil) + expect(@provider.gem_env).to receive(:uninstall).with("rspec", nil) @provider.action_remove end @@ -655,27 +655,27 @@ describe Chef::Provider::Package::Rubygems do expect(@provider.new_resource.version).to be_nil expect(@provider.current_resource.version).not_to be_nil # the behavior we're testing: - @new_resource.options(:install_dir => '/alt/install/location') - expect(@provider.gem_env).to receive(:uninstall).with('rspec', nil, :install_dir => '/alt/install/location') + @new_resource.options(:install_dir => "/alt/install/location") + expect(@provider.gem_env).to receive(:uninstall).with("rspec", nil, :install_dir => "/alt/install/location") @provider.action_remove end it "uninstalls via the gem command when options are given as a String" do - @new_resource.options('-i /alt/install/location') + @new_resource.options("-i /alt/install/location") expect(@provider).to receive(:shell_out!).with("gem uninstall rspec -q -x -I -a -i /alt/install/location", env: nil, timeout: 900) @provider.action_remove end it "uninstalls a specific version of a gem when a version is provided" do - @new_resource.version('1.2.3') - expect(@provider.gem_env).to receive(:uninstall).with('rspec', '1.2.3') + @new_resource.version("1.2.3") + expect(@provider.gem_env).to receive(:uninstall).with("rspec", "1.2.3") @provider.action_remove end end describe "in an alternate gem environment" do it "uninstalls via the gem command" do - @new_resource.gem_binary('/usr/weird/bin/gem') + @new_resource.gem_binary("/usr/weird/bin/gem") expect(@provider).to receive(:shell_out!).with("/usr/weird/bin/gem uninstall rspec -q -x -I -a", env: nil, timeout: 900) @provider.action_remove end diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb index 8f2d2bb8ea..93bfcb7a39 100644 --- a/spec/unit/provider/package/smartos_spec.rb +++ b/spec/unit/provider/package/smartos_spec.rb @@ -18,7 +18,7 @@ # require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "spec_helper")) -require 'ostruct' +require "ostruct" describe Chef::Provider::Package::SmartOS, "load_current_resource" do before(:each) do @@ -81,8 +81,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do expect(search).to receive(:each_line). and_yield("something-varnish-1.1.1 something varnish like\n"). and_yield("varnish-2.3.4 actual varnish\n") - @shell_out = double('shell_out!', :stdout => search) - expect(@provider).to receive(:shell_out!).with('/opt/local/bin/pkgin', 'se', 'varnish', :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out) + @shell_out = double("shell_out!", :stdout => search) + expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out) expect(@provider.candidate_version).to eq("2.3.4") end @@ -91,8 +91,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do expect(search).to receive(:each_line). and_yield("something-varnish-1.1.1;;something varnish like\n"). and_yield("varnish-2.3.4;;actual varnish\n") - @shell_out = double('shell_out!', :stdout => search) - expect(@provider).to receive(:shell_out!).with('/opt/local/bin/pkgin', 'se', 'varnish', :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out) + @shell_out = double("shell_out!", :stdout => search) + expect(@provider).to receive(:shell_out!).with("/opt/local/bin/pkgin", "se", "varnish", :env => nil, :returns => [0,1], :timeout=>900).and_return(@shell_out) expect(@provider.candidate_version).to eq("2.3.4") end end diff --git a/spec/unit/provider/package/solaris_spec.rb b/spec/unit/provider/package/solaris_spec.rb index ae6c96da00..722007a6b0 100644 --- a/spec/unit/provider/package/solaris_spec.rb +++ b/spec/unit/provider/package/solaris_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Solaris do before(:each) do diff --git a/spec/unit/provider/package/windows/exe_spec.rb b/spec/unit/provider/package/windows/exe_spec.rb index 6756ffa9e0..18c1c2cd5d 100644 --- a/spec/unit/provider/package/windows/exe_spec.rb +++ b/spec/unit/provider/package/windows/exe_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/provider/package/windows/exe' +require "spec_helper" +require "chef/provider/package/windows/exe" unless Chef::Platform.windows? class Chef @@ -41,14 +41,14 @@ describe Chef::Provider::Package::Windows::Exe do end let(:uninstall_hash) do [{ - 'DisplayVersion' => 'outdated', - 'UninstallString' => File.join("uninst_dir", "uninst_file"), + "DisplayVersion" => "outdated", + "UninstallString" => File.join("uninst_dir", "uninst_file"), }] end let(:uninstall_entry) do entries = [] uninstall_hash.each do |entry| - entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new('hive', 'key', entry)) + entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new("hive", "key", entry)) end entries end @@ -100,8 +100,8 @@ describe Chef::Provider::Package::Windows::Exe do end it "returns the version attribute if given" do - new_resource.version('v55555') - expect(provider.package_version).to eql('v55555') + new_resource.version("v55555") + expect(provider.package_version).to eql("v55555") end it "returns nil if no version given" do @@ -121,19 +121,19 @@ describe Chef::Provider::Package::Windows::Exe do let(:uninstall_hash) do [ { - 'DisplayVersion' => 'v1', - 'UninstallString' => File.join("uninst_dir1", "uninst_file1"), + "DisplayVersion" => "v1", + "UninstallString" => File.join("uninst_dir1", "uninst_file1"), }, { - 'DisplayVersion' => 'v2', - 'UninstallString' => File.join("uninst_dir2", "uninst_file2"), + "DisplayVersion" => "v2", + "UninstallString" => File.join("uninst_dir2", "uninst_file2"), }, ] end context "version given and installed" do it "removes given version" do - new_resource.version('v2') + new_resource.version("v2") expect(provider).to receive(:shell_out!).with(/start \"\" \/wait \/d\"uninst_dir2\" uninst_file2 \/S \/NCRC & exit %%%%ERRORLEVEL%%%%/, kind_of(Hash)) provider.remove_package end diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb index 835bd4ad19..86067ce8c8 100644 --- a/spec/unit/provider/package/windows/msi_spec.rb +++ b/spec/unit/provider/package/windows/msi_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/provider/package/windows/msi' +require "spec_helper" +require "chef/provider/package/windows/msi" describe Chef::Provider::Package::Windows::MSI do - let(:node) { double('Chef::Node') } - let(:events) { double('Chef::Events').as_null_object } # mock all the methods - let(:run_context) { double('Chef::RunContext', :node => node, :events => events) } + let(:node) { double("Chef::Node") } + let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:package_name) { "calculator" } let(:resource_source) { "calculator.msi" } let(:resource_version) { nil } @@ -34,14 +34,14 @@ describe Chef::Provider::Package::Windows::MSI do end let(:uninstall_hash) do [{ - 'DisplayVersion' => 'outdated', - 'UninstallString' => "MsiExec.exe /X{guid}", + "DisplayVersion" => "outdated", + "UninstallString" => "MsiExec.exe /X{guid}", }] end let(:uninstall_entry) do entries = [] uninstall_hash.each do |entry| - entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new('hive', 'key', entry)) + entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new("hive", "key", entry)) end entries end @@ -129,12 +129,12 @@ describe Chef::Provider::Package::Windows::MSI do let(:uninstall_hash) do [ { - 'DisplayVersion' => 'outdated', - 'UninstallString' => "MsiExec.exe /X{guid}", + "DisplayVersion" => "outdated", + "UninstallString" => "MsiExec.exe /X{guid}", }, { - 'DisplayVersion' => 'really_outdated', - 'UninstallString' => "MsiExec.exe /X{guid2}", + "DisplayVersion" => "really_outdated", + "UninstallString" => "MsiExec.exe /X{guid2}", }, ] end diff --git a/spec/unit/provider/package/windows_spec.rb b/spec/unit/provider/package/windows_spec.rb index 200cc9888a..4771057133 100644 --- a/spec/unit/provider/package/windows_spec.rb +++ b/spec/unit/provider/package/windows_spec.rb @@ -16,9 +16,9 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/provider/package/windows/exe' -require 'chef/provider/package/windows/msi' +require "spec_helper" +require "chef/provider/package/windows/exe" +require "chef/provider/package/windows/msi" describe Chef::Provider::Package::Windows, :windows_only do before(:each) do @@ -26,11 +26,11 @@ describe Chef::Provider::Package::Windows, :windows_only do allow(Chef::FileCache).to receive(:create_cache_path).with("package/").and_return(cache_path) end - let(:node) { double('Chef::Node') } - let(:events) { double('Chef::Events').as_null_object } # mock all the methods - let(:run_context) { double('Chef::RunContext', :node => node, :events => events) } - let(:resource_source) { 'calculator.msi' } - let(:resource_name) { 'calculator' } + let(:node) { double("Chef::Node") } + let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } + let(:resource_source) { "calculator.msi" } + let(:resource_name) { "calculator" } let(:new_resource) do new_resource = Chef::Resource::WindowsPackage.new(resource_name) new_resource.source(resource_source) if resource_source @@ -47,7 +47,7 @@ describe Chef::Provider::Package::Windows, :windows_only do shared_examples "a local file" do before(:each) do allow(Chef::Util::PathHelper).to receive(:validate_path) - allow(provider).to receive(:package_provider).and_return(double('package_provider', + allow(provider).to receive(:package_provider).and_return(double("package_provider", :installed_version => "1.0", :package_version => "2.0")) end @@ -69,7 +69,7 @@ describe Chef::Provider::Package::Windows, :windows_only do end context "when the source is a uri" do - let(:resource_source) { 'https://foo.bar/calculator.msi' } + let(:resource_source) { "https://foo.bar/calculator.msi" } context "when the source has not been downloaded" do before(:each) do @@ -134,7 +134,7 @@ describe Chef::Provider::Package::Windows, :windows_only do end context "when the source is a uri" do - let(:resource_source) { 'https://foo.bar/calculator.msi' } + let(:resource_source) { "https://foo.bar/calculator.msi" } context "when the source has not been downloaded" do before(:each) do @@ -170,15 +170,15 @@ describe Chef::Provider::Package::Windows, :windows_only do context "there is no source" do let(:uninstall_hash) do [{ - 'DisplayVersion' => 'outdated', - 'UninstallString' => "blah blah", + "DisplayVersion" => "outdated", + "UninstallString" => "blah blah", }] end let(:uninstall_key) { "blah" } let(:uninstall_entry) do entries = [] uninstall_hash.each do |entry| - entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new('hive', uninstall_key, entry)) + entries.push(Chef::Provider::Package::Windows::RegistryUninstallEntry.new("hive", uninstall_key, entry)) end entries end @@ -191,8 +191,8 @@ describe Chef::Provider::Package::Windows, :windows_only do context "uninstall string contains MsiExec.exe" do let(:uninstall_hash) do [{ - 'DisplayVersion' => 'outdated', - 'UninstallString' => "MsiExec.exe /X{guid}", + "DisplayVersion" => "outdated", + "UninstallString" => "MsiExec.exe /X{guid}", }] end @@ -204,8 +204,8 @@ describe Chef::Provider::Package::Windows, :windows_only do context "uninstall string ends with uninst.exe" do let(:uninstall_hash) do [{ - 'DisplayVersion' => 'outdated', - 'UninstallString' => %q{"c:/hfhfheru/uninst.exe"}, + "DisplayVersion" => "outdated", + "UninstallString" => %q{"c:/hfhfheru/uninst.exe"}, }] end @@ -237,17 +237,17 @@ describe Chef::Provider::Package::Windows, :windows_only do end it "sets installer_type to inno if the source contains inno" do - allow(::Kernel).to receive(:open).and_yield(StringIO.new('blah blah inno blah')) + allow(::Kernel).to receive(:open).and_yield(StringIO.new("blah blah inno blah")) expect(provider.installer_type).to eql(:inno) end it "sets installer_type to wise if the source contains wise" do - allow(::Kernel).to receive(:open).and_yield(StringIO.new('blah blah wise blah')) + allow(::Kernel).to receive(:open).and_yield(StringIO.new("blah blah wise blah")) expect(provider.installer_type).to eql(:wise) end it "sets installer_type to nsis if the source contains nsis" do - allow(::Kernel).to receive(:open).and_yield(StringIO.new('blah blah nullsoft blah')) + allow(::Kernel).to receive(:open).and_yield(StringIO.new("blah blah nullsoft blah")) expect(provider.installer_type).to eql(:nsis) end @@ -263,7 +263,7 @@ describe Chef::Provider::Package::Windows, :windows_only do let(:resource_source) { "setup.exe" } it "sets installer_type to installshield" do - allow(::Kernel).to receive(:open).and_yield(StringIO.new('')) + allow(::Kernel).to receive(:open).and_yield(StringIO.new("")) expect(provider.installer_type).to eql(:installshield) end end @@ -272,7 +272,7 @@ describe Chef::Provider::Package::Windows, :windows_only do let(:resource_source) { "tomfoolery.now" } it "raises an error" do - allow(::Kernel).to receive(:open).and_yield(StringIO.new('')) + allow(::Kernel).to receive(:open).and_yield(StringIO.new("")) provider.new_resource.installer_type(nil) expect { provider.installer_type }.to raise_error(Chef::Exceptions::CannotDetermineWindowsInstallerType) end @@ -313,7 +313,7 @@ describe Chef::Provider::Package::Windows, :windows_only do end context "a version is given and none is installed" do - before { new_resource.version('5.5.5') } + before { new_resource.version("5.5.5") } it "installs given version" do expect(provider).to receive(:install_package).with("blah", "5.5.5") @@ -324,7 +324,7 @@ describe Chef::Provider::Package::Windows, :windows_only do context "a version is given and several are installed" do context "given version matches an installed version" do before do - new_resource.version('5.5.5') + new_resource.version("5.5.5") allow(provider).to receive(:current_version_array).and_return([ ["5.5.5", "4.3.0", "1.1.1"] ]) end @@ -336,7 +336,7 @@ describe Chef::Provider::Package::Windows, :windows_only do context "given version does not match an installed version" do before do - new_resource.version('5.5.5') + new_resource.version("5.5.5") allow(provider).to receive(:current_version_array).and_return([ ["5.5.0", "4.3.0", "1.1.1"] ]) end @@ -350,7 +350,7 @@ describe Chef::Provider::Package::Windows, :windows_only do context "a version is given and one is installed" do context "given version matches installed version" do before do - new_resource.version('5.5.5') + new_resource.version("5.5.5") allow(provider).to receive(:current_version_array).and_return(["5.5.5"]) end @@ -362,7 +362,7 @@ describe Chef::Provider::Package::Windows, :windows_only do context "given version does not match installed version" do before do - new_resource.version('5.5.5') + new_resource.version("5.5.5") allow(provider).to receive(:current_version_array).and_return(["5.5.0"]) end diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb index 70ab257a54..efbbdf6450 100644 --- a/spec/unit/provider/package/yum_spec.rb +++ b/spec/unit/provider/package/yum_spec.rb @@ -16,18 +16,18 @@ # limitations under the License. # -require 'spec_helper' -require 'securerandom' +require "spec_helper" +require "securerandom" describe Chef::Provider::Package::Yum do before(:each) do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::YumPackage.new('cups') + @new_resource = Chef::Resource::YumPackage.new("cups") @status = double("Status", :exitstatus => 0) @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -77,15 +77,15 @@ describe Chef::Provider::Package::Yum do describe "when source is provided" do it "should set the candidate version" do - @new_resource = Chef::Resource::YumPackage.new('testing.source') + @new_resource = Chef::Resource::YumPackage.new("testing.source") @new_resource.source "chef-server-core-12.0.5-1.rpm" @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) allow(File).to receive(:exists?).with(@new_resource.source).and_return(true) allow(@yum_cache).to receive(:installed_version).and_return(nil) - shellout_double = double(:stdout => 'chef-server-core 12.0.5-1') + shellout_double = double(:stdout => "chef-server-core 12.0.5-1") allow(@provider).to receive(:shell_out!).and_return(shellout_double) @provider.load_current_resource - expect(@provider.candidate_version).to eql('12.0.5-1') + expect(@provider.candidate_version).to eql("12.0.5-1") end end @@ -113,7 +113,7 @@ describe Chef::Provider::Package::Yum do end it "when the new_resource is a vanilla package class and yum-deprecated exists" do - @new_resource = Chef::Resource::Package.new('cups') + @new_resource = Chef::Resource::Package.new("cups") expect(File).to receive(:exist?).with("/usr/bin/yum-deprecated").and_return(true) expect(@yum_cache).to receive(:yum_binary=).with("yum-deprecated") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @@ -121,7 +121,7 @@ describe Chef::Provider::Package::Yum do end it "when the new_resource is a vanilla package class and yum-deprecated does not exist" do - @new_resource = Chef::Resource::Package.new('cups') + @new_resource = Chef::Resource::Package.new("cups") expect(File).to receive(:exist?).with("/usr/bin/yum-deprecated").and_return(false) expect(@yum_cache).to receive(:yum_binary=).with("yum") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @@ -131,9 +131,9 @@ describe Chef::Provider::Package::Yum do describe "when arch in package_name" do it "should set the arch if no existing package_name is found and new_package_name+new_arch is available" do - @new_resource = Chef::Resource::YumPackage.new('testing.noarch') + @new_resource = Chef::Resource::YumPackage.new("testing.noarch") @yum_cache = double( - 'Chef::Provider::Yum::YumCache' + "Chef::Provider::Yum::YumCache" ) allow(@yum_cache).to receive(:installed_version) do |package_name, arch| # nothing installed for package_name/new_package_name @@ -157,7 +157,7 @@ describe Chef::Provider::Package::Yum do expect(@provider.new_resource.arch).to eq("noarch") expect(@provider.arch).to eq("noarch") - @new_resource = Chef::Resource::YumPackage.new('testing.more.noarch') + @new_resource = Chef::Resource::YumPackage.new("testing.more.noarch") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource expect(@provider.new_resource.package_name).to eq("testing.more") @@ -167,9 +167,9 @@ describe Chef::Provider::Package::Yum do describe "when version constraint in package_name" do it "should set package_version if no existing package_name is found and new_package_name is available" do - @new_resource = Chef::Resource::Package.new('cups = 1.2.4-11.18.el5_2.3') + @new_resource = Chef::Resource::Package.new("cups = 1.2.4-11.18.el5_2.3") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) - allow(@yum_cache).to receive(:package_available?) { |pkg| pkg == 'cups' ? true : false } + allow(@yum_cache).to receive(:package_available?) { |pkg| pkg == "cups" ? true : false } allow(@yum_cache).to receive(:packages_from_require) do |pkg| [Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.3", "noarch", [], false, true, "base"), Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.2", "noarch", [], false, true, "base")] @@ -186,9 +186,9 @@ describe Chef::Provider::Package::Yum do end it "should not set the arch when an existing package_name is found" do - @new_resource = Chef::Resource::YumPackage.new('testing.beta3') + @new_resource = Chef::Resource::YumPackage.new("testing.beta3") @yum_cache = double( - 'Chef::Provider::Yum::YumCache' + "Chef::Provider::Yum::YumCache" ) allow(@yum_cache).to receive(:installed_version) do |package_name, arch| # installed for package_name @@ -213,7 +213,7 @@ describe Chef::Provider::Package::Yum do expect(@provider.new_resource.arch).to eq(nil) expect(@provider.arch).to eq(nil) - @new_resource = Chef::Resource::YumPackage.new('testing.beta3.more') + @new_resource = Chef::Resource::YumPackage.new("testing.beta3.more") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource expect(@provider.new_resource.package_name).to eq("testing.beta3.more") @@ -222,9 +222,9 @@ describe Chef::Provider::Package::Yum do end it "should not set the arch when no existing package_name or new_package_name+new_arch is found" do - @new_resource = Chef::Resource::YumPackage.new('testing.beta3') + @new_resource = Chef::Resource::YumPackage.new("testing.beta3") @yum_cache = double( - 'Chef::Provider::Yum::YumCache' + "Chef::Provider::Yum::YumCache" ) allow(@yum_cache).to receive(:installed_version) do |package_name, arch| # nothing installed for package_name/new_package_name @@ -244,7 +244,7 @@ describe Chef::Provider::Package::Yum do expect(@provider.new_resource.arch).to eq(nil) expect(@provider.arch).to eq(nil) - @new_resource = Chef::Resource::YumPackage.new('testing.beta3.more') + @new_resource = Chef::Resource::YumPackage.new("testing.beta3.more") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource expect(@provider.new_resource.package_name).to eq("testing.beta3.more") @@ -253,10 +253,10 @@ describe Chef::Provider::Package::Yum do end it "should ensure it doesn't clobber an existing arch if passed" do - @new_resource = Chef::Resource::YumPackage.new('testing.i386') + @new_resource = Chef::Resource::YumPackage.new("testing.i386") @new_resource.arch("x86_64") @yum_cache = double( - 'Chef::Provider::Yum::YumCache' + "Chef::Provider::Yum::YumCache" ) allow(@yum_cache).to receive(:installed_version) do |package_name, arch| # nothing installed for package_name/new_package_name @@ -313,7 +313,7 @@ describe Chef::Provider::Package::Yum do context "when the package name isn't found" do let(:yum_cache) { double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.0.1.el5", @@ -334,61 +334,61 @@ describe Chef::Provider::Package::Yum do it "should search provides then set package_name to match" do @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') + expect(@new_resource.package_name).to eq("test-package") expect(@new_resource.version).to eq(nil) end it "should search provides then set version to match if a requirement was passed in the package name" do - @new_resource = Chef::Resource::YumPackage.new('test-package = 2.0.1.el5') + @new_resource = Chef::Resource::YumPackage.new("test-package = 2.0.1.el5") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') - expect(@new_resource.version).to eq('2.0.1.el5') + expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.version).to eq("2.0.1.el5") end it "should search provides then set version to match if a requirement was passed in the version" do - @new_resource = Chef::Resource::YumPackage.new('test-package') - @new_resource.version('= 2.0.1.el5') + @new_resource = Chef::Resource::YumPackage.new("test-package") + @new_resource.version("= 2.0.1.el5") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') - expect(@new_resource.version).to eq('2.0.1.el5') + expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.version).to eq("2.0.1.el5") end it "should search provides and not set the version to match if a specific version was requested" do - @new_resource = Chef::Resource::YumPackage.new('test-package') - @new_resource.version('3.0.1.el5') + @new_resource = Chef::Resource::YumPackage.new("test-package") + @new_resource.version("3.0.1.el5") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') - expect(@new_resource.version).to eq('3.0.1.el5') + expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.version).to eq("3.0.1.el5") end it "should search provides then set versions to match if requirements were passed in the package name as an array" do - @new_resource = Chef::Resource::YumPackage.new(['test-package = 2.0.1.el5']) + @new_resource = Chef::Resource::YumPackage.new(["test-package = 2.0.1.el5"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq(['test-package']) - expect(@new_resource.version).to eq(['2.0.1.el5']) + expect(@new_resource.package_name).to eq(["test-package"]) + expect(@new_resource.version).to eq(["2.0.1.el5"]) end it "should search provides and not set the versions to match if specific versions were requested in an array" do - @new_resource = Chef::Resource::YumPackage.new(['test-package']) - @new_resource.version(['3.0.1.el5']) + @new_resource = Chef::Resource::YumPackage.new(["test-package"]) + @new_resource.version(["3.0.1.el5"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq(['test-package']) - expect(@new_resource.version).to eq(['3.0.1.el5']) + expect(@new_resource.package_name).to eq(["test-package"]) + expect(@new_resource.version).to eq(["3.0.1.el5"]) end end it "should not return an error if no version number is specified in the resource" do - @new_resource = Chef::Resource::YumPackage.new('test-package') + @new_resource = Chef::Resource::YumPackage.new("test-package") @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.0.1.el5", @@ -408,9 +408,9 @@ describe Chef::Provider::Package::Yum do end it "should give precedence to the version attribute when both a requirement in the resource name and a version attribute are specified" do - @new_resource = Chef::Resource::YumPackage.new('test-package') + @new_resource = Chef::Resource::YumPackage.new("test-package") @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -423,17 +423,17 @@ describe Chef::Provider::Package::Yum do allow(@yum_cache).to receive(:yum_binary=).with("yum") pkg = Chef::Provider::Package::Yum::RPMPackage.new("test-package", "2.0.1.el5", "x86_64", []) expect(@yum_cache).to receive(:packages_from_require).and_return([pkg]) - @new_resource = Chef::Resource::YumPackage.new('test-package = 2.0.1.el5') - @new_resource.version('3.0.1.el5') + @new_resource = Chef::Resource::YumPackage.new("test-package = 2.0.1.el5") + @new_resource.version("3.0.1.el5") @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq('test-package') - expect(@new_resource.version).to eq('3.0.1.el5') + expect(@new_resource.package_name).to eq("test-package") + expect(@new_resource.version).to eq("3.0.1.el5") end it "should correctly detect the installed states of an array of package names and version numbers" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.0.1.el5", @@ -448,17 +448,17 @@ describe Chef::Provider::Package::Yum do expect(@yum_cache).to receive(:packages_from_require).exactly(4).times.and_return([]) expect(@yum_cache).to receive(:reload_provides).twice - @new_resource = Chef::Resource::YumPackage.new(['test-package','test-package2']) - @new_resource.version(['2.0.1.el5','3.0.1.el5']) + @new_resource = Chef::Resource::YumPackage.new(["test-package","test-package2"]) + @new_resource.version(["2.0.1.el5","3.0.1.el5"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) @provider.load_current_resource - expect(@new_resource.package_name).to eq(['test-package','test-package2']) - expect(@new_resource.version).to eq(['2.0.1.el5','3.0.1.el5']) + expect(@new_resource.package_name).to eq(["test-package","test-package2"]) + expect(@new_resource.version).to eq(["2.0.1.el5","3.0.1.el5"]) end it "should search provides if no package is available - if no match in installed provides then load the complete set" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -478,7 +478,7 @@ describe Chef::Provider::Package::Yum do it "should search provides if no package is available and not load the complete set if action is :remove or :purge" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -502,7 +502,7 @@ describe Chef::Provider::Package::Yum do it "should search provides if no package is available - if no match in provides leave the name intact" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_provides => true, :reload_installed => true, :reset => true, @@ -562,7 +562,7 @@ describe Chef::Provider::Package::Yum do it "installs the package with the options given in the resource" do @provider.load_current_resource - allow(@provider).to receive(:candidate_version).and_return('11') + allow(@provider).to receive(:candidate_version).and_return("11") allow(@new_resource).to receive(:options).and_return("--disablerepo epmd") allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( @@ -573,7 +573,7 @@ describe Chef::Provider::Package::Yum do it "should raise an exception if the package is not available" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_from_cache => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -591,7 +591,7 @@ describe Chef::Provider::Package::Yum do it "should raise an exception if candidate version is older than the installed version and allow_downgrade is false" do allow(@new_resource).to receive(:allow_downgrade).and_return(false) @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -610,7 +610,7 @@ describe Chef::Provider::Package::Yum do it "should not raise an exception if candidate version is older than the installed version and the package is list in yum's installonlypkg option" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -634,7 +634,7 @@ describe Chef::Provider::Package::Yum do it "should run yum downgrade if candidate version is older than the installed version and allow_downgrade is true" do allow(@new_resource).to receive(:allow_downgrade).and_return(true) @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -681,7 +681,7 @@ describe Chef::Provider::Package::Yum do describe "when upgrading a package" do it "should run yum install if the package is installed and a version is given" do @provider.load_current_resource - allow(@provider).to receive(:candidate_version).and_return('11') + allow(@provider).to receive(:candidate_version).and_return("11") allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-11" @@ -691,8 +691,8 @@ describe Chef::Provider::Package::Yum do it "should run yum install if the package is not installed" do @provider.load_current_resource - @current_resource = Chef::Resource::Package.new('cups') - allow(@provider).to receive(:candidate_version).and_return('11') + @current_resource = Chef::Resource::Package.new("cups") + allow(@provider).to receive(:candidate_version).and_return("11") allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-11" @@ -702,7 +702,7 @@ describe Chef::Provider::Package::Yum do it "should raise an exception if candidate version is older than the installed version" do @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, :installed_version => "1.2.4-11.18.el5", @@ -722,8 +722,8 @@ describe Chef::Provider::Package::Yum do # Test our little workaround, some crossover into Chef::Provider::Package territory it "should call action_upgrade in the parent if the current resource version is nil" do allow(@yum_cache).to receive(:installed_version).and_return(nil) - @current_resource = Chef::Resource::Package.new('cups') - allow(@provider).to receive(:candidate_version).and_return('11') + @current_resource = Chef::Resource::Package.new("cups") + allow(@provider).to receive(:candidate_version).and_return("11") expect(@provider).to receive(:upgrade_package).with( "cups", "11", @@ -733,7 +733,7 @@ describe Chef::Provider::Package::Yum do it "should call action_upgrade in the parent if the candidate version is nil" do @provider.load_current_resource - @current_resource = Chef::Resource::Package.new('cups') + @current_resource = Chef::Resource::Package.new("cups") allow(@provider).to receive(:candidate_version).and_return(nil) expect(@provider).not_to receive(:upgrade_package) @provider.run_action(:upgrade) @@ -741,8 +741,8 @@ describe Chef::Provider::Package::Yum do it "should call action_upgrade in the parent if the candidate is newer" do @provider.load_current_resource - @current_resource = Chef::Resource::Package.new('cups') - allow(@provider).to receive(:candidate_version).and_return('11') + @current_resource = Chef::Resource::Package.new("cups") + allow(@provider).to receive(:candidate_version).and_return("11") expect(@provider).to receive(:upgrade_package).with( "cups", "11", @@ -753,8 +753,8 @@ describe Chef::Provider::Package::Yum do it "should not call action_upgrade in the parent if the candidate is older" do allow(@yum_cache).to receive(:installed_version).and_return("12") @provider.load_current_resource - @current_resource = Chef::Resource::Package.new('cups') - allow(@provider).to receive(:candidate_version).and_return('11') + @current_resource = Chef::Resource::Package.new("cups") + allow(@provider).to receive(:candidate_version).and_return("11") expect(@provider).not_to receive(:upgrade_package) @provider.run_action(:upgrade) end @@ -989,37 +989,37 @@ describe Chef::Provider::Package::Yum::RPMUtils do end it "tests isalnum good input" do - [ 'a', 'z', 'A', 'Z', '0', '9' ].each do |t| + [ "a", "z", "A", "Z", "0", "9" ].each do |t| expect(@rpmutils.isalnum(t)).to eq(true) end end it "tests isalnum bad input" do - [ '-', '.', '!', '^', ':', '_' ].each do |t| + [ "-", ".", "!", "^", ":", "_" ].each do |t| expect(@rpmutils.isalnum(t)).to eq(false) end end it "tests isalpha good input" do - [ 'a', 'z', 'A', 'Z' ].each do |t| + [ "a", "z", "A", "Z" ].each do |t| expect(@rpmutils.isalpha(t)).to eq(true) end end it "tests isalpha bad input" do - [ '0', '9', '-', '.', '!', '^', ':', '_' ].each do |t| + [ "0", "9", "-", ".", "!", "^", ":", "_" ].each do |t| expect(@rpmutils.isalpha(t)).to eq(false) end end it "tests isdigit good input" do - [ '0', '9' ].each do |t| + [ "0", "9" ].each do |t| expect(@rpmutils.isdigit(t)).to eq(true) end end it "tests isdigit bad input" do - [ 'A', 'z', '-', '.', '!', '^', ':', '_' ].each do |t| + [ "A", "z", "-", ".", "!", "^", ":", "_" ].each do |t| expect(@rpmutils.isdigit(t)).to eq(false) end end @@ -2115,18 +2115,18 @@ describe "Chef::Provider::Package::Yum - Multi" do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Package.new(['cups', 'vim']) + @new_resource = Chef::Resource::Package.new(["cups", "vim"]) @status = double("Status", :exitstatus => 0) @yum_cache = double( - 'Chef::Provider::Yum::YumCache', + "Chef::Provider::Yum::YumCache", :reload_installed => true, :reset => true, - :installed_version => 'XXXX', - :candidate_version => 'YYYY', + :installed_version => "XXXX", + :candidate_version => "YYYY", :package_available? => true, :version_available? => true, - :allow_multi_install => [ 'kernel' ], - :package_repository => 'base', + :allow_multi_install => [ "kernel" ], + :package_repository => "base", :disable_extra_repo_control => true, ) allow(Chef::Provider::Package::Yum::YumCache).to receive(:instance).and_return(@yum_cache) @@ -2139,12 +2139,12 @@ describe "Chef::Provider::Package::Yum - Multi" do describe "when loading the current system state" do it "should create a current resource with the name of the new_resource" do @provider.load_current_resource - expect(@provider.current_resource.name).to eq('cups, vim') + expect(@provider.current_resource.name).to eq("cups, vim") end it "should set the current resources package name to the new resources package name" do @provider.load_current_resource - expect(@provider.current_resource.package_name).to eq(['cups', 'vim']) + expect(@provider.current_resource.package_name).to eq(["cups", "vim"]) end it "should set the installed version to nil on the current resource if no installed package" do @@ -2154,21 +2154,21 @@ describe "Chef::Provider::Package::Yum - Multi" do end it "should set the installed version if yum has one" do - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('1.0') - allow(@yum_cache).to receive(:candidate_version).with('cups', nil).and_return('1.2.4-11.18.el5_2.3') - allow(@yum_cache).to receive(:candidate_version).with('vim', nil).and_return('1.5') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("1.0") + allow(@yum_cache).to receive(:candidate_version).with("cups", nil).and_return("1.2.4-11.18.el5_2.3") + allow(@yum_cache).to receive(:candidate_version).with("vim", nil).and_return("1.5") @provider.load_current_resource - expect(@provider.current_resource.version).to eq(['1.2.4-11.18.el5', '1.0']) + expect(@provider.current_resource.version).to eq(["1.2.4-11.18.el5", "1.0"]) end it "should set the candidate version if yum info has one" do - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('1.0') - allow(@yum_cache).to receive(:candidate_version).with('cups', nil).and_return('1.2.4-11.18.el5_2.3') - allow(@yum_cache).to receive(:candidate_version).with('vim', nil).and_return('1.5') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("1.0") + allow(@yum_cache).to receive(:candidate_version).with("cups", nil).and_return("1.2.4-11.18.el5_2.3") + allow(@yum_cache).to receive(:candidate_version).with("vim", nil).and_return("1.5") @provider.load_current_resource - expect(@provider.candidate_version).to eql(['1.2.4-11.18.el5_2.3', '1.5']) + expect(@provider.candidate_version).to eql(["1.2.4-11.18.el5_2.3", "1.5"]) end it "should return the current resouce" do @@ -2177,20 +2177,20 @@ describe "Chef::Provider::Package::Yum - Multi" do describe "when version constraint in package_name" do it "should set package_version if no existing package_name is found and new_package_name is available" do - @new_resource = Chef::Resource::Package.new(['cups = 1.2.4-11.18.el5_2.3', 'emacs = 24.4']) + @new_resource = Chef::Resource::Package.new(["cups = 1.2.4-11.18.el5_2.3", "emacs = 24.4"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) allow(@yum_cache).to receive(:package_available?) { |pkg| %w(cups emacs).include?(pkg) ? true : false } allow(@yum_cache).to receive(:candidate_version) do |pkg| - if pkg == 'cups' + if pkg == "cups" "1.2.4-11.18.el5_2.3" - elsif pkg == 'emacs' + elsif pkg == "emacs" "24.4" end end allow(@yum_cache).to receive(:packages_from_require) do |pkg| - if pkg.name == 'cups' + if pkg.name == "cups" [Chef::Provider::Package::Yum::RPMDbPackage.new("cups", "1.2.4-11.18.el5_2.3", "noarch", [], false, true, "base")] - elsif pkg.name == 'emacs' + elsif pkg.name == "emacs" [Chef::Provider::Package::Yum::RPMDbPackage.new("emacs", "24.4", "noarch", [], false, true, "base")] end end @@ -2210,12 +2210,12 @@ describe "Chef::Provider::Package::Yum - Multi" do it "should run yum install with the package name and version" do @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9") expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-1.2.4-11.19.el5 vim-1.0" ) - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0']) + @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) end it "should run yum install with the package name, version and arch" do @@ -2231,17 +2231,17 @@ describe "Chef::Provider::Package::Yum - Multi" do it "installs the package with the options given in the resource" do @provider.load_current_resource allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9") expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y --disablerepo epmd install cups-1.2.4-11.19.el5 vim-1.0" ) allow(@new_resource).to receive(:options).and_return("--disablerepo epmd") - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0']) + @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) end it "should run yum install with the package name and version when name has arch" do - @new_resource = Chef::Resource::Package.new(['cups.x86_64', 'vim']) + @new_resource = Chef::Resource::Package.new(["cups.x86_64", "vim"]) @provider = Chef::Provider::Package::Yum.new(@new_resource, @run_context) allow(Chef::Provider::Package::Yum::RPMUtils).to receive(:rpmvercmp).and_return(-1) @@ -2249,20 +2249,20 @@ describe "Chef::Provider::Package::Yum - Multi" do # and we need to craft the right response. The default mock setup above # will just return valid versions all the time which won't work for this # test. - allow(@yum_cache).to receive(:installed_version).with('cups', 'x86_64').and_return('XXXX') - allow(@yum_cache).to receive(:candidate_version).with('cups', 'x86_64').and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('cups.x86_64').and_return(nil) - allow(@yum_cache).to receive(:candidate_version).with('cups.x86_64').and_return(nil) + allow(@yum_cache).to receive(:installed_version).with("cups", "x86_64").and_return("XXXX") + allow(@yum_cache).to receive(:candidate_version).with("cups", "x86_64").and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("cups.x86_64").and_return(nil) + allow(@yum_cache).to receive(:candidate_version).with("cups.x86_64").and_return(nil) # Normal mock's for the idempotency check - allow(@yum_cache).to receive(:installed_version).with('cups', nil).and_return('1.2.4-11.18.el5') - allow(@yum_cache).to receive(:installed_version).with('vim', nil).and_return('0.9') + allow(@yum_cache).to receive(:installed_version).with("cups", nil).and_return("1.2.4-11.18.el5") + allow(@yum_cache).to receive(:installed_version).with("vim", nil).and_return("0.9") @provider.load_current_resource expect(@provider).to receive(:yum_command).with( "-d0 -e0 -y install cups-1.2.4-11.19.el5.x86_64 vim-1.0" ) - @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", '1.0']) + @provider.install_package(["cups", "vim"], ["1.2.4-11.19.el5", "1.0"]) end end diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb index 5fb3abe875..0f39fde5cf 100644 --- a/spec/unit/provider/package/zypper_spec.rb +++ b/spec/unit/provider/package/zypper_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package::Zypper do let!(:new_resource) { Chef::Resource::ZypperPackage.new("cups") } diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb index cf905aeab7..ca2e545358 100644 --- a/spec/unit/provider/package_spec.rb +++ b/spec/unit/provider/package_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Package do let(:node) do @@ -27,8 +27,8 @@ describe Chef::Provider::Package do end let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } - let(:new_resource) { Chef::Resource::Package.new('emacs') } - let(:current_resource) { Chef::Resource::Package.new('emacs') } + let(:new_resource) { Chef::Resource::Package.new("emacs") } + let(:current_resource) { Chef::Resource::Package.new("emacs") } let(:candidate_version) { "1.0" } let(:provider) do provider = Chef::Provider::Package.new(new_resource, run_context) @@ -44,8 +44,8 @@ describe Chef::Provider::Package do end it "raises a Chef::Exceptions::InvalidResourceSpecification if both multipackage and source are provided" do - new_resource.package_name(['a', 'b']) - new_resource.source('foo') + new_resource.package_name(["a", "b"]) + new_resource.source("foo") expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::InvalidResourceSpecification) end @@ -187,12 +187,12 @@ describe Chef::Provider::Package do describe "When removing the package" do before(:each) do allow(provider).to receive(:remove_package).and_return(true) - current_resource.version '1.4.2' + current_resource.version "1.4.2" end it "should remove the package if it is installed" do expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with('emacs', nil) + expect(provider).to receive(:remove_package).with("emacs", nil) provider.run_action(:remove) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -201,7 +201,7 @@ describe Chef::Provider::Package do it "should remove the package at a specific version if it is installed at that version" do new_resource.version "1.4.2" expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with('emacs', '1.4.2') + expect(provider).to receive(:remove_package).with("emacs", "1.4.2") provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end @@ -231,12 +231,12 @@ describe Chef::Provider::Package do describe "When purging the package" do before(:each) do allow(provider).to receive(:purge_package).and_return(true) - current_resource.version '1.4.2' + current_resource.version "1.4.2" end it "should purge the package if it is installed" do expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with('emacs', nil) + expect(provider).to receive(:purge_package).with("emacs", nil) provider.run_action(:purge) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action @@ -245,7 +245,7 @@ describe Chef::Provider::Package do it "should purge the package at a specific version if it is installed at that version" do new_resource.version "1.4.2" expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with('emacs', '1.4.2') + expect(provider).to receive(:purge_package).with("emacs", "1.4.2") provider.run_action(:purge) expect(new_resource).to be_updated_by_last_action end @@ -280,9 +280,9 @@ describe Chef::Provider::Package do end it "should info log, reconfigure the package and update the resource" do - allow(current_resource).to receive(:version).and_return('1.0') + allow(current_resource).to receive(:version).and_return("1.0") allow(new_resource).to receive(:response_file).and_return(true) - expect(provider).to receive(:get_preseed_file).and_return('/var/cache/preseed-test') + expect(provider).to receive(:get_preseed_file).and_return("/var/cache/preseed-test") allow(provider).to receive(:preseed_package).and_return(true) allow(provider).to receive(:reconfig_package).and_return(true) expect(Chef::Log).to receive(:info).with("package[emacs] reconfigured") @@ -301,7 +301,7 @@ describe Chef::Provider::Package do end it "should debug log and not reconfigure the package if no response_file is given" do - allow(current_resource).to receive(:version).and_return('1.0') + allow(current_resource).to receive(:version).and_return("1.0") allow(new_resource).to receive(:response_file).and_return(nil) expect(Chef::Log).to receive(:debug).with("package[emacs] no response_file provided - nothing to do") expect(provider).not_to receive(:reconfig_package) @@ -310,7 +310,7 @@ describe Chef::Provider::Package do end it "should debug log and not reconfigure the package if the response_file has not changed" do - allow(current_resource).to receive(:version).and_return('1.0') + allow(current_resource).to receive(:version).and_return("1.0") allow(new_resource).to receive(:response_file).and_return(true) expect(provider).to receive(:get_preseed_file).and_return(false) allow(provider).to receive(:preseed_package).and_return(false) @@ -323,19 +323,19 @@ describe Chef::Provider::Package do describe "when running commands to be implemented by subclasses" do it "should raises UnsupportedAction for install" do - expect { provider.install_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction) + expect { provider.install_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction) end it "should raises UnsupportedAction for upgrade" do - expect { provider.upgrade_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction) + expect { provider.upgrade_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction) end it "should raises UnsupportedAction for remove" do - expect { provider.remove_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction) + expect { provider.remove_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction) end it "should raises UnsupportedAction for purge" do - expect { provider.purge_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction) + expect { provider.purge_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction) end it "should raise UnsupportedAction for preseed_package" do @@ -344,7 +344,7 @@ describe Chef::Provider::Package do end it "should raise UnsupportedAction for reconfig" do - expect { provider.reconfig_package('emacs', '1.4.2') }.to raise_error(Chef::Exceptions::UnsupportedAction) + expect { provider.reconfig_package("emacs", "1.4.2") }.to raise_error(Chef::Exceptions::UnsupportedAction) end end @@ -360,52 +360,52 @@ describe Chef::Provider::Package do end let(:run_context) { Chef::RunContext.new(node, cookbook_collection, events) } let(:new_resource) do - new_resource = Chef::Resource::Package.new('emacs') - new_resource.response_file('java.response') - new_resource.cookbook_name = 'java' + new_resource = Chef::Resource::Package.new("emacs") + new_resource.response_file("java.response") + new_resource.cookbook_name = "java" new_resource end describe "creating the cookbook file resource to fetch the response file" do before do - expect(Chef::FileCache).to receive(:create_cache_path).with('preseed/java').and_return("/tmp/preseed/java") + expect(Chef::FileCache).to receive(:create_cache_path).with("preseed/java").and_return("/tmp/preseed/java") end it "sets the preseed resource's runcontext to its own run context" do allow(Chef::FileCache).to receive(:create_cache_path).and_return("/tmp/preseed/java") - expect(provider.preseed_resource('java', '6').run_context).not_to be_nil - expect(provider.preseed_resource('java', '6').run_context).to equal(provider.run_context) + expect(provider.preseed_resource("java", "6").run_context).not_to be_nil + expect(provider.preseed_resource("java", "6").run_context).to equal(provider.run_context) end it "should set the cookbook name of the remote file to the new resources cookbook name" do - expect(provider.preseed_resource('java', '6').cookbook_name).to eq('java') + expect(provider.preseed_resource("java", "6").cookbook_name).to eq("java") end it "should set remote files source to the new resources response file" do - expect(provider.preseed_resource('java', '6').source).to eq('java.response') + expect(provider.preseed_resource("java", "6").source).to eq("java.response") end it "should never back up the cached response file" do - expect(provider.preseed_resource('java', '6').backup).to be_falsey + expect(provider.preseed_resource("java", "6").backup).to be_falsey end it "sets the install path of the resource to $file_cache/$cookbook/$pkg_name-$pkg_version.seed" do - expect(provider.preseed_resource('java', '6').path).to eq('/tmp/preseed/java/java-6.seed') + expect(provider.preseed_resource("java", "6").path).to eq("/tmp/preseed/java/java-6.seed") end end describe "when installing the preseed file to the cache location" do - let(:response_file_destination) { Dir.tmpdir + '/preseed--java--java-6.seed' } + let(:response_file_destination) { Dir.tmpdir + "/preseed--java--java-6.seed" } let(:response_file_resource) { response_file_resource = Chef::Resource::CookbookFile.new(response_file_destination, run_context) - response_file_resource.cookbook_name = 'java' + response_file_resource.cookbook_name = "java" response_file_resource.backup(false) - response_file_resource.source('java.response') + response_file_resource.source("java.response") response_file_resource } before do - expect(provider).to receive(:preseed_resource).with('java', '6').and_return(response_file_resource) + expect(provider).to receive(:preseed_resource).with("java", "6").and_return(response_file_resource) end after do @@ -547,7 +547,7 @@ describe "Subclass with use_multipackage_api" do current_resource.package_name "vim" current_resource.version [ "1.0" ] allow(new_resource).to receive(:response_file).and_return(true) - expect(provider).to receive(:get_preseed_file).and_return('/var/cache/preseed-test') + expect(provider).to receive(:get_preseed_file).and_return("/var/cache/preseed-test") allow(provider).to receive(:preseed_package).and_return(true) allow(provider).to receive(:reconfig_package).and_return(true) expect(provider).to receive(:reconfig_package).with( @@ -563,8 +563,8 @@ describe "Chef::Provider::Package - Multi" do let(:node) { Chef::Node.new } let(:events) { Chef::EventDispatch::Dispatcher.new } let(:run_context) { Chef::RunContext.new(node, {}, events) } - let(:new_resource) { Chef::Resource::Package.new(['emacs', 'vi']) } - let(:current_resource) { Chef::Resource::Package.new(['emacs', 'vi']) } + let(:new_resource) { Chef::Resource::Package.new(["emacs", "vi"]) } + let(:current_resource) { Chef::Resource::Package.new(["emacs", "vi"]) } let(:candidate_version) { [ "1.0", "6.2" ] } let(:provider) do provider = Chef::Provider::Package.new(new_resource, run_context) @@ -590,30 +590,30 @@ describe "Chef::Provider::Package - Multi" do it "installs the candidate versions when some are installed" do expect(provider).to receive(:install_package).with( - [ 'vi' ], - [ '6.2' ], + [ "vi" ], + [ "6.2" ], ).and_return(true) - current_resource.version(['1.0', nil]) + current_resource.version(["1.0", nil]) provider.run_action(:install) expect(new_resource).to be_updated end it "installs the specified version when some are out of date" do - current_resource.version(['1.0', '6.2']) - new_resource.version(['1.0', '6.1']) + current_resource.version(["1.0", "6.2"]) + new_resource.version(["1.0", "6.1"]) provider.run_action(:install) expect(new_resource).to be_updated end it "does not install any version if all are installed at the right version" do - current_resource.version(['1.0', '6.2']) - new_resource.version(['1.0', '6.2']) + current_resource.version(["1.0", "6.2"]) + new_resource.version(["1.0", "6.2"]) provider.run_action(:install) expect(new_resource).not_to be_updated_by_last_action end it "does not install any version if all are installed, and no version was specified" do - current_resource.version(['1.0', '6.2']) + current_resource.version(["1.0", "6.2"]) provider.run_action(:install) expect(new_resource).not_to be_updated_by_last_action end @@ -625,42 +625,42 @@ describe "Chef::Provider::Package - Multi" do end it "raises an exception if one is not installed and no candidates are available" do - current_resource.version(['1.0', nil]) - provider.candidate_version = ['1.0', nil] + current_resource.version(["1.0", nil]) + provider.candidate_version = ["1.0", nil] expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end it "does not raise an exception if the packages are installed or have a candidate" do - current_resource.version(['1.0', nil]) - provider.candidate_version = [nil, '6.2'] + current_resource.version(["1.0", nil]) + provider.candidate_version = [nil, "6.2"] expect { provider.run_action(:install) }.not_to raise_error end it "raises an exception if an explicit version is asked for, an old version is installed, but no candidate" do - new_resource.version ['1.0', '6.2'] - current_resource.version(['1.0', '6.1']) - provider.candidate_version = ['1.0', nil] + new_resource.version ["1.0", "6.2"] + current_resource.version(["1.0", "6.1"]) + provider.candidate_version = ["1.0", nil] expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end it "does not raise an exception if an explicit version is asked for, and is installed, but no candidate" do - new_resource.version ['1.0', '6.2'] - current_resource.version(['1.0', '6.2']) - provider.candidate_version = ['1.0', nil] + new_resource.version ["1.0", "6.2"] + current_resource.version(["1.0", "6.2"]) + provider.candidate_version = ["1.0", nil] expect { provider.run_action(:install) }.not_to raise_error end it "raise an exception if an explicit version is asked for, and is not installed, and no candidate" do - new_resource.version ['1.0', '6.2'] - current_resource.version(['1.0', nil]) - provider.candidate_version = ['1.0', nil] + new_resource.version ["1.0", "6.2"] + current_resource.version(["1.0", nil]) + provider.candidate_version = ["1.0", nil] expect { provider.run_action(:install) }.to raise_error(Chef::Exceptions::Package) end it "does not raise an exception if an explicit version is asked for, and is not installed, and there is a candidate" do - new_resource.version ['1.0', '6.2'] - current_resource.version(['1.0', nil]) - provider.candidate_version = ['1.0', '6.2'] + new_resource.version ["1.0", "6.2"] + current_resource.version(["1.0", nil]) + provider.candidate_version = ["1.0", "6.2"] expect { provider.run_action(:install) }.not_to raise_error end end @@ -672,7 +672,7 @@ describe "Chef::Provider::Package - Multi" do end it "should upgrade the package if the current versions are not the candidate version" do - current_resource.version ['0.9', '6.1'] + current_resource.version ["0.9", "6.1"] expect(provider).to receive(:upgrade_package).with( new_resource.package_name, provider.candidate_version, @@ -682,7 +682,7 @@ describe "Chef::Provider::Package - Multi" do end it "should upgrade the package if some of current versions are not the candidate versions" do - current_resource.version ['1.0', '6.1'] + current_resource.version ["1.0", "6.1"] expect(provider).to receive(:upgrade_package).with( ["vi"], ["6.2"], @@ -692,7 +692,7 @@ describe "Chef::Provider::Package - Multi" do end it "should not install the package if the current versions are the candidate version" do - current_resource.version ['1.0', '6.2'] + current_resource.version ["1.0", "6.2"] expect(provider).not_to receive(:upgrade_package) provider.run_action(:upgrade) expect(new_resource).not_to be_updated_by_last_action @@ -705,20 +705,20 @@ describe "Chef::Provider::Package - Multi" do end it "should raise an exception if one is not installed and no candidates are available" do - current_resource.version(['1.0', nil]) - provider.candidate_version = ['1.0', nil] + current_resource.version(["1.0", nil]) + provider.candidate_version = ["1.0", nil] expect { provider.run_action(:upgrade) }.to raise_error(Chef::Exceptions::Package) end it "should not raise an exception if the packages are installed or have a candidate" do - current_resource.version(['1.0', nil]) - provider.candidate_version = [nil, '6.2'] + current_resource.version(["1.0", nil]) + provider.candidate_version = [nil, "6.2"] expect { provider.run_action(:upgrade) }.not_to raise_error end it "should not raise an exception if the packages are installed or have a candidate" do - current_resource.version(['1.0', nil]) - provider.candidate_version = [nil, '6.2'] + current_resource.version(["1.0", nil]) + provider.candidate_version = [nil, "6.2"] expect { provider.run_action(:upgrade) }.not_to raise_error end end @@ -726,44 +726,44 @@ describe "Chef::Provider::Package - Multi" do describe "When removing multiple packages " do before(:each) do allow(provider).to receive(:remove_package).and_return(true) - current_resource.version ['1.0', '6.2'] + current_resource.version ["1.0", "6.2"] end it "should remove the packages if all are installed" do expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(['emacs', 'vi'], nil) + expect(provider).to receive(:remove_package).with(["emacs", "vi"], nil) provider.run_action(:remove) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action end it "should remove the packages if some are installed" do - current_resource.version ['1.0', nil] + current_resource.version ["1.0", nil] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(['emacs', 'vi'], nil) + expect(provider).to receive(:remove_package).with(["emacs", "vi"], nil) provider.run_action(:remove) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action end it "should remove the packages at a specific version if they are installed at that version" do - new_resource.version ['1.0', '6.2'] + new_resource.version ["1.0", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(['emacs', 'vi'], ['1.0', '6.2']) + expect(provider).to receive(:remove_package).with(["emacs", "vi"], ["1.0", "6.2"]) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end it "should remove the packages at a specific version any are is installed at that version" do - new_resource.version ['0.5', '6.2'] + new_resource.version ["0.5", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:remove_package).with(['emacs', 'vi'], ['0.5', '6.2']) + expect(provider).to receive(:remove_package).with(["emacs", "vi"], ["0.5", "6.2"]) provider.run_action(:remove) expect(new_resource).to be_updated_by_last_action end it "should not remove the packages at a specific version if they are not installed at that version" do - new_resource.version ['0.5', '6.0'] + new_resource.version ["0.5", "6.0"] expect(provider).not_to be_removing_package expect(provider).not_to receive(:remove_package) provider.run_action(:remove) @@ -782,44 +782,44 @@ describe "Chef::Provider::Package - Multi" do describe "When purging multiple packages " do before(:each) do allow(provider).to receive(:purge_package).and_return(true) - current_resource.version ['1.0', '6.2'] + current_resource.version ["1.0", "6.2"] end it "should purge the packages if all are installed" do expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(['emacs', 'vi'], nil) + expect(provider).to receive(:purge_package).with(["emacs", "vi"], nil) provider.run_action(:purge) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action end it "should purge the packages if some are installed" do - current_resource.version ['1.0', nil] + current_resource.version ["1.0", nil] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(['emacs', 'vi'], nil) + expect(provider).to receive(:purge_package).with(["emacs", "vi"], nil) provider.run_action(:purge) expect(new_resource).to be_updated expect(new_resource).to be_updated_by_last_action end it "should purge the packages at a specific version if they are installed at that version" do - new_resource.version ['1.0', '6.2'] + new_resource.version ["1.0", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(['emacs', 'vi'], ['1.0', '6.2']) + expect(provider).to receive(:purge_package).with(["emacs", "vi"], ["1.0", "6.2"]) provider.run_action(:purge) expect(new_resource).to be_updated_by_last_action end it "should purge the packages at a specific version any are is installed at that version" do - new_resource.version ['0.5', '6.2'] + new_resource.version ["0.5", "6.2"] expect(provider).to be_removing_package - expect(provider).to receive(:purge_package).with(['emacs', 'vi'], ['0.5', '6.2']) + expect(provider).to receive(:purge_package).with(["emacs", "vi"], ["0.5", "6.2"]) provider.run_action(:purge) expect(new_resource).to be_updated_by_last_action end it "should not purge the packages at a specific version if they are not installed at that version" do - new_resource.version ['0.5', '6.0'] + new_resource.version ["0.5", "6.0"] expect(provider).not_to be_removing_package expect(provider).not_to receive(:purge_package) provider.run_action(:purge) diff --git a/spec/unit/provider/powershell_script_spec.rb b/spec/unit/provider/powershell_script_spec.rb index 121973763d..c4a712d69a 100644 --- a/spec/unit/provider/powershell_script_spec.rb +++ b/spec/unit/provider/powershell_script_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::PowershellScript, "action_run" do let(:powershell_version) { nil } @@ -33,12 +33,12 @@ describe Chef::Provider::PowershellScript, "action_run" do let(:provider) { empty_events = Chef::EventDispatch::Dispatcher.new run_context = Chef::RunContext.new(node, {}, empty_events) - new_resource = Chef::Resource::PowershellScript.new('run some powershell code', run_context) + new_resource = Chef::Resource::PowershellScript.new("run some powershell code", run_context) Chef::Provider::PowershellScript.new(new_resource, run_context) } - context 'when setting interpreter flags' do - context 'on nano' do + context "when setting interpreter flags" do + context "on nano" do before(:each) do allow(Chef::Platform).to receive(:windows_nano_server?).and_return(true) allow(provider).to receive(:is_forced_32bit).and_return(false) @@ -48,12 +48,12 @@ describe Chef::Provider::PowershellScript, "action_run" do end it "sets the -Command flag as the last flag" do - flags = provider.command.split(' ').keep_if { |flag| flag =~ /^-/ } + flags = provider.command.split(" ").keep_if { |flag| flag =~ /^-/ } expect(flags.pop).to eq("-Command") end end - context 'not on nano' do + context "not on nano" do before(:each) do allow(Chef::Platform).to receive(:windows_nano_server?).and_return(false) allow(provider).to receive(:is_forced_32bit).and_return(false) @@ -63,36 +63,36 @@ describe Chef::Provider::PowershellScript, "action_run" do end it "sets the -File flag as the last flag" do - flags = provider.command.split(' ').keep_if { |flag| flag =~ /^-/ } + flags = provider.command.split(" ").keep_if { |flag| flag =~ /^-/ } expect(flags.pop).to eq("-File") end let(:execution_policy_flag) do execution_policy_index = 0 - provider_flags = provider.flags.split(' ') + provider_flags = provider.flags.split(" ") execution_policy_specified = false provider_flags.find do | value | execution_policy_index += 1 - execution_policy_specified = value.downcase == '-ExecutionPolicy'.downcase + execution_policy_specified = value.downcase == "-ExecutionPolicy".downcase end execution_policy = execution_policy_specified ? provider_flags[execution_policy_index] : nil end - context 'when running with an unspecified PowerShell version' do + context "when running with an unspecified PowerShell version" do let(:powershell_version) { nil } it "sets the -ExecutionPolicy flag to 'Unrestricted' by default" do - expect(execution_policy_flag.downcase).to eq('unrestricted'.downcase) + expect(execution_policy_flag.downcase).to eq("unrestricted".downcase) end end - { '2.0' => 'Unrestricted', - '2.5' => 'Unrestricted', - '3.0' => 'Bypass', - '3.6' => 'Bypass', - '4.0' => 'Bypass', - '5.0' => 'Bypass' }.each do | version_policy | + { "2.0" => "Unrestricted", + "2.5" => "Unrestricted", + "3.0" => "Bypass", + "3.6" => "Bypass", + "4.0" => "Bypass", + "5.0" => "Bypass" }.each do | version_policy | let(:powershell_version) { version_policy[0].to_f } context "when running PowerShell version #{version_policy[0]}" do let(:powershell_version) { version_policy[0].to_f } diff --git a/spec/unit/provider/registry_key_spec.rb b/spec/unit/provider/registry_key_spec.rb index 47543ffe39..ef03ec4012 100644 --- a/spec/unit/provider/registry_key_spec.rb +++ b/spec/unit/provider/registry_key_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" shared_examples_for "a registry key" do before(:each) do diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb index 6426dafd79..0103169e84 100644 --- a/spec/unit/provider/remote_directory_spec.rb +++ b/spec/unit/provider/remote_directory_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' -require 'digest/md5' -require 'tmpdir' -require 'chef/mixin/file_class' +require "spec_helper" +require "digest/md5" +require "tmpdir" +require "chef/mixin/file_class" class Chef::CFCCheck include Chef::Mixin::FileClass @@ -32,7 +32,7 @@ describe Chef::Provider::RemoteDirectory do @resource = Chef::Resource::RemoteDirectory.new(File.join(Dir.tmpdir, "tafty")) # in CHEF_SPEC_DATA/cookbooks/openldap/files/default/remotedir @resource.source "remotedir" - @resource.cookbook('openldap') + @resource.cookbook("openldap") @cookbook_repo = ::File.expand_path(::File.join(CHEF_SPEC_DATA, "cookbooks")) Chef::Cookbook::FileVendor.fetch_from_disk(@cookbook_repo) @@ -121,12 +121,12 @@ describe Chef::Provider::RemoteDirectory do it "transfers the directory with all contents" do @provider.run_action(:create) - expect(::File.exist?(@destination_dir + '/remote_dir_file1.txt')).to be_truthy - expect(::File.exist?(@destination_dir + '/remote_dir_file2.txt')).to be_truthy - expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')).to be_truthy - expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file2.txt')).to be_truthy - expect(::File.exist?(@destination_dir + '/remotesubdir/.a_dotfile')).to be_truthy - expect(::File.exist?(@destination_dir + '/.a_dotdir/.a_dotfile_in_a_dotdir')).to be_truthy + expect(::File.exist?(@destination_dir + "/remote_dir_file1.txt")).to be_truthy + expect(::File.exist?(@destination_dir + "/remote_dir_file2.txt")).to be_truthy + expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")).to be_truthy + expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file2.txt")).to be_truthy + expect(::File.exist?(@destination_dir + "/remotesubdir/.a_dotfile")).to be_truthy + expect(::File.exist?(@destination_dir + "/.a_dotdir/.a_dotfile_in_a_dotdir")).to be_truthy end describe "only if it is missing" do @@ -134,15 +134,15 @@ describe Chef::Provider::RemoteDirectory do @resource.overwrite(true) @provider.run_action(:create) - File.open(@destination_dir + '/remote_dir_file1.txt', 'a') {|f| f.puts "blah blah blah" } - File.open(@destination_dir + '/remotesubdir/remote_subdir_file1.txt', 'a') {|f| f.puts "blah blah blah" } - file1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + '/remote_dir_file1.txt')) - subdirfile1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')) + File.open(@destination_dir + "/remote_dir_file1.txt", "a") {|f| f.puts "blah blah blah" } + File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") {|f| f.puts "blah blah blah" } + file1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + "/remote_dir_file1.txt")) + subdirfile1md5 = Digest::MD5.hexdigest(File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")) @provider.run_action(:create_if_missing) - expect(file1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + '/remote_dir_file1.txt')))).to be_truthy - expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')))).to be_truthy + expect(file1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + "/remote_dir_file1.txt")))).to be_truthy + expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")))).to be_truthy end end @@ -151,35 +151,35 @@ describe Chef::Provider::RemoteDirectory do it "removes existing files if purge is true" do @provider.run_action(:create) - FileUtils.touch(@destination_dir + '/marked_for_death.txt') - FileUtils.touch(@destination_dir + '/remotesubdir/marked_for_death_again.txt') + FileUtils.touch(@destination_dir + "/marked_for_death.txt") + FileUtils.touch(@destination_dir + "/remotesubdir/marked_for_death_again.txt") @provider.run_action(:create) - expect(::File.exist?(@destination_dir + '/remote_dir_file1.txt')).to be_truthy - expect(::File.exist?(@destination_dir + '/remote_dir_file2.txt')).to be_truthy - expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')).to be_truthy - expect(::File.exist?(@destination_dir + '/remotesubdir/remote_subdir_file2.txt')).to be_truthy + expect(::File.exist?(@destination_dir + "/remote_dir_file1.txt")).to be_truthy + expect(::File.exist?(@destination_dir + "/remote_dir_file2.txt")).to be_truthy + expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")).to be_truthy + expect(::File.exist?(@destination_dir + "/remotesubdir/remote_subdir_file2.txt")).to be_truthy - expect(::File.exist?(@destination_dir + '/marked_for_death.txt')).to be_falsey - expect(::File.exist?(@destination_dir + '/remotesubdir/marked_for_death_again.txt')).to be_falsey + expect(::File.exist?(@destination_dir + "/marked_for_death.txt")).to be_falsey + expect(::File.exist?(@destination_dir + "/remotesubdir/marked_for_death_again.txt")).to be_falsey end it "removes files in subdirectories before files above" do @provider.run_action(:create) - FileUtils.mkdir_p(@destination_dir + '/a/multiply/nested/directory/') - FileUtils.touch(@destination_dir + '/a/foo.txt') - FileUtils.touch(@destination_dir + '/a/multiply/bar.txt') - FileUtils.touch(@destination_dir + '/a/multiply/nested/baz.txt') - FileUtils.touch(@destination_dir + '/a/multiply/nested/directory/qux.txt') + FileUtils.mkdir_p(@destination_dir + "/a/multiply/nested/directory/") + FileUtils.touch(@destination_dir + "/a/foo.txt") + FileUtils.touch(@destination_dir + "/a/multiply/bar.txt") + FileUtils.touch(@destination_dir + "/a/multiply/nested/baz.txt") + FileUtils.touch(@destination_dir + "/a/multiply/nested/directory/qux.txt") @provider.run_action(:create) - expect(::File.exist?(@destination_dir + '/a/foo.txt')).to be_falsey - expect(::File.exist?(@destination_dir + '/a/multiply/bar.txt')).to be_falsey - expect(::File.exist?(@destination_dir + '/a/multiply/nested/baz.txt')).to be_falsey - expect(::File.exist?(@destination_dir + '/a/multiply/nested/directory/qux.txt')).to be_falsey + expect(::File.exist?(@destination_dir + "/a/foo.txt")).to be_falsey + expect(::File.exist?(@destination_dir + "/a/multiply/bar.txt")).to be_falsey + expect(::File.exist?(@destination_dir + "/a/multiply/nested/baz.txt")).to be_falsey + expect(::File.exist?(@destination_dir + "/a/multiply/nested/directory/qux.txt")).to be_falsey end it "removes directory symlinks properly", :not_supported_on_win2k3 do - symlinked_dir_path = @destination_dir + '/symlinked_dir' + symlinked_dir_path = @destination_dir + "/symlinked_dir" @provider.action = :create @provider.run_action @@ -207,13 +207,13 @@ describe Chef::Provider::RemoteDirectory do it "leaves modifications alone" do @provider.run_action(:create) - ::File.open(@destination_dir + '/remote_dir_file1.txt', 'a') {|f| f.puts "blah blah blah" } - ::File.open(@destination_dir + '/remotesubdir/remote_subdir_file1.txt', 'a') {|f| f.puts "blah blah blah" } - file1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + '/remote_dir_file1.txt')) - subdirfile1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')) + ::File.open(@destination_dir + "/remote_dir_file1.txt", "a") {|f| f.puts "blah blah blah" } + ::File.open(@destination_dir + "/remotesubdir/remote_subdir_file1.txt", "a") {|f| f.puts "blah blah blah" } + file1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + "/remote_dir_file1.txt")) + subdirfile1md5 = Digest::MD5.hexdigest(::File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")) @provider.run_action(:create) - expect(file1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + '/remote_dir_file1.txt')))).to be_truthy - expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + '/remotesubdir/remote_subdir_file1.txt')))).to be_truthy + expect(file1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + "/remote_dir_file1.txt")))).to be_truthy + expect(subdirfile1md5.eql?(Digest::MD5.hexdigest(::File.read(@destination_dir + "/remotesubdir/remote_subdir_file1.txt")))).to be_truthy end end diff --git a/spec/unit/provider/remote_file/cache_control_data_spec.rb b/spec/unit/provider/remote_file/cache_control_data_spec.rb index c154c4228e..a0c200bc79 100644 --- a/spec/unit/provider/remote_file/cache_control_data_spec.rb +++ b/spec/unit/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" CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH = 64 CACHE_FILE_CHECKSUM_HEX_LENGTH = 32 @@ -136,7 +136,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do end context "and it still is valid JSON" do - let(:cache_json_data) { '' } + let(:cache_json_data) { "" } it "returns empty cache control data" do expect(cache_control_data.etag).to be_nil @@ -214,16 +214,16 @@ describe Chef::Provider::RemoteFile::CacheControlData do # local file system path limits resulting in exceptions from # file system API's on both Windows and Unix systems. context "and the URI results in a file cache path that exceeds #{CACHE_FILE_PATH_LIMIT} characters in length" do - let(:long_remote_path) { "http://www.bing.com/" + ('0' * (CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH * 2 )) } + let(:long_remote_path) { "http://www.bing.com/" + ("0" * (CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH * 2 )) } let(:uri) { URI.parse(long_remote_path) } let(:truncated_remote_uri) { URI.parse(long_remote_path[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH]) } let(:truncated_file_cache_path) do cache_control_data_truncated = Chef::Provider::RemoteFile::CacheControlData.load_and_validate(truncated_remote_uri, current_file_checksum) - cache_control_data_truncated.send('sanitized_cache_file_basename')[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH] + cache_control_data_truncated.send("sanitized_cache_file_basename")[0...CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH] end it "truncates the file cache path to 102 characters" do - normalized_cache_path = cache_control_data.send('sanitized_cache_file_basename') + normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename") expect(Chef::FileCache).to receive(:store).with("remote_file/" + normalized_cache_path, cache_control_data.json_data) @@ -233,7 +233,7 @@ describe Chef::Provider::RemoteFile::CacheControlData do end it "uses a file cache path that starts with the first #{CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH} characters of the URI" do - normalized_cache_path = cache_control_data.send('sanitized_cache_file_basename') + normalized_cache_path = cache_control_data.send("sanitized_cache_file_basename") expect(truncated_file_cache_path.length).to eq(CACHE_FILE_TRUNCATED_FRIENDLY_FILE_NAME_LENGTH) expect(normalized_cache_path.start_with?(truncated_file_cache_path)).to eq(true) diff --git a/spec/unit/provider/remote_file/content_spec.rb b/spec/unit/provider/remote_file/content_spec.rb index 2639c39faa..c1e827887a 100644 --- a/spec/unit/provider/remote_file/content_spec.rb +++ b/spec/unit/provider/remote_file/content_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::RemoteFile::Content do diff --git a/spec/unit/provider/remote_file/fetcher_spec.rb b/spec/unit/provider/remote_file/fetcher_spec.rb index 8bd3b7c625..10742bc671 100644 --- a/spec/unit/provider/remote_file/fetcher_spec.rb +++ b/spec/unit/provider/remote_file/fetcher_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::RemoteFile::Fetcher do diff --git a/spec/unit/provider/remote_file/ftp_spec.rb b/spec/unit/provider/remote_file/ftp_spec.rb index dbbddd8e84..4292a744a5 100644 --- a/spec/unit/provider/remote_file/ftp_spec.rb +++ b/spec/unit/provider/remote_file/ftp_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::RemoteFile::FTP do let(:enclosing_directory) { diff --git a/spec/unit/provider/remote_file/http_spec.rb b/spec/unit/provider/remote_file/http_spec.rb index d9cfaa15eb..a08e65add3 100644 --- a/spec/unit/provider/remote_file/http_spec.rb +++ b/spec/unit/provider/remote_file/http_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::RemoteFile::HTTP do diff --git a/spec/unit/provider/remote_file/local_file_spec.rb b/spec/unit/provider/remote_file/local_file_spec.rb index 575996a540..791d411e03 100644 --- a/spec/unit/provider/remote_file/local_file_spec.rb +++ b/spec/unit/provider/remote_file/local_file_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::RemoteFile::LocalFile do diff --git a/spec/unit/provider/remote_file/network_file_spec.rb b/spec/unit/provider/remote_file/network_file_spec.rb index 3666a47468..38e0acd13f 100644 --- a/spec/unit/provider/remote_file/network_file_spec.rb +++ b/spec/unit/provider/remote_file/network_file_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::RemoteFile::NetworkFile do diff --git a/spec/unit/provider/remote_file_spec.rb b/spec/unit/provider/remote_file_spec.rb index de4a897847..d6381905e9 100644 --- a/spec/unit/provider/remote_file_spec.rb +++ b/spec/unit/provider/remote_file_spec.rb @@ -17,9 +17,9 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'support/shared/unit/provider/file' +require "support/shared/unit/provider/file" describe Chef::Provider::RemoteFile do @@ -32,12 +32,12 @@ describe Chef::Provider::RemoteFile do end let(:content) do - content = double('Chef::Provider::File::Content::RemoteFile') + content = double("Chef::Provider::File::Content::RemoteFile") end - let(:node) { double('Chef::Node') } - let(:events) { double('Chef::Events').as_null_object } # mock all the methods - let(:run_context) { double('Chef::RunContext', :node => node, :events => events) } + let(:node) { double("Chef::Node") } + let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) } diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb index ff68eea895..0205df430c 100644 --- a/spec/unit/provider/route_spec.rb +++ b/spec/unit/provider/route_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Route do before do @@ -25,9 +25,9 @@ describe Chef::Provider::Route do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, @cookbook_collection, @events) - @new_resource = Chef::Resource::Route.new('10.0.0.10') + @new_resource = Chef::Resource::Route.new("10.0.0.10") @new_resource.gateway "10.0.0.9" - @current_resource = Chef::Resource::Route.new('10.0.0.10') + @current_resource = Chef::Resource::Route.new("10.0.0.10") @current_resource.gateway "10.0.0.9" @provider = Chef::Provider::Route.new(@new_resource, @run_context) @@ -36,14 +36,14 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "hex2ip" do it "should return nil if ip address is invalid" do - expect(@provider.hex2ip('foo')).to be_nil # does not even look like an ip - expect(@provider.hex2ip('ABCDEFGH')).to be_nil # 8 chars, but invalid + expect(@provider.hex2ip("foo")).to be_nil # does not even look like an ip + expect(@provider.hex2ip("ABCDEFGH")).to be_nil # 8 chars, but invalid end it "should return quad-dotted notation for a valid IP" do - expect(@provider.hex2ip('01234567')).to eq('103.69.35.1') - expect(@provider.hex2ip('0064a8c0')).to eq('192.168.100.0') - expect(@provider.hex2ip('00FFFFFF')).to eq('255.255.255.0') + expect(@provider.hex2ip("01234567")).to eq("103.69.35.1") + expect(@provider.hex2ip("0064a8c0")).to eq("192.168.100.0") + expect(@provider.hex2ip("00FFFFFF")).to eq("255.255.255.0") end end @@ -51,7 +51,7 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "load_current_resource" do context "on linux" do before do - @node.automatic_attrs[:os] = 'linux' + @node.automatic_attrs[:os] = "linux" routing_table = "Iface Destination Gateway Flags RefCnt Use Metric Mask MTU Window IRTT\n" + "eth0 0064A8C0 0984A8C0 0003 0 0 0 00FFFFFF 0 0 0\n" route_file = StringIO.new(routing_table) @@ -59,7 +59,7 @@ describe Chef::Provider::Route do end it "should set is_running to false when a route is not detected" do - resource = Chef::Resource::Route.new('10.10.10.0/24') + resource = Chef::Resource::Route.new("10.10.10.0/24") allow(resource).to receive(:gateway).and_return("10.0.0.1") allow(resource).to receive(:device).and_return("eth0") provider = Chef::Provider::Route.new(resource, @run_context) @@ -69,7 +69,7 @@ describe Chef::Provider::Route do end it "should detect existing routes and set is_running attribute correctly" do - resource = Chef::Resource::Route.new('192.168.100.0/24') + resource = Chef::Resource::Route.new("192.168.100.0/24") allow(resource).to receive(:gateway).and_return("192.168.132.9") allow(resource).to receive(:device).and_return("eth0") provider = Chef::Provider::Route.new(resource, @run_context) @@ -79,7 +79,7 @@ describe Chef::Provider::Route do end it "should use gateway value when matching routes" do - resource = Chef::Resource::Route.new('192.168.100.0/24') + resource = Chef::Resource::Route.new("192.168.100.0/24") allow(resource).to receive(:gateway).and_return("10.10.10.10") allow(resource).to receive(:device).and_return("eth0") provider = Chef::Provider::Route.new(resource, @run_context) @@ -110,11 +110,11 @@ describe Chef::Provider::Route do end it "should not delete config file for :add action (CHEF-3332)" do - @node.automatic_attrs[:platform] = 'centos' + @node.automatic_attrs[:platform] = "centos" route_file = StringIO.new expect(File).to receive(:new).and_return(route_file) - @resource_add = Chef::Resource::Route.new('192.168.1.0/24 via 192.168.0.1') + @resource_add = Chef::Resource::Route.new("192.168.1.0/24 via 192.168.0.1") @run_context.resource_collection << @resource_add allow(@provider).to receive(:run_command).and_return(true) @@ -145,7 +145,7 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "generate_command for action_add" do it "should include a netmask when a one is specified" do - allow(@new_resource).to receive(:netmask).and_return('255.255.0.0') + allow(@new_resource).to receive(:netmask).and_return("255.255.0.0") expect(@provider.generate_command(:add)).to match(/\/\d{1,2}\s/) end @@ -166,7 +166,7 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "generate_command for action_delete" do it "should include a netmask when a one is specified" do - allow(@new_resource).to receive(:netmask).and_return('255.255.0.0') + allow(@new_resource).to receive(:netmask).and_return("255.255.0.0") expect(@provider.generate_command(:delete)).to match(/\/\d{1,2}\s/) end @@ -187,7 +187,7 @@ describe Chef::Provider::Route do describe Chef::Provider::Route, "config_file_contents for action_add" do it "should include a netmask when a one is specified" do - allow(@new_resource).to receive(:netmask).and_return('255.255.0.0') + allow(@new_resource).to receive(:netmask).and_return("255.255.0.0") expect(@provider.config_file_contents(:add, { :target => @new_resource.target, :netmask => @new_resource.netmask})).to match(/\/\d{1,2}.*\n$/) end @@ -224,13 +224,13 @@ describe Chef::Provider::Route do end it "should put all routes for a device in a route config file" do - @node.automatic_attrs[:platform] = 'centos' + @node.automatic_attrs[:platform] = "centos" route_file = StringIO.new expect(File).to receive(:new).and_return(route_file) - @run_context.resource_collection << Chef::Resource::Route.new('192.168.1.0/24 via 192.168.0.1') - @run_context.resource_collection << Chef::Resource::Route.new('192.168.2.0/24 via 192.168.0.1') - @run_context.resource_collection << Chef::Resource::Route.new('192.168.3.0/24 via 192.168.0.1') + @run_context.resource_collection << Chef::Resource::Route.new("192.168.1.0/24 via 192.168.0.1") + @run_context.resource_collection << Chef::Resource::Route.new("192.168.2.0/24 via 192.168.0.1") + @run_context.resource_collection << Chef::Resource::Route.new("192.168.3.0/24 via 192.168.0.1") @provider.action = :add @provider.generate_config diff --git a/spec/unit/provider/ruby_block_spec.rb b/spec/unit/provider/ruby_block_spec.rb index 266c943367..c306d0ae9c 100644 --- a/spec/unit/provider/ruby_block_spec.rb +++ b/spec/unit/provider/ruby_block_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::RubyBlock, "initialize" do before(:each) do diff --git a/spec/unit/provider/script_spec.rb b/spec/unit/provider/script_spec.rb index 7cc5abbd15..e488b0ef79 100644 --- a/spec/unit/provider/script_spec.rb +++ b/spec/unit/provider/script_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Script, "action_run" do let(:node) { Chef::Node.new } @@ -26,9 +26,9 @@ describe Chef::Provider::Script, "action_run" do let(:run_context) { Chef::RunContext.new(node, {}, events) } let(:new_resource) { - new_resource = Chef::Resource::Script.new('run some perl code') + new_resource = Chef::Resource::Script.new("run some perl code") new_resource.code "$| = 1; print 'i like beans'" - new_resource.interpreter 'perl' + new_resource.interpreter "perl" new_resource } @@ -58,9 +58,9 @@ describe Chef::Provider::Script, "action_run" do context "#set_owner_and_group" do it "sets the owner and group for the script file" do - new_resource.user 'toor' - new_resource.group 'wheel' - expect(FileUtils).to receive(:chown).with('toor', 'wheel', tempfile.path) + new_resource.user "toor" + new_resource.group "wheel" + expect(FileUtils).to receive(:chown).with("toor", "wheel", tempfile.path) provider.set_owner_and_group end end @@ -99,13 +99,13 @@ describe Chef::Provider::Script, "action_run" do expect(provider.command).to eq(%Q{"perl" "#{tempfile.path}"}) end - it 'should call shell_out! with the command' do + it "should call shell_out! with the command" do expect(provider).to receive(:shell_out!).with(provider.command, default_opts).and_return(true) provider.action_run end it "should set the command to 'interpreter flags tempfile'" do - new_resource.flags '-f' + new_resource.flags "-f" expect(provider.command).to eq(%Q{"perl" -f "#{tempfile.path}"}) end end diff --git a/spec/unit/provider/service/aix_service_spec.rb b/spec/unit/provider/service/aix_service_spec.rb index 5cca7d6f0a..abfc19d94f 100644 --- a/spec/unit/provider/service/aix_service_spec.rb +++ b/spec/unit/provider/service/aix_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Aix do before(:each) do @@ -133,7 +133,7 @@ describe Chef::Provider::Service::Aix do end it "should call the start command for groups" do - @provider.instance_eval('@is_resource_group = true') + @provider.instance_eval("@is_resource_group = true") expect(@provider).to receive(:shell_out!).with("startsrc -g #{@new_resource.service_name}") @provider.start_service @@ -152,7 +152,7 @@ describe Chef::Provider::Service::Aix do end it "should call the stop command for groups" do - @provider.instance_eval('@is_resource_group = true') + @provider.instance_eval("@is_resource_group = true") expect(@provider).to receive(:shell_out!).with("stopsrc -g #{@new_resource.service_name}") @provider.stop_service @@ -171,7 +171,7 @@ describe Chef::Provider::Service::Aix do end it "should call the reload command for groups" do - @provider.instance_eval('@is_resource_group = true') + @provider.instance_eval("@is_resource_group = true") expect(@provider).to receive(:shell_out!).with("refresh -g #{@new_resource.service_name}") @provider.reload_service diff --git a/spec/unit/provider/service/aixinit_service_spec.rb b/spec/unit/provider/service/aixinit_service_spec.rb index 9977343daa..9274c3001b 100644 --- a/spec/unit/provider/service/aixinit_service_spec.rb +++ b/spec/unit/provider/service/aixinit_service_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::AixInit do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = {:ps => 'fuuuu'} + @node.automatic_attrs[:command] = {:ps => "fuuuu"} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -102,7 +102,7 @@ describe Chef::Provider::Service::AixInit do context "when the service doesn't set a priority" do it "creates symlink with status S" do - expect(@provider).to receive(:create_symlink).with(2,'S','') + expect(@provider).to receive(:create_symlink).with(2,"S","") @provider.enable_service end @@ -114,7 +114,7 @@ describe Chef::Provider::Service::AixInit do end it "creates a symlink with status S and a priority" do - expect(@provider).to receive(:create_symlink).with(2,'S',75) + expect(@provider).to receive(:create_symlink).with(2,"S",75) @provider.enable_service end @@ -127,8 +127,8 @@ describe Chef::Provider::Service::AixInit do end it "create symlink with status start (S) or stop (K) and a priority " do - expect(@provider).to receive(:create_symlink).with(2,'S',20) - expect(@provider).to receive(:create_symlink).with(3,'K',10) + expect(@provider).to receive(:create_symlink).with(2,"S",20) + expect(@provider).to receive(:create_symlink).with(3,"K",10) @provider.enable_service end @@ -142,7 +142,7 @@ describe Chef::Provider::Service::AixInit do context "when the service doesn't set a priority" do it "creates symlinks with status stop (K)" do - expect(@provider).to receive(:create_symlink).with(2,'K','') + expect(@provider).to receive(:create_symlink).with(2,"K","") @provider.disable_service end @@ -154,7 +154,7 @@ describe Chef::Provider::Service::AixInit do end it "create symlink with status stop (k) and a priority " do - expect(@provider).to receive(:create_symlink).with(2,'K',25) + expect(@provider).to receive(:create_symlink).with(2,"K",25) @provider.disable_service end @@ -167,7 +167,7 @@ describe Chef::Provider::Service::AixInit do end it "create symlink with status stop (k) and a priority " do - expect(@provider).to receive(:create_symlink).with(3,'K',90) + expect(@provider).to receive(:create_symlink).with(3,"K",90) @provider.disable_service end @@ -231,7 +231,7 @@ describe Chef::Provider::Service::AixInit do it "the service is enabled" do expect(@provider.current_resource).to receive(:enabled).with(true) - expect(@provider.current_resource).to receive(:priority).with('') + expect(@provider.current_resource).to receive(:priority).with("") @provider.set_current_resource_attributes end @@ -240,7 +240,7 @@ describe Chef::Provider::Service::AixInit do context "when rc2.d contains only stop script (without priority)" do before do files = ["/etc/rc.d/rc2.d/Kapache"] - @priority = {2 => [:stop, '']} + @priority = {2 => [:stop, ""]} allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).and_return(files) end @@ -257,7 +257,7 @@ describe Chef::Provider::Service::AixInit do files = ["/etc/rc.d/rc2.d/Sapache", "/etc/rc.d/rc2.d/Kapache"] # FIXME: this is clearly buggy the duplicated keys do not work #@priority = {2 => [:start, ''], 2 => [:stop, '']} - @priority = {2 => [:stop, '']} + @priority = {2 => [:stop, ""]} allow(Dir).to receive(:glob).with(["/etc/rc.d/rc2.d/[SK][0-9][0-9]#{@new_resource.service_name}", "/etc/rc.d/rc2.d/[SK]#{@new_resource.service_name}"]).and_return(files) end diff --git a/spec/unit/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index 49be0e274c..40f87b24bf 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_service_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" # most of this code has been ripped from init_service_spec.rb # and is only slightly modified to match "arch" needs. @@ -45,7 +45,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do it "should set the current resources service name to the new resources service name" do allow(@provider).to receive(:shell_out).and_return(OpenStruct.new(:exitstatus => 0, :stdout => "")) @provider.load_current_resource - expect(@provider.current_resource.service_name).to eq('chef') + expect(@provider.current_resource.service_name).to eq("chef") end end @@ -155,7 +155,7 @@ RUNNING_PS it "should return existing entries in DAEMONS array" do allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network !apache ssh)") - expect(@provider.daemons).to eq(['network', '!apache', 'ssh']) + expect(@provider.daemons).to eq(["network", "!apache", "ssh"]) end context "when the current service status is known" do @@ -180,7 +180,7 @@ RUNNING_PS it "should add chef to DAEMONS array" do allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network)") - expect(@provider).to receive(:update_daemons).with(['network', 'chef']) + expect(@provider).to receive(:update_daemons).with(["network", "chef"]) @provider.enable_service() end end @@ -201,7 +201,7 @@ RUNNING_PS it "should remove chef from DAEMONS array" do allow(::File).to receive(:read).with("/etc/rc.conf").and_return("DAEMONS=(network chef)") - expect(@provider).to receive(:update_daemons).with(['network', '!chef']) + expect(@provider).to receive(:update_daemons).with(["network", "!chef"]) @provider.disable_service() end end diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb index 346e349db7..79c51d0ea7 100644 --- a/spec/unit/provider/service/debian_service_spec.rb +++ b/spec/unit/provider/service/debian_service_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Debian do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = {:ps => 'fuuuu'} + @node.automatic_attrs[:command] = {:ps => "fuuuu"} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) diff --git a/spec/unit/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index cfc28c94d5..5bfa8ff6c0 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class Chef::Provider::Service::Freebsd public :service_enable_variable_name diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index b4155f9628..8bfac80002 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_service_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Gentoo do before(:each) do diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index 827a4261e1..2594a732d9 100644 --- a/spec/unit/provider/service/init_service_spec.rb +++ b/spec/unit/provider/service/init_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Init, "load_current_resource" do before(:each) do @@ -48,7 +48,7 @@ PS it "should set the current resources service name to the new resources service name" do @provider.load_current_resource - expect(@current_resource.service_name).to eq('chef') + expect(@current_resource.service_name).to eq("chef") end describe "when the service supports status" do diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb index 3799daebb4..fccbfac2b3 100644 --- a/spec/unit/provider/service/insserv_service_spec.rb +++ b/spec/unit/provider/service/insserv_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Insserv do before(:each) do diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index 81588c80e5..d8d860a291 100644 --- a/spec/unit/provider/service/invokercd_service_spec.rb +++ b/spec/unit/provider/service/invokercd_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Invokercd, "load_current_resource" do before(:each) do @@ -48,7 +48,7 @@ PS it "should set the current resources service name to the new resources service name" do @provider.load_current_resource - expect(@current_resource.service_name).to eq('chef') + expect(@current_resource.service_name).to eq("chef") end describe "when the service supports status" do diff --git a/spec/unit/provider/service/macosx_spec.rb b/spec/unit/provider/service/macosx_spec.rb index 54183bdc3d..c3204700d7 100644 --- a/spec/unit/provider/service/macosx_spec.rb +++ b/spec/unit/provider/service/macosx_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Macosx do describe ".gather_plist_dirs" do context "when HOME directory is set" do before do - allow(Chef::Util::PathHelper).to receive(:home).with('Library', 'LaunchAgents').and_yield('/Users/someuser/Library/LaunchAgents') + allow(Chef::Util::PathHelper).to receive(:home).with("Library", "LaunchAgents").and_yield("/Users/someuser/Library/LaunchAgents") end it "includes users's LaunchAgents folder" do @@ -32,7 +32,7 @@ describe Chef::Provider::Service::Macosx do context "when HOME directory is not set" do before do - allow(Chef::Util::PathHelper).to receive(:home).with('Library', 'LaunchAgents').and_return(nil) + allow(Chef::Util::PathHelper).to receive(:home).with("Library", "LaunchAgents").and_return(nil) end it "doesn't include user's LaunchAgents folder" do @@ -61,20 +61,20 @@ XML ["Daemon", "Agent"].each do |service_type| ["redis-server", "io.redis.redis-server"].each do |service_name| ["10.9", "10.10", "10.11"].each do |platform_version| - let(:plist) {'/Library/LaunchDaemons/io.redis.redis-server.plist'} + let(:plist) {"/Library/LaunchDaemons/io.redis.redis-server.plist"} let(:session) { StringIO.new } - if service_type == 'Agent' - let(:plist) {'/Library/LaunchAgents/io.redis.redis-server.plist'} - let(:session) {'-S Aqua '} - let(:su_cmd) {'su -l igor -c'} + if service_type == "Agent" + let(:plist) {"/Library/LaunchAgents/io.redis.redis-server.plist"} + let(:session) {"-S Aqua "} + let(:su_cmd) {"su -l igor -c"} if platform_version == "10.9" - let(:su_cmd) {'su igor -c'} + let(:su_cmd) {"su igor -c"} end end - let(:service_label) {'io.redis.redis-server'} + let(:service_label) {"io.redis.redis-server"} before do allow(Dir).to receive(:glob).and_return([plist], []) - allow(Etc).to receive(:getlogin).and_return('igor') + allow(Etc).to receive(:getlogin).and_return("igor") allow(node).to receive(:[]).with("platform_version").and_return(platform_version) cmd = "launchctl list #{service_label}" allow(provider).to receive(:shell_out_with_systems_locale). @@ -263,7 +263,7 @@ SVC_LIST end it "starts service via launchctl if service found" do - cmd = 'launchctl load -w ' + session + plist + cmd = "launchctl load -w " + session + plist expect(provider).to receive(:shell_out_with_systems_locale). with(/(#{su_cmd} .#{cmd}.|#{cmd})/). and_return(0) @@ -295,7 +295,7 @@ SVC_LIST end it "stops the service via launchctl if service found" do - cmd = 'launchctl unload -w '+ plist + cmd = "launchctl unload -w "+ plist expect(provider).to receive(:shell_out_with_systems_locale). with(/(#{su_cmd} .#{cmd}.|#{cmd})/). and_return(0) diff --git a/spec/unit/provider/service/openbsd_service_spec.rb b/spec/unit/provider/service/openbsd_service_spec.rb index 8118e9b3ee..c08a97e7b1 100644 --- a/spec/unit/provider/service/openbsd_service_spec.rb +++ b/spec/unit/provider/service/openbsd_service_spec.rb @@ -18,7 +18,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class Chef::Provider::Service::Openbsd public :builtin_service_enable_variable_name @@ -52,8 +52,8 @@ describe Chef::Provider::Service::Openbsd do let(:provider) do events = Chef::EventDispatch::Dispatcher.new run_context = Chef::RunContext.new(node, {}, events) - allow(::File).to receive(:read).with('/etc/rc.conf').and_return('') - allow(::File).to receive(:read).with('/etc/rc.conf.local').and_return('') + allow(::File).to receive(:read).with("/etc/rc.conf").and_return("") + allow(::File).to receive(:read).with("/etc/rc.conf.local").and_return("") provider = Chef::Provider::Service::Openbsd.new(new_resource,run_context) provider.action = :start provider @@ -80,7 +80,7 @@ describe Chef::Provider::Service::Openbsd do end it "should set init_command to nil if it can't find anything" do - expect(::File).to receive(:exist?).with('/etc/rc.d/sndiod').and_return(false) + expect(::File).to receive(:exist?).with("/etc/rc.d/sndiod").and_return(false) expect(provider.init_command).to be nil end end @@ -381,7 +381,7 @@ describe Chef::Provider::Service::Openbsd do describe Chef::Provider::Service::Openbsd, "enable_service" do before do provider.current_resource = current_resource - allow(FileUtils).to receive(:touch).with('/etc/rc.conf.local') + allow(FileUtils).to receive(:touch).with("/etc/rc.conf.local") end context "is builtin and disabled by default" do before do @@ -398,10 +398,10 @@ describe Chef::Provider::Service::Openbsd do end context "is disabled" do before do - provider.rc_conf_local = '' + provider.rc_conf_local = "" end it "should enable the service by adding a line to rc.conf.local" do - expect(::File).to receive(:write).with('/etc/rc.conf.local', include("#{provider.builtin_service_enable_variable_name}=\"\"")) + expect(::File).to receive(:write).with("/etc/rc.conf.local", include("#{provider.builtin_service_enable_variable_name}=\"\"")) expect(provider.is_enabled?).to be false provider.enable_service expect(provider.is_enabled?).to be true @@ -414,7 +414,7 @@ describe Chef::Provider::Service::Openbsd do end context "is enabled" do before do - provider.rc_conf_local = '' + provider.rc_conf_local = "" end it "should not change rc.conf.local since it is already enabled" do expect(::File).not_to receive(:write) @@ -426,7 +426,7 @@ describe Chef::Provider::Service::Openbsd do provider.rc_conf_local = "#{provider.builtin_service_enable_variable_name}=NO" end it "should enable the service by removing a line from rc.conf.local" do - expect(::File).to receive(:write).with('/etc/rc.conf.local', /^(?!#{provider.builtin_service_enable_variable_name})$/) + expect(::File).to receive(:write).with("/etc/rc.conf.local", /^(?!#{provider.builtin_service_enable_variable_name})$/) expect(provider.is_enabled?).to be false provider.enable_service expect(provider.is_enabled?).to be true @@ -435,7 +435,7 @@ describe Chef::Provider::Service::Openbsd do end context "is not builtin" do before do - provider.rc_conf = '' + provider.rc_conf = "" end context "is enabled" do before do @@ -448,10 +448,10 @@ describe Chef::Provider::Service::Openbsd do end context "is disabled" do before do - provider.rc_conf_local = '' + provider.rc_conf_local = "" end it "should enable the service by adding it to the pkg_scripts list" do - expect(::File).to receive(:write).with('/etc/rc.conf.local', "\npkg_scripts=\"#{new_resource.service_name}\"\n") + expect(::File).to receive(:write).with("/etc/rc.conf.local", "\npkg_scripts=\"#{new_resource.service_name}\"\n") expect(provider.is_enabled?).to be false provider.enable_service expect(provider.is_enabled?).to be true @@ -463,7 +463,7 @@ describe Chef::Provider::Service::Openbsd do describe Chef::Provider::Service::Openbsd, "disable_service" do before do provider.current_resource = current_resource - allow(FileUtils).to receive(:touch).with('/etc/rc.conf.local') + allow(FileUtils).to receive(:touch).with("/etc/rc.conf.local") end context "is builtin and disabled by default" do before do @@ -474,7 +474,7 @@ describe Chef::Provider::Service::Openbsd do provider.rc_conf_local = "#{provider.builtin_service_enable_variable_name}=\"\"" end it "should disable the service by removing its line from rc.conf.local" do - expect(::File).to receive(:write).with('/etc/rc.conf.local', /^(?!#{provider.builtin_service_enable_variable_name})$/) + expect(::File).to receive(:write).with("/etc/rc.conf.local", /^(?!#{provider.builtin_service_enable_variable_name})$/) expect(provider.is_enabled?).to be true provider.disable_service expect(provider.is_enabled?).to be false @@ -482,7 +482,7 @@ describe Chef::Provider::Service::Openbsd do end context "is disabled" do before do - provider.rc_conf_local = '' + provider.rc_conf_local = "" end it "should not change rc.conf.local since it is already disabled" do expect(::File).not_to receive(:write) @@ -496,10 +496,10 @@ describe Chef::Provider::Service::Openbsd do end context "is enabled" do before do - provider.rc_conf_local = '' + provider.rc_conf_local = "" end it "should disable the service by adding a line to rc.conf.local" do - expect(::File).to receive(:write).with('/etc/rc.conf.local', include("#{provider.builtin_service_enable_variable_name}=\"NO\"")) + expect(::File).to receive(:write).with("/etc/rc.conf.local", include("#{provider.builtin_service_enable_variable_name}=\"NO\"")) expect(provider.is_enabled?).to be true provider.disable_service expect(provider.is_enabled?).to be false @@ -517,14 +517,14 @@ describe Chef::Provider::Service::Openbsd do end context "is not builtin" do before do - provider.rc_conf = '' + provider.rc_conf = "" end context "is enabled" do before do provider.rc_conf_local = "pkg_scripts=\"#{new_resource.service_name}\"\n" end it "should disable the service by removing it from the pkg_scripts list" do - expect(::File).to receive(:write).with('/etc/rc.conf.local', /^(?!#{new_resource.service_name})$/) + expect(::File).to receive(:write).with("/etc/rc.conf.local", /^(?!#{new_resource.service_name})$/) expect(provider.is_enabled?).to be true provider.disable_service expect(provider.is_enabled?).to be false @@ -532,7 +532,7 @@ describe Chef::Provider::Service::Openbsd do end context "is disabled" do before do - provider.rc_conf_local = '' + provider.rc_conf_local = "" end it "should not change rc.conf.local since it is already disabled" do expect(::File).not_to receive(:write) diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index 5aaf54d9f5..d79e179898 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_spec.rb @@ -17,7 +17,7 @@ # require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "spec_helper")) -require 'ostruct' +require "ostruct" shared_examples_for "define_resource_requirements_common" do it "should raise an error if /sbin/chkconfig does not exist" do @@ -44,7 +44,7 @@ describe "Chef::Provider::Service::Redhat" do before(:each) do @node = Chef::Node.new - @node.automatic_attrs[:command] = {:ps => 'foo'} + @node.automatic_attrs[:command] = {:ps => "foo"} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb index 895c559dff..ef5fe55a49 100644 --- a/spec/unit/provider/service/simple_service_spec.rb +++ b/spec/unit/provider/service/simple_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Simple, "load_current_resource" do before(:each) do diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index 4ff3e89ae3..a5f54f0830 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Solaris do before(:each) do @@ -24,69 +24,69 @@ describe Chef::Provider::Service::Solaris do @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::Service.new('chef') + @new_resource = Chef::Resource::Service.new("chef") - @current_resource = Chef::Resource::Service.new('chef') + @current_resource = Chef::Resource::Service.new("chef") @provider = Chef::Provider::Service::Solaris.new(@new_resource, @run_context) allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) # enabled / started service (svcs -l chef) enabled_svc_stdout = [ - 'fmri svc:/application/chef:default', - 'name chef service', - 'enabled true', - 'state online', - 'next_state none', - 'state_time April 2, 2015 04:25:19 PM EDT', - 'logfile /var/svc/log/application-chef:default.log', - 'restarter svc:/system/svc/restarter:default', - 'contract_id 1115271', - 'dependency require_all/error svc:/milestone/multi-user:default (online)', + "fmri svc:/application/chef:default", + "name chef service", + "enabled true", + "state online", + "next_state none", + "state_time April 2, 2015 04:25:19 PM EDT", + "logfile /var/svc/log/application-chef:default.log", + "restarter svc:/system/svc/restarter:default", + "contract_id 1115271", + "dependency require_all/error svc:/milestone/multi-user:default (online)", ].join("\n") # disabled / stopped service (svcs -l chef) disabled_svc_stdout = [ - 'fmri svc:/application/chef:default', - 'name chef service', - 'enabled false', - 'state disabled', - 'next_state none', - 'state_time April 2, 2015 04:25:19 PM EDT', - 'logfile /var/svc/log/application-chef:default.log', - 'restarter svc:/system/svc/restarter:default', - 'contract_id 1115271', - 'dependency require_all/error svc:/milestone/multi-user:default (online)', + "fmri svc:/application/chef:default", + "name chef service", + "enabled false", + "state disabled", + "next_state none", + "state_time April 2, 2015 04:25:19 PM EDT", + "logfile /var/svc/log/application-chef:default.log", + "restarter svc:/system/svc/restarter:default", + "contract_id 1115271", + "dependency require_all/error svc:/milestone/multi-user:default (online)", ].join("\n") # disabled / stopped service (svcs -l chef) maintenance_svc_stdout = [ - 'fmri svc:/application/chef:default', - 'name chef service', - 'enabled true', - 'state maintenance', - 'next_state none', - 'state_time April 2, 2015 04:25:19 PM EDT', - 'logfile /var/svc/log/application-chef:default.log', - 'restarter svc:/system/svc/restarter:default', - 'contract_id 1115271', - 'dependency require_all/error svc:/milestone/multi-user:default (online)', + "fmri svc:/application/chef:default", + "name chef service", + "enabled true", + "state maintenance", + "next_state none", + "state_time April 2, 2015 04:25:19 PM EDT", + "logfile /var/svc/log/application-chef:default.log", + "restarter svc:/system/svc/restarter:default", + "contract_id 1115271", + "dependency require_all/error svc:/milestone/multi-user:default (online)", ].join("\n") # shell_out! return value for a service that is running - @enabled_svc_status = double("Status", :exitstatus => 0, :stdout => enabled_svc_stdout, :stdin => '', :stderr => '') + @enabled_svc_status = double("Status", :exitstatus => 0, :stdout => enabled_svc_stdout, :stdin => "", :stderr => "") # shell_out! return value for a service that is disabled - @disabled_svc_status = double("Status", :exitstatus => 0, :stdout => disabled_svc_stdout, :stdin => '', :stderr => '') + @disabled_svc_status = double("Status", :exitstatus => 0, :stdout => disabled_svc_stdout, :stdin => "", :stderr => "") # shell_out! return value for a service that is in maintenance mode - @maintenance_svc_status = double("Status", :exitstatus => 0, :stdout => maintenance_svc_stdout, :stdin => '', :stderr => '') + @maintenance_svc_status = double("Status", :exitstatus => 0, :stdout => maintenance_svc_stdout, :stdin => "", :stderr => "") # shell_out! return value for a service that does not exist - @no_svc_status = double("Status", :exitstatus => 1, :stdout => '', :stdin => '', :stderr => "svcs: Pattern 'chef' doesn't match any instances\n") + @no_svc_status = double("Status", :exitstatus => 1, :stdout => "", :stdin => "", :stderr => "svcs: Pattern 'chef' doesn't match any instances\n") # shell_out! return value for a successful execution - @success = double("clear", :exitstatus => 0, :stdout => '', :stdin => '', :stderr => '') + @success = double("clear", :exitstatus => 0, :stdout => "", :stdin => "", :stderr => "") end it "should raise an error if /bin/svcs and /usr/sbin/svcadm are not executable" do diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb index 90b669a459..3761eb46db 100644 --- a/spec/unit/provider/service/systemd_service_spec.rb +++ b/spec/unit/provider/service/systemd_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Systemd do @@ -33,11 +33,11 @@ describe Chef::Provider::Service::Systemd do let(:provider) { Chef::Provider::Service::Systemd.new(new_resource, run_context) } let(:shell_out_success) do - double('shell_out_with_systems_locale', :exitstatus => 0, :error? => false) + double("shell_out_with_systems_locale", :exitstatus => 0, :error? => false) end let(:shell_out_failure) do - double('shell_out_with_systems_locale', :exitstatus => 1, :error? => true) + double("shell_out_with_systems_locale", :exitstatus => 1, :error? => true) end let(:current_resource) { Chef::Resource::Service.new(service_name) } diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index 6fb1f9fdbf..8a17e04f1a 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -16,18 +16,18 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service::Upstart do let(:shell_out_success) do - double('shell_out_with_systems_locale', :exitstatus => 0, :error? => false) + double("shell_out_with_systems_locale", :exitstatus => 0, :error? => false) end before(:each) do @node =Chef::Node.new - @node.name('upstarter') - @node.automatic_attrs[:platform] = 'ubuntu' - @node.automatic_attrs[:platform_version] = '9.10' + @node.name("upstarter") + @node.automatic_attrs[:platform] = "ubuntu" + @node.automatic_attrs[:platform_version] = "9.10" @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) @@ -42,7 +42,7 @@ describe Chef::Provider::Service::Upstart do end it "should return /etc/event.d as the upstart job directory when running on Ubuntu 9.04" do - @node.automatic_attrs[:platform_version] = '9.04' + @node.automatic_attrs[:platform_version] = "9.04" #Chef::Platform.stub(:find_platform_and_version).and_return([ "ubuntu", "9.04" ]) @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) expect(@provider.instance_variable_get(:@upstart_job_dir)).to eq("/etc/event.d") @@ -50,14 +50,14 @@ describe Chef::Provider::Service::Upstart do end it "should return /etc/init as the upstart job directory when running on Ubuntu 9.10" do - @node.automatic_attrs[:platform_version] = '9.10' + @node.automatic_attrs[:platform_version] = "9.10" @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) expect(@provider.instance_variable_get(:@upstart_job_dir)).to eq("/etc/init") expect(@provider.instance_variable_get(:@upstart_conf_suffix)).to eq(".conf") end it "should return /etc/init as the upstart job directory by default" do - @node.automatic_attrs[:platform_version] = '9000' + @node.automatic_attrs[:platform_version] = "9000" @provider = Chef::Provider::Service::Upstart.new(@new_resource, @run_context) expect(@provider.instance_variable_get(:@upstart_job_dir)).to eq("/etc/init") expect(@provider.instance_variable_get(:@upstart_conf_suffix)).to eq(".conf") @@ -228,7 +228,7 @@ describe Chef::Provider::Service::Upstart do describe "enable and disable service" do before(:each) do - @current_resource = Chef::Resource::Service.new('rsyslog') + @current_resource = Chef::Resource::Service.new("rsyslog") allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) @provider.current_resource = @current_resource allow(Chef::Util::FileEdit).to receive(:new) @@ -256,7 +256,7 @@ describe Chef::Provider::Service::Upstart do describe "start and stop service" do before(:each) do - @current_resource = Chef::Resource::Service.new('rsyslog') + @current_resource = Chef::Resource::Service.new("rsyslog") allow(Chef::Resource::Service).to receive(:new).and_return(@current_resource) @provider.current_resource = @current_resource diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index 34140fdd7b..d478192c78 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'mixlib/shellout' +require "spec_helper" +require "mixlib/shellout" describe Chef::Provider::Service::Windows, "load_current_resource" do include_context "Win32" @@ -51,14 +51,14 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do end after(:each) do - Win32::Service.send(:remove_const, 'AUTO_START') if defined?(Win32::Service::AUTO_START) - Win32::Service.send(:remove_const, 'DEMAND_START') if defined?(Win32::Service::DEMAND_START) - Win32::Service.send(:remove_const, 'DISABLED') if defined?(Win32::Service::DISABLED) + Win32::Service.send(:remove_const, "AUTO_START") if defined?(Win32::Service::AUTO_START) + Win32::Service.send(:remove_const, "DEMAND_START") if defined?(Win32::Service::DEMAND_START) + Win32::Service.send(:remove_const, "DISABLED") if defined?(Win32::Service::DISABLED) end it "sets the current resources service name to the new resources service name" do provider.load_current_resource - expect(provider.current_resource.service_name).to eq('chef') + expect(provider.current_resource.service_name).to eq("chef") end it "returns the current resource" do diff --git a/spec/unit/provider/service_spec.rb b/spec/unit/provider/service_spec.rb index 17bade55b6..38ac37d294 100644 --- a/spec/unit/provider/service_spec.rb +++ b/spec/unit/provider/service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Service do before do diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb index 9d4a8bd218..ff04a63b93 100644 --- a/spec/unit/provider/subversion_spec.rb +++ b/spec/unit/provider/subversion_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Subversion do @@ -36,7 +36,7 @@ describe Chef::Provider::Subversion do it "converts resource attributes to options for run_command and popen4" do expect(@provider.run_options).to eq({}) - @resource.user 'deployninja' + @resource.user "deployninja" expect(@provider.run_options).to eq({:user => "deployninja"}) end @@ -64,7 +64,7 @@ describe Chef::Provider::Subversion do "Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision "Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n" expect(::File).to receive(:exist?).at_least(1).times.with("/my/deploy/dir/.svn").and_return(true) - expected_command = ["svn info", {:cwd => '/my/deploy/dir', :returns => [0,1]}] + expected_command = ["svn info", {:cwd => "/my/deploy/dir", :returns => [0,1]}] expect(@provider).to receive(:shell_out!).with(*expected_command). and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) expect(@provider.find_current_revision).to eql("11410") @@ -73,7 +73,7 @@ describe Chef::Provider::Subversion do it "gives nil as the current revision if the deploy dir isn't a SVN working copy" do example_svn_info = "svn: '/tmp/deploydir' is not a working copy\n" expect(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(true) - expected_command = ["svn info", {:cwd => '/my/deploy/dir', :returns => [0,1]}] + expected_command = ["svn info", {:cwd => "/my/deploy/dir", :returns => [0,1]}] expect(@provider).to receive(:shell_out!).with(*expected_command). and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) expect(@provider.find_current_revision).to be_nil @@ -119,7 +119,7 @@ describe Chef::Provider::Subversion do "Last Changed Rev: 11410\n" + # Last Changed Rev is preferred to Revision "Last Changed Date: 2009-03-25 06:09:56 -0600 (Wed, 25 Mar 2009)\n\n" @resource.revision "HEAD" - expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd => '/my/deploy/dir', :returns => [0,1]}] + expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd => "/my/deploy/dir", :returns => [0,1]}] expect(@provider).to receive(:shell_out!).with(*expected_command). and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) expect(@provider.revision_int).to eql("11410") @@ -128,7 +128,7 @@ describe Chef::Provider::Subversion do it "returns a helpful message if data from `svn info` can't be parsed" do example_svn_info = "some random text from an error message\n" @resource.revision "HEAD" - expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd => '/my/deploy/dir', :returns => [0,1]}] + expected_command = ["svn info http://svn.example.org/trunk/ --no-auth-cache -rHEAD", {:cwd => "/my/deploy/dir", :returns => [0,1]}] expect(@provider).to receive(:shell_out!).with(*expected_command). and_return(double("ShellOut result", :stdout => example_svn_info, :stderr => "")) expect {@provider.revision_int}.to raise_error(RuntimeError, "Could not parse `svn info` data: some random text from an error message\n") @@ -202,7 +202,7 @@ describe Chef::Provider::Subversion do allow(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(false) allow(::File).to receive(:exist?).with("/my/deploy/dir").and_return(true) allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) - allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return(['.','..','foo','bar']) + allow(::Dir).to receive(:entries).with("/my/deploy/dir").and_return([".","..","foo","bar"]) expect(@provider).not_to receive(:checkout_command) @provider.run_action(:checkout) expect(@resource).not_to be_updated @@ -246,7 +246,7 @@ describe Chef::Provider::Subversion do it "does not fetch any updates if the remote revision matches the current revision" do allow(::File).to receive(:directory?).with("/my/deploy").and_return(true) expect(::File).to receive(:exist?).with("/my/deploy/dir/.svn").and_return(true) - allow(@provider).to receive(:find_current_revision).and_return('12345') + allow(@provider).to receive(:find_current_revision).and_return("12345") allow(@provider).to receive(:current_revision_matches_target_revision?).and_return(true) @provider.run_action(:sync) expect(@resource).not_to be_updated @@ -267,29 +267,29 @@ describe Chef::Provider::Subversion do it "selects 'svn' as the binary by default" do @resource.svn_binary nil allow(ChefConfig).to receive(:windows?) { false } - expect(@provider).to receive(:svn_binary).and_return('svn') + expect(@provider).to receive(:svn_binary).and_return("svn") expect(@provider.export_command).to eql( - 'svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir') + "svn export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir") end it "selects an svn binary with an exe extension on windows" do @resource.svn_binary nil allow(ChefConfig).to receive(:windows?) { true } - expect(@provider).to receive(:svn_binary).and_return('svn.exe') + expect(@provider).to receive(:svn_binary).and_return("svn.exe") expect(@provider.export_command).to eql( - 'svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir') + "svn.exe export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir") end it "uses a custom svn binary as part of the svn command" do - @resource.svn_binary 'teapot' - expect(@provider).to receive(:svn_binary).and_return('teapot') + @resource.svn_binary "teapot" + expect(@provider).to receive(:svn_binary).and_return("teapot") expect(@provider.export_command).to eql( - 'teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir') + "teapot export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir") end it "wraps custom svn binary with quotes if it contains whitespace" do - @resource.svn_binary 'c:/program files (x86)/subversion/svn.exe' - expect(@provider).to receive(:svn_binary).and_return('c:/program files (x86)/subversion/svn.exe') + @resource.svn_binary "c:/program files (x86)/subversion/svn.exe" + expect(@provider).to receive(:svn_binary).and_return("c:/program files (x86)/subversion/svn.exe") expect(@provider.export_command).to eql( '"c:/program files (x86)/subversion/svn.exe" export --force -q -r12345 http://svn.example.org/trunk/ /my/deploy/dir') end diff --git a/spec/unit/provider/template/content_spec.rb b/spec/unit/provider/template/content_spec.rb index 509c8cf33b..7a19f59de1 100644 --- a/spec/unit/provider/template/content_spec.rb +++ b/spec/unit/provider/template/content_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::Template::Content do @@ -30,13 +30,13 @@ describe Chef::Provider::Template::Content do let(:new_resource) do double("Chef::Resource::Template (new)", - :cookbook_name => 'openldap', - :recipe_name => 'default', + :cookbook_name => "openldap", + :recipe_name => "default", :source_line => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb:2:in `from_file'", :source_line_file => "/Users/lamont/solo/cookbooks/openldap/recipes/default.rb", :source_line_number => "2", - :source => 'openldap_stuff.conf.erb', - :name => 'openldap_stuff.conf', + :source => "openldap_stuff.conf.erb", + :name => "openldap_stuff.conf", :path => resource_path, :local => false, :cookbook => nil, @@ -47,8 +47,8 @@ describe Chef::Provider::Template::Content do end let(:rendered_file_locations) { - [Dir.tmpdir + '/openldap_stuff.conf', - enclosing_directory + '/openldap_stuff.conf'] + [Dir.tmpdir + "/openldap_stuff.conf", + enclosing_directory + "/openldap_stuff.conf"] } let(:run_context) do @@ -73,20 +73,20 @@ describe Chef::Provider::Template::Content do end it "finds the template file in the cookbook cache if it isn't local" do - expect(content.template_location).to eq(CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/openldap_stuff.conf.erb') + expect(content.template_location).to eq(CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/openldap_stuff.conf.erb") end it "finds the template file locally if it is local" do allow(new_resource).to receive(:local).and_return(true) - allow(new_resource).to receive(:source).and_return('/tmp/its_on_disk.erb') - expect(content.template_location).to eq('/tmp/its_on_disk.erb') + allow(new_resource).to receive(:source).and_return("/tmp/its_on_disk.erb") + expect(content.template_location).to eq("/tmp/its_on_disk.erb") end it "should use the cookbook name if defined in the template resource" do - allow(new_resource).to receive(:cookbook_name).and_return('apache2') - allow(new_resource).to receive(:cookbook).and_return('openldap') + allow(new_resource).to receive(:cookbook_name).and_return("apache2") + allow(new_resource).to receive(:cookbook).and_return("openldap") allow(new_resource).to receive(:source).and_return("test.erb") - expect(content.template_location).to eq(CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/test.erb') + expect(content.template_location).to eq(CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/test.erb") end it "returns a tempfile in the tempdir when :file_staging_uses_destdir is not set" do @@ -130,14 +130,14 @@ describe Chef::Provider::Template::Content do describe "when using location helpers" do let(:new_resource) do double("Chef::Resource::Template (new)", - :cookbook_name => 'openldap', - :recipe_name => 'default', + :cookbook_name => "openldap", + :recipe_name => "default", :source_line => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb:2:in `from_file'", :source_line_file => CHEF_SPEC_DATA + "/cookbooks/openldap/recipes/default.rb", :source_line_number => "2", - :source => 'helpers.erb', - :name => 'helpers.erb', - :path => CHEF_SPEC_DATA + '/cookbooks/openldap/templates/default/helpers.erb', + :source => "helpers.erb", + :name => "helpers.erb", + :path => CHEF_SPEC_DATA + "/cookbooks/openldap/templates/default/helpers.erb", :local => false, :cookbook => nil, :variables => {}, diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb index 713303d818..5340cc8d12 100644 --- a/spec/unit/provider/template_spec.rb +++ b/spec/unit/provider/template_spec.rb @@ -17,17 +17,17 @@ # limitations under the License. # -require 'stringio' -require 'spec_helper' -require 'etc' -require 'ostruct' -require 'support/shared/unit/provider/file' +require "stringio" +require "spec_helper" +require "etc" +require "ostruct" +require "support/shared/unit/provider/file" describe Chef::Provider::Template do - let(:node) { double('Chef::Node') } - let(:events) { double('Chef::Events').as_null_object } # mock all the methods - let(:run_context) { double('Chef::RunContext', :node => node, :events => events) } + let(:node) { double("Chef::Node") } + let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) } @@ -50,7 +50,7 @@ describe Chef::Provider::Template do end let(:content) do - content = double('Chef::Provider::File::Content::Template', :template_location => "/foo/bar/baz") + content = double("Chef::Provider::File::Content::Template", :template_location => "/foo/bar/baz") allow(File).to receive(:exists?).with("/foo/bar/baz").and_return(true) content end @@ -59,9 +59,9 @@ describe Chef::Provider::Template do context "when creating the template" do - let(:node) { double('Chef::Node') } - let(:events) { double('Chef::Events').as_null_object } # mock all the methods - let(:run_context) { double('Chef::RunContext', :node => node, :events => events) } + let(:node) { double("Chef::Node") } + let(:events) { double("Chef::Events").as_null_object } # mock all the methods + let(:run_context) { double("Chef::RunContext", :node => node, :events => events) } let(:enclosing_directory) { canonicalize_path(File.expand_path(File.join(CHEF_SPEC_DATA, "templates"))) } diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb index a9407a4d7e..8195bdfc25 100644 --- a/spec/unit/provider/user/dscl_spec.rb +++ b/spec/unit/provider/user/dscl_spec.rb @@ -18,9 +18,9 @@ ShellCmdResult = Struct.new(:stdout, :stderr, :exitstatus) -require 'spec_helper' -require 'ostruct' -require 'mixlib/shellout' +require "spec_helper" +require "ostruct" +require "mixlib/shellout" describe Chef::Provider::User::Dscl do before do @@ -114,32 +114,32 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" describe "when shelling out to dscl" do it "should run dscl with the supplied cmd /Path args" do - shell_return = ShellCmdResult.new('stdout', 'err', 0) + shell_return = ShellCmdResult.new("stdout", "err", 0) expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return) - expect(provider.run_dscl("cmd /Path args")).to eq('stdout') + expect(provider.run_dscl("cmd /Path args")).to eq("stdout") end it "returns an empty string from delete commands" do - shell_return = ShellCmdResult.new('out', 'err', 23) + shell_return = ShellCmdResult.new("out", "err", 23) expect(provider).to receive(:shell_out).with("dscl . -delete /Path args").and_return(shell_return) expect(provider.run_dscl("delete /Path args")).to eq("") end it "should raise an exception for any other command" do - shell_return = ShellCmdResult.new('out', 'err', 23) - expect(provider).to receive(:shell_out).with('dscl . -cmd /Path arguments').and_return(shell_return) + shell_return = ShellCmdResult.new("out", "err", 23) + expect(provider).to receive(:shell_out).with("dscl . -cmd /Path arguments").and_return(shell_return) expect { provider.run_dscl("cmd /Path arguments") }.to raise_error(Chef::Exceptions::DsclCommandFailed) end it "raises an exception when dscl reports 'no such key'" do - shell_return = ShellCmdResult.new("No such key: ", 'err', 23) - expect(provider).to receive(:shell_out).with('dscl . -cmd /Path args').and_return(shell_return) + shell_return = ShellCmdResult.new("No such key: ", "err", 23) + expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return) expect { provider.run_dscl("cmd /Path args") }.to raise_error(Chef::Exceptions::DsclCommandFailed) end it "raises an exception when dscl reports 'eDSRecordNotFound'" do - shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", 'err', -14136) - expect(provider).to receive(:shell_out).with('dscl . -cmd /Path args').and_return(shell_return) + shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136) + expect(provider).to receive(:shell_out).with("dscl . -cmd /Path args").and_return(shell_return) expect { provider.run_dscl("cmd /Path args") }.to raise_error(Chef::Exceptions::DsclCommandFailed) end end @@ -197,7 +197,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" end it "finds a valid, unused uid when none is specified" do - expect(provider).to receive(:run_dscl).with("list /Users uid").and_return('') + expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("") expect(provider).to receive(:run_dscl).with("create /Users/toor UniqueID 501") expect(provider).to receive(:get_free_uid).and_return(501) provider.dscl_set_uid @@ -207,7 +207,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" it "sets the uid specified in the resource" do new_resource.uid(1000) expect(provider).to receive(:run_dscl).with("create /Users/toor UniqueID 1000").and_return(true) - expect(provider).to receive(:run_dscl).with("list /Users uid").and_return('') + expect(provider).to receive(:run_dscl).with("list /Users uid").and_return("") provider.dscl_set_uid end end @@ -219,7 +219,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" before do new_resource.supports({ :manage_home => true }) - new_resource.home('/Users/toor') + new_resource.home("/Users/toor") provider.current_resource = current_resource end @@ -232,25 +232,25 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" it "raises InvalidHomeDirectory when the resource's home directory doesn't look right" do - new_resource.home('epic-fail') + new_resource.home("epic-fail") expect { provider.dscl_set_home }.to raise_error(Chef::Exceptions::InvalidHomeDirectory) end it "moves the users home to the new location if it exists and the target location is different" do new_resource.supports(:manage_home => true) - current_home = CHEF_SPEC_DATA + '/old_home_dir' - current_home_files = [current_home + '/my-dot-emacs', current_home + '/my-dot-vim'] + current_home = CHEF_SPEC_DATA + "/old_home_dir" + current_home_files = [current_home + "/my-dot-emacs", current_home + "/my-dot-vim"] current_resource.home(current_home) new_resource.gid(23) - allow(::File).to receive(:exists?).with('/old/home/toor').and_return(true) - allow(::File).to receive(:exists?).with('/Users/toor').and_return(true) + allow(::File).to receive(:exists?).with("/old/home/toor").and_return(true) + allow(::File).to receive(:exists?).with("/Users/toor").and_return(true) - expect(FileUtils).to receive(:mkdir_p).with('/Users/toor').and_return(true) + expect(FileUtils).to receive(:mkdir_p).with("/Users/toor").and_return(true) expect(FileUtils).to receive(:rmdir).with(current_home) expect(::Dir).to receive(:glob).with("#{CHEF_SPEC_DATA}/old_home_dir/*",::File::FNM_DOTMATCH).and_return(current_home_files) expect(FileUtils).to receive(:mv).with(current_home_files, "/Users/toor", :force => true) - expect(FileUtils).to receive(:chown_R).with('toor','23','/Users/toor') + expect(FileUtils).to receive(:chown_R).with("toor","23","/Users/toor") expect(provider).to receive(:run_dscl).with("create /Users/toor NFSHomeDirectory '/Users/toor'") provider.dscl_set_home @@ -263,7 +263,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" it "should run ditto to copy any missing files from skel to the new home dir" do expect(::File).to receive(:exists?).with("/System/Library/User\ Template/English.lproj").and_return(true) - expect(FileUtils).to receive(:chown_R).with('toor', '', '/Users/toor') + expect(FileUtils).to receive(:chown_R).with("toor", "", "/Users/toor") expect(provider).to receive(:shell_out!).with("ditto '/System/Library/User Template/English.lproj' '/Users/toor'") provider.ditto_home end @@ -382,7 +382,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30" expect(provider).to receive(:shell_out).with("dscacheutil '-flushcache'") expect(provider).to receive(:shell_out).with("plutil -convert xml1 -o - /var/db/dslocal/nodes/Default/users/toor.plist") do if user_plist_file.nil? - ShellCmdResult.new('Can not find the file', 'Sorry!!', 1) + ShellCmdResult.new("Can not find the file", "Sorry!!", 1) else ShellCmdResult.new(File.read(File.join(CHEF_SPEC_DATA, "mac_users/#{user_plist_file}.plist.xml")), "", 0) end @@ -656,7 +656,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30") it "password_shadow_info should have salted-sha-512 format" do shadow_info = provider.prepare_password_shadow_info expect(shadow_info).to have_key("SALTED-SHA512") - info = shadow_info["SALTED-SHA512"].string.unpack('H*').first + info = shadow_info["SALTED-SHA512"].string.unpack("H*").first expect(provider.salted_sha512?(info)).to be_truthy end end @@ -667,7 +667,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30") it "password_shadow_info should have salted-sha-512 format" do shadow_info = provider.prepare_password_shadow_info expect(shadow_info).to have_key("SALTED-SHA512") - info = shadow_info["SALTED-SHA512"].string.unpack('H*').first + info = shadow_info["SALTED-SHA512"].string.unpack("H*").first expect(provider.salted_sha512?(info)).to be_truthy expect(info).to eq(vagrant_sha_512) end @@ -689,7 +689,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30") expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("entropy") expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("salt") expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("iterations") - info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack('H*').first + info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack("H*").first expect(provider.salted_sha512_pbkdf2?(info)).to be_truthy end end @@ -705,7 +705,7 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30") expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("entropy") expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("salt") expect(shadow_info["SALTED-SHA512-PBKDF2"]).to have_key("iterations") - info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack('H*').first + info = shadow_info["SALTED-SHA512-PBKDF2"]["entropy"].string.unpack("H*").first expect(provider.salted_sha512_pbkdf2?(info)).to be_truthy expect(info).to eq(vagrant_sha_512_pbkdf2) end @@ -791,8 +791,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30") end it "should raise an exception when the group does not exist" do - shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", 'err', -14136) - expect(provider).to receive(:shell_out).with('dscl . -read /Groups/newgroup PrimaryGroupID').and_return(shell_return) + shell_return = ShellCmdResult.new("<dscl_cmd> DS Error: -14136 (eDSRecordNotFound)", "err", -14136) + expect(provider).to receive(:shell_out).with("dscl . -read /Groups/newgroup PrimaryGroupID").and_return(shell_return) expect { provider.dscl_set_gid }.to raise_error(Chef::Exceptions::GroupIDNotFound) end end @@ -814,8 +814,8 @@ ea18e18b720e358e7fbe3cfbeaa561456f6ba008937a30") new_resource.username "mud" new_resource.uid 2342 new_resource.gid 2342 - new_resource.home '/Users/death' - new_resource.password 'goaway' + new_resource.home "/Users/death" + new_resource.password "goaway" end it "sets the user, comment field, uid, gid, moves the home directory, sets the shell, and sets the password" do diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb index 6683a75f42..4b58fdc58e 100644 --- a/spec/unit/provider/user/pw_spec.rb +++ b/spec/unit/provider/user/pw_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::User::Pw do before(:each) do @@ -48,11 +48,11 @@ describe Chef::Provider::User::Pw do describe "setting options to the pw command" do field_list = { - 'comment' => "-c", - 'home' => "-d", - 'gid' => "-g", - 'uid' => "-u", - 'shell' => "-s", + "comment" => "-c", + "home" => "-d", + "gid" => "-g", + "uid" => "-u", + "shell" => "-s", } field_list.each do |attribute, option| it "should check for differences in #{attribute} between the new and current resources" do diff --git a/spec/unit/provider/user/solaris_spec.rb b/spec/unit/provider/user/solaris_spec.rb index a3c17a9a56..f3299aaf63 100644 --- a/spec/unit/provider/user/solaris_spec.rb +++ b/spec/unit/provider/user/solaris_spec.rb @@ -22,8 +22,8 @@ ShellCmdResult = Struct.new(:stdout, :stderr, :exitstatus) -require 'mixlib/shellout' -require 'spec_helper' +require "mixlib/shellout" +require "spec_helper" describe Chef::Provider::User::Solaris do @@ -73,63 +73,63 @@ describe Chef::Provider::User::Solaris do end end - describe 'when managing user locked status' do + describe "when managing user locked status" do before(:each) do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::User.new('dave') + @new_resource = Chef::Resource::User.new("dave") @current_resource = @new_resource.dup @provider = Chef::Provider::User::Solaris.new(@new_resource, @run_context) @provider.current_resource = @current_resource end - describe 'when determining if the user is locked' do + describe "when determining if the user is locked" do # locked shadow lines [ - 'dave:LK:::::::', - 'dave:*LK*:::::::', - 'dave:*LK*foobar:::::::', - 'dave:*LK*bahamas10:::::::', - 'dave:*LK*L....:::::::', + "dave:LK:::::::", + "dave:*LK*:::::::", + "dave:*LK*foobar:::::::", + "dave:*LK*bahamas10:::::::", + "dave:*LK*L....:::::::", ].each do |shadow| it "should return true if user is locked with #{shadow}" do - shell_return = ShellCmdResult.new(shadow + "\n", '', 0) - expect(provider).to receive(:shell_out!).with('getent', 'shadow', @new_resource.username).and_return(shell_return) + shell_return = ShellCmdResult.new(shadow + "\n", "", 0) + expect(provider).to receive(:shell_out!).with("getent", "shadow", @new_resource.username).and_return(shell_return) expect(provider.check_lock).to eql(true) end end # unlocked shadow lines [ - 'dave:NP:::::::', - 'dave:*NP*:::::::', - 'dave:foobar:::::::', - 'dave:bahamas10:::::::', - 'dave:L...:::::::', + "dave:NP:::::::", + "dave:*NP*:::::::", + "dave:foobar:::::::", + "dave:bahamas10:::::::", + "dave:L...:::::::", ].each do |shadow| it "should return false if user is unlocked with #{shadow}" do - shell_return = ShellCmdResult.new(shadow + "\n", '', 0) - expect(provider).to receive(:shell_out!).with('getent', 'shadow', @new_resource.username).and_return(shell_return) + shell_return = ShellCmdResult.new(shadow + "\n", "", 0) + expect(provider).to receive(:shell_out!).with("getent", "shadow", @new_resource.username).and_return(shell_return) expect(provider.check_lock).to eql(false) end end end - describe 'when locking the user' do - it 'should run passwd -l with the new resources username' do - shell_return = ShellCmdResult.new('', '', 0) - expect(provider).to receive(:shell_out!).with('passwd', '-l', @new_resource.username).and_return(shell_return) + describe "when locking the user" do + it "should run passwd -l with the new resources username" do + shell_return = ShellCmdResult.new("", "", 0) + expect(provider).to receive(:shell_out!).with("passwd", "-l", @new_resource.username).and_return(shell_return) provider.lock_user end end - describe 'when unlocking the user' do - it 'should run passwd -u with the new resources username' do - shell_return = ShellCmdResult.new('', '', 0) - expect(provider).to receive(:shell_out!).with('passwd', '-u', @new_resource.username).and_return(shell_return) + describe "when unlocking the user" do + it "should run passwd -u with the new resources username" do + shell_return = ShellCmdResult.new("", "", 0) + expect(provider).to receive(:shell_out!).with("passwd", "-u", @new_resource.username).and_return(shell_return) provider.unlock_user end end diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb index a295dff679..f8bcb13363 100644 --- a/spec/unit/provider/user/useradd_spec.rb +++ b/spec/unit/provider/user/useradd_spec.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/provider/user/useradd' +require "spec_helper" +require "chef/provider/user/useradd" describe Chef::Provider::User::Useradd do @@ -30,11 +30,11 @@ describe Chef::Provider::User::Useradd do end supported_useradd_options = { - 'comment' => "-c", - 'gid' => "-g", - 'uid' => "-u", - 'shell' => "-s", - 'password' => "-p", + "comment" => "-c", + "gid" => "-g", + "uid" => "-u", + "shell" => "-s", + "password" => "-p", } include_examples "a useradd-based user provider", supported_useradd_options diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb index 7e08f971a9..7a8cb29963 100644 --- a/spec/unit/provider/user/windows_spec.rb +++ b/spec/unit/provider/user/windows_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class Chef class Util @@ -104,7 +104,7 @@ describe Chef::Provider::User::Windows do end it "marks the home_dir attribute to be updated" do - expect(@provider.set_options[:home_dir]).to eq('/home/adam') + expect(@provider.set_options[:home_dir]).to eq("/home/adam") end it "ignores the primary_group_id attribute" do @@ -116,11 +116,11 @@ describe Chef::Provider::User::Windows do end it "marks the script_path attribute to be updated" do - expect(@provider.set_options[:script_path]).to eq('/usr/bin/zsh') + expect(@provider.set_options[:script_path]).to eq("/usr/bin/zsh") end it "marks the password attribute to be updated" do - expect(@provider.set_options[:password]).to eq('abracadabra') + expect(@provider.set_options[:password]).to eq("abracadabra") end end end diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb index c38abcc049..043a67df1b 100644 --- a/spec/unit/provider/user_spec.rb +++ b/spec/unit/provider/user_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" EtcPwnamIsh = Struct.new(:name, :passwd, :uid, :gid, :gecos, :dir, :shell, :change, :uclass, :expire) EtcGrnamIsh = Struct.new(:name, :passwd, :gid, :mem) @@ -83,7 +83,7 @@ describe Chef::Provider::User do it "should create a current resource with the same name as the new resource" do @provider.load_current_resource - expect(@provider.current_resource.name).to eq('adam') + expect(@provider.current_resource.name).to eq("adam") end it "should set the username of the current resource to the username of the new resource" do @@ -92,7 +92,7 @@ describe Chef::Provider::User do end it "should change the encoding of gecos to the encoding of the new resource" do - @pw_user.gecos.force_encoding('ASCII-8BIT') + @pw_user.gecos.force_encoding("ASCII-8BIT") @provider.load_current_resource expect(@provider.current_resource.comment.encoding).to eq(@new_resource.comment.encoding) end @@ -141,8 +141,8 @@ describe Chef::Provider::User do describe "and running assertions" do def self.shadow_lib_unavail? begin - require 'rubygems' - require 'shadow' + require "rubygems" + require "shadow" rescue LoadError skip "ruby-shadow gem not installed for dynamic load test" true @@ -165,7 +165,7 @@ describe Chef::Provider::User do context "and we are root", :requires_root => true do it "should pass assertions when ruby-shadow can be loaded" do - @provider.action = 'create' + @provider.action = "create" original_method = @provider.method(:require) expect(@provider).to receive(:require) { |*args| original_method.call(*args) } passwd_info = Struct::PasswdEntry.new(:sp_namp => "adm ", :sp_pwdp => "$1$T0N0Q.lc$nyG6pFI3Dpqa5cxUz/57j0", :sp_lstchg => 14861, :sp_min => 0, :sp_max => 99999, @@ -192,13 +192,13 @@ describe Chef::Provider::User do describe "compare_user" do let(:mapping) { { - 'username' => ["adam", "Adam"], - 'comment' => ["Adam Jacob", "adam jacob"], - 'uid' => [1000, 1001], - 'gid' => [1000, 1001], - 'home' => ["/home/adam", "/Users/adam"], - 'shell'=> ["/usr/bin/zsh", "/bin/bash"], - 'password'=> ["abcd","12345"], + "username" => ["adam", "Adam"], + "comment" => ["Adam Jacob", "adam jacob"], + "uid" => [1000, 1001], + "gid" => [1000, 1001], + "home" => ["/home/adam", "/Users/adam"], + "shell"=> ["/usr/bin/zsh", "/bin/bash"], + "password"=> ["abcd","12345"], } } @@ -441,8 +441,8 @@ describe Chef::Provider::User do describe "convert_group_name" do before do - @new_resource.gid('999') - @group = EtcGrnamIsh.new('wheel', '*', 999, []) + @new_resource.gid("999") + @group = EtcGrnamIsh.new("wheel", "*", 999, []) end it "should lookup the group name locally" do diff --git a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb index 2a4dccdad7..6f8949bba3 100644 --- a/spec/unit/provider/whyrun_safe_ruby_block_spec.rb +++ b/spec/unit/provider/whyrun_safe_ruby_block_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Provider::WhyrunSafeRubyBlock, "initialize" do before(:each) do diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb index cee097e715..16befad5ca 100644 --- a/spec/unit/provider_resolver_spec.rb +++ b/spec/unit/provider_resolver_spec.rb @@ -16,13 +16,13 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/mixin/convert_to_class_name' -require 'chef/provider_resolver' -require 'chef/platform/service_helpers' -require 'support/shared/integration/integration_helper' -require 'tmpdir' -require 'fileutils' +require "spec_helper" +require "chef/mixin/convert_to_class_name" +require "chef/provider_resolver" +require "chef/platform/service_helpers" +require "support/shared/integration/integration_helper" +require "tmpdir" +require "fileutils" include Chef::Mixin::ConvertToClassName @@ -48,7 +48,7 @@ describe Chef::ProviderResolver do node.automatic[:platform_family] = platform_family node.automatic[:platform] = platform node.automatic[:platform_version] = platform_version - node.automatic[:kernel] = { machine: 'i386' } + node.automatic[:kernel] = { machine: "i386" } node end let(:run_context) { Chef::RunContext.new(node, nil, nil) } @@ -73,7 +73,7 @@ describe Chef::ProviderResolver do end def self.on_platform(platform, *tags, - platform_version: '11.0.1', + platform_version: "11.0.1", platform_family: nil, os: nil, &block) @@ -147,17 +147,17 @@ describe Chef::ProviderResolver do services.each do |service| case service when :debian - file 'usr/sbin/update-rc.d', '' + file "usr/sbin/update-rc.d", "" when :invokercd - file 'usr/sbin/invoke-rc.d', '' + file "usr/sbin/invoke-rc.d", "" when :insserv - file 'sbin/insserv', '' + file "sbin/insserv", "" when :upstart - file 'sbin/initctl', '' + file "sbin/initctl", "" when :redhat - file 'sbin/chkconfig', '' + file "sbin/chkconfig", "" when :systemd - file 'proc/1/comm', "systemd\n" + file "proc/1/comm", "systemd\n" else raise ArgumentError, service end @@ -178,7 +178,7 @@ describe Chef::ProviderResolver do when :usr_local_etc_rcd file "usr/local/etc/rc.d/#{service_name}", "" when :systemd - file 'proc/1/comm', "systemd\n" + file "proc/1/comm", "systemd\n" file "etc/systemd/system/#{service_name}.service", "" else raise ArgumentError, config @@ -480,7 +480,7 @@ describe Chef::ProviderResolver do end end - on_platform %w(freebsd netbsd), platform_version: '3.1.4' do + on_platform %w(freebsd netbsd), platform_version: "3.1.4" do it "returns a Freebsd provider if it finds the /usr/local/etc/rc.d initscript" do stub_service_providers stub_service_configs(:usr_local_etc_rcd) diff --git a/spec/unit/provider_spec.rb b/spec/unit/provider_spec.rb index 97b88b1732..dae5839d6c 100644 --- a/spec/unit/provider_spec.rb +++ b/spec/unit/provider_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class NoWhyrunDemonstrator < Chef::Provider diff --git a/spec/unit/pure_application_spec.rb b/spec/unit/pure_application_spec.rb index 5d879a7b85..de9650e381 100644 --- a/spec/unit/pure_application_spec.rb +++ b/spec/unit/pure_application_spec.rb @@ -19,7 +19,7 @@ # be able to test only Chef::Application. # Regression test for CHEF-5169 -require 'chef/application' +require "chef/application" describe "Chef::Application" do let(:app) { Chef::Application.new } diff --git a/spec/unit/recipe_spec.rb b/spec/unit/recipe_spec.rb index 34f852e2ce..d247a1bb5e 100644 --- a/spec/unit/recipe_spec.rb +++ b/spec/unit/recipe_spec.rb @@ -19,8 +19,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/platform/resource_priority_map' +require "spec_helper" +require "chef/platform/resource_priority_map" describe Chef::Recipe do diff --git a/spec/unit/resource/apt_package_spec.rb b/spec/unit/resource/apt_package_spec.rb index 3c31f63dd7..cf425519b5 100644 --- a/spec/unit/resource/apt_package_spec.rb +++ b/spec/unit/resource/apt_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::AptPackage, "initialize" do diff --git a/spec/unit/resource/bash_spec.rb b/spec/unit/resource/bash_spec.rb index f313900433..71805a44a2 100644 --- a/spec/unit/resource/bash_spec.rb +++ b/spec/unit/resource/bash_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Bash do diff --git a/spec/unit/resource/batch_spec.rb b/spec/unit/resource/batch_spec.rb index b8c2897f42..965e48d9fa 100644 --- a/spec/unit/resource/batch_spec.rb +++ b/spec/unit/resource/batch_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Batch do @@ -25,7 +25,7 @@ describe Chef::Resource::Batch do node.default["kernel"] = Hash.new node.default["kernel"][:machine] = :x86_64.to_s - node.automatic[:os] = 'windows' + node.automatic[:os] = "windows" run_context = Chef::RunContext.new(node, nil, nil) @@ -41,7 +41,7 @@ describe Chef::Resource::Batch do let(:resource_instance) { @resource } let(:resource_instance_name ) { @resource.command } let(:resource_name) { :batch } - let(:interpreter_file_name) { 'cmd.exe' } + let(:interpreter_file_name) { "cmd.exe" } it_should_behave_like "a Windows script resource" end diff --git a/spec/unit/resource/breakpoint_spec.rb b/spec/unit/resource/breakpoint_spec.rb index 88ab34d568..63a1753a2f 100644 --- a/spec/unit/resource/breakpoint_spec.rb +++ b/spec/unit/resource/breakpoint_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::Breakpoint do diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb index df37779d1b..3e6002e4f2 100644 --- a/spec/unit/resource/chef_gem_spec.rb +++ b/spec/unit/resource/chef_gem_spec.rb @@ -17,8 +17,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::ChefGem, "initialize" do diff --git a/spec/unit/resource/chocolatey_package_spec.rb b/spec/unit/resource/chocolatey_package_spec.rb index 38f1d2905c..b125279909 100644 --- a/spec/unit/resource/chocolatey_package_spec.rb +++ b/spec/unit/resource/chocolatey_package_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::ChocolateyPackage do diff --git a/spec/unit/resource/conditional_action_not_nothing_spec.rb b/spec/unit/resource/conditional_action_not_nothing_spec.rb index d140615cfc..bc22ae7a47 100644 --- a/spec/unit/resource/conditional_action_not_nothing_spec.rb +++ b/spec/unit/resource/conditional_action_not_nothing_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::ConditionalActionNotNothing do diff --git a/spec/unit/resource/conditional_spec.rb b/spec/unit/resource/conditional_spec.rb index 489c1136b1..7d153df24a 100644 --- a/spec/unit/resource/conditional_spec.rb +++ b/spec/unit/resource/conditional_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Resource::Conditional do before do @@ -89,17 +89,17 @@ describe Chef::Resource::Conditional do end end - describe 'after running a command which timed out' do + describe "after running a command which timed out" do before do @conditional = Chef::Resource::Conditional.only_if(@parent_resource, "false") allow_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:shell_out).and_raise(Chef::Exceptions::CommandTimeout) end - it 'indicates that resource convergence should not continue' do + it "indicates that resource convergence should not continue" do expect(@conditional.continue?).to be_falsey end - it 'should log a warning' do + it "should log a warning" do expect(Chef::Log).to receive(:warn).with("Command 'false' timed out") @conditional.continue? end @@ -169,17 +169,17 @@ describe Chef::Resource::Conditional do end end - describe 'after running a command which timed out' do + describe "after running a command which timed out" do before do @conditional = Chef::Resource::Conditional.not_if(@parent_resource, "false") allow_any_instance_of(Chef::GuardInterpreter::DefaultGuardInterpreter).to receive(:shell_out).and_raise(Chef::Exceptions::CommandTimeout) end - it 'indicates that resource convergence should continue' do + it "indicates that resource convergence should continue" do expect(@conditional.continue?).to be_truthy end - it 'should log a warning' do + it "should log a warning" do expect(Chef::Log).to receive(:warn).with("Command 'false' timed out") @conditional.continue? end diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb index bd437893ce..442e175f63 100644 --- a/spec/unit/resource/cookbook_file_spec.rb +++ b/spec/unit/resource/cookbook_file_spec.rb @@ -17,20 +17,20 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::CookbookFile do before do - @cookbook_file = Chef::Resource::CookbookFile.new('sourcecode_tarball.tgz') + @cookbook_file = Chef::Resource::CookbookFile.new("sourcecode_tarball.tgz") end it "uses the name parameter for the source parameter" do - expect(@cookbook_file.name).to eq('sourcecode_tarball.tgz') + expect(@cookbook_file.name).to eq("sourcecode_tarball.tgz") end it "has a source parameter" do - @cookbook_file.name('config_file.conf') - expect(@cookbook_file.name).to eq('config_file.conf') + @cookbook_file.name("config_file.conf") + expect(@cookbook_file.name).to eq("config_file.conf") end it "defaults to a nil cookbook parameter (current cookbook will be used)" do @@ -39,7 +39,7 @@ describe Chef::Resource::CookbookFile do it "has a cookbook parameter" do @cookbook_file.cookbook("munin") - expect(@cookbook_file.cookbook).to eq('munin') + expect(@cookbook_file.cookbook).to eq("munin") end it "sets the provider to Chef::Provider::CookbookFile" do diff --git a/spec/unit/resource/cron_spec.rb b/spec/unit/resource/cron_spec.rb index 0978be6930..1ba48641ed 100644 --- a/spec/unit/resource/cron_spec.rb +++ b/spec/unit/resource/cron_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Cron do diff --git a/spec/unit/resource/csh_spec.rb b/spec/unit/resource/csh_spec.rb index 5fb3b00507..fee96eb75e 100644 --- a/spec/unit/resource/csh_spec.rb +++ b/spec/unit/resource/csh_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Csh do diff --git a/spec/unit/resource/deploy_revision_spec.rb b/spec/unit/resource/deploy_revision_spec.rb index d136aa251e..45df9c3dc2 100644 --- a/spec/unit/resource/deploy_revision_spec.rb +++ b/spec/unit/resource/deploy_revision_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::DeployRevision do diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb index 2338e37173..c53978a127 100644 --- a/spec/unit/resource/deploy_spec.rb +++ b/spec/unit/resource/deploy_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::Deploy do diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb index e9e80806db..a6d353ce06 100644 --- a/spec/unit/resource/directory_spec.rb +++ b/spec/unit/resource/directory_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Directory do diff --git a/spec/unit/resource/dpkg_package_spec.rb b/spec/unit/resource/dpkg_package_spec.rb index 931e6763bd..4c35f0cb41 100644 --- a/spec/unit/resource/dpkg_package_spec.rb +++ b/spec/unit/resource/dpkg_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::DpkgPackage, "initialize" do @@ -26,7 +26,7 @@ describe Chef::Resource::DpkgPackage, "initialize" do provider: Chef::Provider::Package::Dpkg, name: :dpkg_package, action: :install, - os: 'linux', + os: "linux", ) end diff --git a/spec/unit/resource/dsc_resource_spec.rb b/spec/unit/resource/dsc_resource_spec.rb index 276aa74111..4c98442d13 100644 --- a/spec/unit/resource/dsc_resource_spec.rb +++ b/spec/unit/resource/dsc_resource_spec.rb @@ -15,18 +15,18 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::DscResource do - let(:dsc_test_resource_name) { 'DSCTest' } + let(:dsc_test_resource_name) { "DSCTest" } let(:dsc_test_property_name) { :DSCTestProperty } - let(:dsc_test_property_value) { 'DSCTestValue' } + let(:dsc_test_property_value) { "DSCTestValue" } let(:dsc_test_reboot_action) { :reboot_now } let(:dsc_test_timeout) { 101 } - context 'when Powershell supports Dsc' do + context "when Powershell supports Dsc" do let(:dsc_test_run_context) { node = Chef::Node.new - node.automatic[:languages][:powershell][:version] = '5.0.10018.0' + node.automatic[:languages][:powershell][:version] = "5.0.10018.0" empty_events = Chef::EventDispatch::Dispatcher.new Chef::RunContext.new(node, {}, empty_events) } @@ -72,7 +72,7 @@ describe Chef::Resource::DscResource do it "raises a TypeError if property_name is not a symbol" do expect{ - dsc_test_resource.property('Foo', dsc_test_property_value) + dsc_test_resource.property("Foo", dsc_test_property_value) }.to raise_error(TypeError) end @@ -87,7 +87,7 @@ describe Chef::Resource::DscResource do end end - context 'Powershell DSL methods' do + context "Powershell DSL methods" do it "responds to :ps_credential" do expect(dsc_test_resource.respond_to?(:ps_credential)).to be true end diff --git a/spec/unit/resource/dsc_script_spec.rb b/spec/unit/resource/dsc_script_spec.rb index 1fa865a2d5..3afa46dd48 100644 --- a/spec/unit/resource/dsc_script_spec.rb +++ b/spec/unit/resource/dsc_script_spec.rb @@ -16,15 +16,15 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::DscScript do - let(:dsc_test_resource_name) { 'DSCTest' } + let(:dsc_test_resource_name) { "DSCTest" } - context 'when Powershell supports Dsc' do + context "when Powershell supports Dsc" do let(:dsc_test_run_context) { node = Chef::Node.new - node.automatic[:languages][:powershell][:version] = '4.0' + node.automatic[:languages][:powershell][:version] = "4.0" empty_events = Chef::EventDispatch::Dispatcher.new Chef::RunContext.new(node, {}, empty_events) } @@ -32,10 +32,10 @@ describe Chef::Resource::DscScript do Chef::Resource::DscScript.new(dsc_test_resource_name, dsc_test_run_context) } let(:configuration_code) {'echo "This is supposed to create a configuration document."'} - let(:configuration_path) {'c:/myconfigs/formatc.ps1'} - let(:configuration_name) { 'formatme' } + let(:configuration_path) {"c:/myconfigs/formatc.ps1"} + let(:configuration_name) { "formatme" } let(:configuration_data) { '@{AllNodes = @( @{ NodeName = "localhost"; PSDscAllowPlainTextPassword = $true })}' } - let(:configuration_data_script) { 'c:/myconfigs/data/safedata.psd1' } + let(:configuration_data_script) { "c:/myconfigs/data/safedata.psd1" } it "has a default action of `:run`" do expect(dsc_test_resource.action).to eq([:run]) @@ -75,9 +75,9 @@ describe Chef::Resource::DscScript do end context "when calling imports" do - let(:module_name) { 'FooModule' } - let(:module_name_b) { 'BarModule' } - let(:dsc_resources) { ['ResourceA', 'ResourceB'] } + let(:module_name) { "FooModule" } + let(:module_name_b) { "BarModule" } + let(:dsc_resources) { ["ResourceA", "ResourceB"] } it "allows an arbitrary number of resources to be set for a module to be set" do dsc_test_resource.imports module_name, *dsc_resources @@ -88,7 +88,7 @@ describe Chef::Resource::DscScript do it "adds * to the imports when no resources are set for a moudle" do dsc_test_resource.imports module_name module_imports = dsc_test_resource.imports[module_name] - expect(module_imports).to eq(['*']) + expect(module_imports).to eq(["*"]) end it "allows an arbitrary number of modules" do diff --git a/spec/unit/resource/easy_install_package_spec.rb b/spec/unit/resource/easy_install_package_spec.rb index c68b026b39..52e0e91994 100644 --- a/spec/unit/resource/easy_install_package_spec.rb +++ b/spec/unit/resource/easy_install_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::EasyInstallPackage, "initialize" do diff --git a/spec/unit/resource/env_spec.rb b/spec/unit/resource/env_spec.rb index 60e85ac31e..8a10ca7e81 100644 --- a/spec/unit/resource/env_spec.rb +++ b/spec/unit/resource/env_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Env do diff --git a/spec/unit/resource/erl_call_spec.rb b/spec/unit/resource/erl_call_spec.rb index 9abf2e7812..7cdb5bda16 100644 --- a/spec/unit/resource/erl_call_spec.rb +++ b/spec/unit/resource/erl_call_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::ErlCall do diff --git a/spec/unit/resource/execute_spec.rb b/spec/unit/resource/execute_spec.rb index 09160ddbd0..493508f08b 100644 --- a/spec/unit/resource/execute_spec.rb +++ b/spec/unit/resource/execute_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Execute do let(:resource_instance_name) { "some command" } diff --git a/spec/unit/resource/file/verification_spec.rb b/spec/unit/resource/file/verification_spec.rb index 6b929789c8..30956c04ba 100644 --- a/spec/unit/resource/file/verification_spec.rb +++ b/spec/unit/resource/file/verification_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::File::Verification do let(:t_block) { Proc.new { true } } @@ -82,27 +82,27 @@ describe Chef::Resource::File::Verification do end it "substitutes \%{file} with the path" do - test_command = platform_specific_verify_command('file') + test_command = platform_specific_verify_command("file") v = Chef::Resource::File::Verification.new(parent_resource, test_command, {}) expect(v.verify(temp_path)).to eq(true) end it "warns about deprecation when \%{file} is used" do expect(Chef::Log).to receive(:deprecation).with(/%{file} is deprecated/, /verification_spec\.rb/) - test_command = platform_specific_verify_command('file') + test_command = platform_specific_verify_command("file") Chef::Resource::File::Verification.new(parent_resource, test_command, {}) .verify(temp_path) end it "does not warn about deprecation when \%{file} is not used" do expect(Chef::Log).to_not receive(:deprecation) - test_command = platform_specific_verify_command('path') + test_command = platform_specific_verify_command("path") Chef::Resource::File::Verification.new(parent_resource, test_command, {}) .verify(temp_path) end it "substitutes \%{path} with the path" do - test_command = platform_specific_verify_command('path') + test_command = platform_specific_verify_command("path") v = Chef::Resource::File::Verification.new(parent_resource, test_command, {}) expect(v.verify(temp_path)).to eq(true) end diff --git a/spec/unit/resource/file_spec.rb b/spec/unit/resource/file_spec.rb index 76beaf15e1..3dec8145a4 100644 --- a/spec/unit/resource/file_spec.rb +++ b/spec/unit/resource/file_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::File do diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb index 7263d3a7ba..5c9c613771 100644 --- a/spec/unit/resource/freebsd_package_spec.rb +++ b/spec/unit/resource/freebsd_package_spec.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Resource::FreebsdPackage do before(:each) do @@ -48,7 +48,7 @@ describe Chef::Resource::FreebsdPackage do describe "Assigning provider after creation" do describe "if ports specified as source" do it "should be Freebsd::Port" do - @resource.source('ports') + @resource.source("ports") @resource.after_created expect(@resource.provider).to eq(Chef::Provider::Package::Freebsd::Port) end diff --git a/spec/unit/resource/gem_package_spec.rb b/spec/unit/resource/gem_package_spec.rb index 0f3eae70bb..6992d8ef17 100644 --- a/spec/unit/resource/gem_package_spec.rb +++ b/spec/unit/resource/gem_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::GemPackage, "initialize" do diff --git a/spec/unit/resource/git_spec.rb b/spec/unit/resource/git_spec.rb index 6a39b3d172..5bdccc87b8 100644 --- a/spec/unit/resource/git_spec.rb +++ b/spec/unit/resource/git_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::Git do diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb index a4029fc911..56db882191 100644 --- a/spec/unit/resource/group_spec.rb +++ b/spec/unit/resource/group_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Group, "initialize" do before(:each) do diff --git a/spec/unit/resource/homebrew_package_spec.rb b/spec/unit/resource/homebrew_package_spec.rb index bb248d1189..6a3f88ceed 100644 --- a/spec/unit/resource/homebrew_package_spec.rb +++ b/spec/unit/resource/homebrew_package_spec.rb @@ -15,10 +15,10 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" -describe Chef::Resource::HomebrewPackage, 'initialize' do +describe Chef::Resource::HomebrewPackage, "initialize" do static_provider_resolution( resource: Chef::Resource::HomebrewPackage, @@ -28,22 +28,22 @@ describe Chef::Resource::HomebrewPackage, 'initialize' do os: "mac_os_x", ) - let(:resource) { Chef::Resource::HomebrewPackage.new('emacs') } + let(:resource) { Chef::Resource::HomebrewPackage.new("emacs") } - shared_examples 'home_brew user set and returned' do - it 'returns the configured homebrew_user' do + shared_examples "home_brew user set and returned" do + it "returns the configured homebrew_user" do resource.homebrew_user user expect(resource.homebrew_user).to eql(user) end end - context 'homebrew_user is set' do - let(:user) { 'Captain Picard' } - include_examples 'home_brew user set and returned' + context "homebrew_user is set" do + let(:user) { "Captain Picard" } + include_examples "home_brew user set and returned" - context 'as an integer' do + context "as an integer" do let(:user) { 1001 } - include_examples 'home_brew user set and returned' + include_examples "home_brew user set and returned" end end diff --git a/spec/unit/resource/http_request_spec.rb b/spec/unit/resource/http_request_spec.rb index aa4ce4dfbc..d8461854f9 100644 --- a/spec/unit/resource/http_request_spec.rb +++ b/spec/unit/resource/http_request_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::HttpRequest do diff --git a/spec/unit/resource/ifconfig_spec.rb b/spec/unit/resource/ifconfig_spec.rb index e3e1f6daa2..9d775e7257 100644 --- a/spec/unit/resource/ifconfig_spec.rb +++ b/spec/unit/resource/ifconfig_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Ifconfig do @@ -49,8 +49,8 @@ describe Chef::Resource::Ifconfig do shared_examples "being a platform based on an old Debian" do |platform, version| before do - @node.automatic_attrs[:os] = 'linux' - @node.automatic_attrs[:platform_family] = 'debian' + @node.automatic_attrs[:os] = "linux" + @node.automatic_attrs[:platform_family] = "debian" @node.automatic_attrs[:platform] = platform @node.automatic_attrs[:platform_version] = version end @@ -62,8 +62,8 @@ describe Chef::Resource::Ifconfig do shared_examples "being a platform based on RedHat" do |platform, version| before do - @node.automatic_attrs[:os] = 'linux' - @node.automatic_attrs[:platform_family] = 'rhel' + @node.automatic_attrs[:os] = "linux" + @node.automatic_attrs[:platform_family] = "rhel" @node.automatic_attrs[:platform] = platform @node.automatic_attrs[:platform_version] = version end @@ -75,8 +75,8 @@ describe Chef::Resource::Ifconfig do shared_examples "being a platform based on a recent Debian" do |platform, version| before do - @node.automatic_attrs[:os] = 'linux' - @node.automatic_attrs[:platform_family] = 'debian' + @node.automatic_attrs[:os] = "linux" + @node.automatic_attrs[:platform_family] = "debian" @node.automatic_attrs[:platform] = platform @node.automatic_attrs[:platform_version] = version end diff --git a/spec/unit/resource/ips_package_spec.rb b/spec/unit/resource/ips_package_spec.rb index 126ae00224..0725380620 100644 --- a/spec/unit/resource/ips_package_spec.rb +++ b/spec/unit/resource/ips_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::IpsPackage, "initialize" do diff --git a/spec/unit/resource/ksh_spec.rb b/spec/unit/resource/ksh_spec.rb index 04bd8148fd..a188ed9802 100644 --- a/spec/unit/resource/ksh_spec.rb +++ b/spec/unit/resource/ksh_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Ksh do diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb index 220ad735bd..0ce5be1caf 100644 --- a/spec/unit/resource/link_spec.rb +++ b/spec/unit/resource/link_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Link do diff --git a/spec/unit/resource/log_spec.rb b/spec/unit/resource/log_spec.rb index b2af194238..d6169ae315 100644 --- a/spec/unit/resource/log_spec.rb +++ b/spec/unit/resource/log_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Log do diff --git a/spec/unit/resource/macports_package_spec.rb b/spec/unit/resource/macports_package_spec.rb index 0a203b2e97..488615f594 100644 --- a/spec/unit/resource/macports_package_spec.rb +++ b/spec/unit/resource/macports_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::MacportsPackage, "initialize" do diff --git a/spec/unit/resource/mdadm_spec.rb b/spec/unit/resource/mdadm_spec.rb index 6ca99c58e5..f2d0e157af 100644 --- a/spec/unit/resource/mdadm_spec.rb +++ b/spec/unit/resource/mdadm_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Mdadm do diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index acce26dcab..1dac2d5dd9 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Mount do before(:each) do @@ -54,7 +54,7 @@ describe Chef::Resource::Mount do end it "should set fsck_device to '-' by default" do - expect(@resource.fsck_device).to eql('-') + expect(@resource.fsck_device).to eql("-") end it "should allow you to set the fsck_device attribute" do diff --git a/spec/unit/resource/ohai_spec.rb b/spec/unit/resource/ohai_spec.rb index 3bc21a41d2..0bf904ab0c 100644 --- a/spec/unit/resource/ohai_spec.rb +++ b/spec/unit/resource/ohai_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Ohai do diff --git a/spec/unit/resource/openbsd_package_spec.rb b/spec/unit/resource/openbsd_package_spec.rb index 95921c2f02..34de97f931 100644 --- a/spec/unit/resource/openbsd_package_spec.rb +++ b/spec/unit/resource/openbsd_package_spec.rb @@ -19,8 +19,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Chef::Resource::OpenbsdPackage do diff --git a/spec/unit/resource/osx_profile_spec.rb b/spec/unit/resource/osx_profile_spec.rb index d7d72e5836..06a147ad84 100644 --- a/spec/unit/resource/osx_profile_spec.rb +++ b/spec/unit/resource/osx_profile_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::OsxProfile do let(:resource) { Chef::Resource::OsxProfile.new( @@ -54,7 +54,7 @@ describe Chef::Resource::OsxProfile do end it "should allow you to set the profile attribute to a hash" do - test_profile = { 'profile' => false } + test_profile = { "profile" => false } resource.profile test_profile expect(resource.profile).to be_a(Hash) end diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb index 449732a3c4..7f7a27e2b2 100644 --- a/spec/unit/resource/package_spec.rb +++ b/spec/unit/resource/package_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Package do diff --git a/spec/unit/resource/pacman_package_spec.rb b/spec/unit/resource/pacman_package_spec.rb index 975863d04f..a383601d93 100644 --- a/spec/unit/resource/pacman_package_spec.rb +++ b/spec/unit/resource/pacman_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::PacmanPackage, "initialize" do diff --git a/spec/unit/resource/perl_spec.rb b/spec/unit/resource/perl_spec.rb index 7247cce6e3..9a1ec22a95 100644 --- a/spec/unit/resource/perl_spec.rb +++ b/spec/unit/resource/perl_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Perl do diff --git a/spec/unit/resource/powershell_script_spec.rb b/spec/unit/resource/powershell_script_spec.rb index 42fcd61a58..16d2d37c9e 100644 --- a/spec/unit/resource/powershell_script_spec.rb +++ b/spec/unit/resource/powershell_script_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::PowershellScript do @@ -25,7 +25,7 @@ describe Chef::Resource::PowershellScript do node.default["kernel"] = Hash.new node.default["kernel"][:machine] = :x86_64.to_s - node.automatic[:os] = 'windows' + node.automatic[:os] = "windows" run_context = Chef::RunContext.new(node, nil, nil) @@ -94,7 +94,7 @@ describe Chef::Resource::PowershellScript do it "enables convert_boolean_return by default for guards in non-Chef::Resource::Script derived resources when no guard params are specified" do node = Chef::Node.new run_context = Chef::RunContext.new(node, nil, nil) - file_resource = Chef::Resource::File.new('idontexist', run_context) + file_resource = Chef::Resource::File.new("idontexist", run_context) file_resource.guard_interpreter :powershell_script allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( @@ -103,21 +103,21 @@ describe Chef::Resource::PowershellScript do end it "enables convert_boolean_return by default for guards in the context of powershell_script when guard params are specified" do - guard_parameters = {:cwd => '/etc/chef', :architecture => :x86_64} + guard_parameters = {:cwd => "/etc/chef", :architecture => :x86_64} allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( {:convert_boolean_return => true, :code => "$true"}.merge(guard_parameters)).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end it "passes convert_boolean_return as true if it was specified as true in a guard parameter" do - guard_parameters = {:cwd => '/etc/chef', :convert_boolean_return => true, :architecture => :x86_64} + guard_parameters = {:cwd => "/etc/chef", :convert_boolean_return => true, :architecture => :x86_64} allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( {:convert_boolean_return => true, :code => "$true"}.merge(guard_parameters)).and_return(Proc.new {}) resource.only_if("$true", guard_parameters) end it "passes convert_boolean_return as false if it was specified as true in a guard parameter" do - other_guard_parameters = {:cwd => '/etc/chef', :architecture => :x86_64} + other_guard_parameters = {:cwd => "/etc/chef", :architecture => :x86_64} parameters_with_boolean_disabled = other_guard_parameters.merge({:convert_boolean_return => false, :code => "$true"}) allow_any_instance_of(Chef::GuardInterpreter::ResourceGuardInterpreter).to receive(:block_from_attributes).with( parameters_with_boolean_disabled).and_return(Proc.new {}) @@ -129,7 +129,7 @@ describe Chef::Resource::PowershellScript do let(:resource_instance) { @resource } let(:resource_instance_name ) { @resource.command } let(:resource_name) { :powershell_script } - let(:interpreter_file_name) { 'powershell.exe' } + let(:interpreter_file_name) { "powershell.exe" } it_behaves_like "a Windows script resource" end diff --git a/spec/unit/resource/python_spec.rb b/spec/unit/resource/python_spec.rb index 8a3f7e48ca..a579eacdff 100644 --- a/spec/unit/resource/python_spec.rb +++ b/spec/unit/resource/python_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Python do diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb index 2d82f1a51c..05a0f5ce83 100644 --- a/spec/unit/resource/registry_key_spec.rb +++ b/spec/unit/resource/registry_key_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::RegistryKey, "initialize" do before(:each) do @@ -80,38 +80,38 @@ describe Chef::Resource::RegistryKey, "values" do end it "should allow a single proper hash of registry values" do - @resource.values( { :name => 'poosh', :type => :string, :data => 'carmen' } ) - expect(@resource.values).to eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ]) + @resource.values( { :name => "poosh", :type => :string, :data => "carmen" } ) + expect(@resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ]) end it "should allow an array of proper hashes of registry values" do - @resource.values [ { :name => 'poosh', :type => :string, :data => 'carmen' } ] - expect(@resource.values).to eql([ { :name => 'poosh', :type => :string, :data => 'carmen' } ]) + @resource.values [ { :name => "poosh", :type => :string, :data => "carmen" } ] + expect(@resource.values).to eql([ { :name => "poosh", :type => :string, :data => "carmen" } ]) end it "should return checksummed data if the type is unsafe" do - @resource.values( { :name => 'poosh', :type => :binary, :data => 255.chr * 1 }) - expect(@resource.values).to eql([ { :name => 'poosh', :type => :binary, :data => 'a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89' } ]) + @resource.values( { :name => "poosh", :type => :binary, :data => 255.chr * 1 }) + expect(@resource.values).to eql([ { :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89" } ]) end it "should throw an exception if the name field is missing" do - expect { @resource.values [ { :type => :string, :data => 'carmen' } ] }.to raise_error(ArgumentError) + expect { @resource.values [ { :type => :string, :data => "carmen" } ] }.to raise_error(ArgumentError) end it "should throw an exception if the type field is missing" do - expect { @resource.values [ { :name => 'poosh', :data => 'carmen' } ] }.to raise_error(ArgumentError) + expect { @resource.values [ { :name => "poosh", :data => "carmen" } ] }.to raise_error(ArgumentError) end it "should throw an exception if the data field is missing" do - expect { @resource.values [ { :name => 'poosh', :type => :string } ] }.to raise_error(ArgumentError) + expect { @resource.values [ { :name => "poosh", :type => :string } ] }.to raise_error(ArgumentError) end it "should throw an exception if extra fields are present" do - expect { @resource.values [ { :name => 'poosh', :type => :string, :data => 'carmen', :screwdriver => 'sonic' } ] }.to raise_error(ArgumentError) + expect { @resource.values [ { :name => "poosh", :type => :string, :data => "carmen", :screwdriver => "sonic" } ] }.to raise_error(ArgumentError) end it "should not allow a string" do - expect { @resource.send(:values, 'souffle') }.to raise_error(ArgumentError) + expect { @resource.send(:values, "souffle") }.to raise_error(ArgumentError) end it "should not allow an integer" do @@ -138,7 +138,7 @@ describe Chef::Resource::RegistryKey, "recursive" do end it "should not allow a string" do - expect { @resource.recursive('souffle') }.to raise_error(ArgumentError) + expect { @resource.recursive("souffle") }.to raise_error(ArgumentError) end it "should not allow an integer" do @@ -167,7 +167,7 @@ describe Chef::Resource::RegistryKey, "architecture" do end it "should not allow a string" do - expect { @resource.architecture('souffle') }.to raise_error(ArgumentError) + expect { @resource.architecture("souffle") }.to raise_error(ArgumentError) end it "should not allow an integer" do @@ -181,7 +181,7 @@ describe Chef::Resource::RegistryKey, ":unscrubbed_values" do end it "should return unsafe data as-is" do - key_values = [ { :name => 'poosh', :type => :binary, :data => 255.chr * 1 } ] + key_values = [ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ] @resource.values(key_values) expect(@resource.unscrubbed_values).to eql(key_values) end @@ -193,7 +193,7 @@ describe Chef::Resource::RegistryKey, "state" do end it "should return scrubbed values" do - @resource.values([ { :name => 'poosh', :type => :binary, :data => 255.chr * 1 } ]) - expect(@resource.state).to eql( { :values => [{ :name => 'poosh', :type => :binary, :data => 'a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89'}] } ) + @resource.values([ { :name => "poosh", :type => :binary, :data => 255.chr * 1 } ]) + expect(@resource.state).to eql( { :values => [{ :name => "poosh", :type => :binary, :data => "a8100ae6aa1940d0b663bb31cd466142ebbdbd5187131b92d93818987832eb89"}] } ) end end diff --git a/spec/unit/resource/remote_directory_spec.rb b/spec/unit/resource/remote_directory_spec.rb index 1ab75586b6..ac0cfcf8d5 100644 --- a/spec/unit/resource/remote_directory_spec.rb +++ b/spec/unit/resource/remote_directory_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::RemoteDirectory do diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb index 0a379ff574..746cdb195c 100644 --- a/spec/unit/resource/remote_file_spec.rb +++ b/spec/unit/resource/remote_file_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::RemoteFile do @@ -36,13 +36,13 @@ describe Chef::Resource::RemoteFile do it "says its provider is RemoteFile when the source is an absolute URI" do @resource.source("http://www.google.com/robots.txt") expect(@resource.provider).to eq(Chef::Provider::RemoteFile) - expect(Chef::Platform.find_provider(:noplatform, 'noversion', @resource)).to eq(Chef::Provider::RemoteFile) + expect(Chef::Platform.find_provider(:noplatform, "noversion", @resource)).to eq(Chef::Provider::RemoteFile) end it "says its provider is RemoteFile when the source is a network share" do @resource.source("\\\\fakey\\fakerton\\fake.txt") expect(@resource.provider).to eq(Chef::Provider::RemoteFile) - expect(Chef::Platform.find_provider(:noplatform, 'noversion', @resource)).to eq(Chef::Provider::RemoteFile) + expect(Chef::Platform.find_provider(:noplatform, "noversion", @resource)).to eq(Chef::Provider::RemoteFile) end describe "source" do @@ -60,7 +60,7 @@ describe Chef::Resource::RemoteFile do expect(@resource.source).to eql([ "\\\\fakey\\fakerton\\fake.txt" ]) end - it 'should accept file URIs with spaces' do + it "should accept file URIs with spaces" do @resource.source("file:///C:/foo bar") expect(@resource.source).to eql(["file:///C:/foo bar"]) end diff --git a/spec/unit/resource/resource_notification_spec.rb b/spec/unit/resource/resource_notification_spec.rb index 024b6f93f7..dfe5d25cec 100644 --- a/spec/unit/resource/resource_notification_spec.rb +++ b/spec/unit/resource/resource_notification_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' -require 'chef/resource/resource_notification' +require "spec_helper" +require "chef/resource/resource_notification" describe Chef::Resource::Notification do diff --git a/spec/unit/resource/route_spec.rb b/spec/unit/resource/route_spec.rb index ec1d369932..b38093887b 100644 --- a/spec/unit/resource/route_spec.rb +++ b/spec/unit/resource/route_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Route do diff --git a/spec/unit/resource/rpm_package_spec.rb b/spec/unit/resource/rpm_package_spec.rb index b2e06f7f68..69412a8d06 100644 --- a/spec/unit/resource/rpm_package_spec.rb +++ b/spec/unit/resource/rpm_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::RpmPackage, "initialize" do diff --git a/spec/unit/resource/ruby_block_spec.rb b/spec/unit/resource/ruby_block_spec.rb index 8664564ac5..d48fd9113c 100644 --- a/spec/unit/resource/ruby_block_spec.rb +++ b/spec/unit/resource/ruby_block_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::RubyBlock do diff --git a/spec/unit/resource/ruby_spec.rb b/spec/unit/resource/ruby_spec.rb index e899810ab9..95078011ee 100644 --- a/spec/unit/resource/ruby_spec.rb +++ b/spec/unit/resource/ruby_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Ruby do diff --git a/spec/unit/resource/scm_spec.rb b/spec/unit/resource/scm_spec.rb index 72319277ab..fadc9a3e54 100644 --- a/spec/unit/resource/scm_spec.rb +++ b/spec/unit/resource/scm_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Scm do @@ -184,7 +184,7 @@ describe Chef::Resource::Scm do end describe "when it has a environment attribute" do - let(:test_environment) { {'CHEF_ENV' => '/tmp' } } + let(:test_environment) { {"CHEF_ENV" => "/tmp" } } before { @resource.environment(test_environment) } it "stores this environment" do expect(@resource.environment).to eq(test_environment) diff --git a/spec/unit/resource/script_spec.rb b/spec/unit/resource/script_spec.rb index 4affee8e8c..45ad1e6cec 100644 --- a/spec/unit/resource/script_spec.rb +++ b/spec/unit/resource/script_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Script do let(:resource_instance_name) { "fakey_fakerton" } diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index b9e3757255..16288d7a90 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Service do diff --git a/spec/unit/resource/smartos_package_spec.rb b/spec/unit/resource/smartos_package_spec.rb index c2cf546dd5..24e65e6c3c 100644 --- a/spec/unit/resource/smartos_package_spec.rb +++ b/spec/unit/resource/smartos_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::SmartosPackage, "initialize" do diff --git a/spec/unit/resource/solaris_package_spec.rb b/spec/unit/resource/solaris_package_spec.rb index f5d3e669a1..a97730aea6 100644 --- a/spec/unit/resource/solaris_package_spec.rb +++ b/spec/unit/resource/solaris_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::SolarisPackage, "initialize" do diff --git a/spec/unit/resource/subversion_spec.rb b/spec/unit/resource/subversion_spec.rb index aa4d1ed708..b2d3689dc9 100644 --- a/spec/unit/resource/subversion_spec.rb +++ b/spec/unit/resource/subversion_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::Subversion do @@ -42,7 +42,7 @@ describe Chef::Resource::Subversion do end it "sets svn info arguments to --no-auth-cache by default" do - expect(@svn.svn_info_args).to eq('--no-auth-cache') + expect(@svn.svn_info_args).to eq("--no-auth-cache") end it "resets svn info arguments to nil when given false in the setter" do @@ -51,7 +51,7 @@ describe Chef::Resource::Subversion do end it "sets svn arguments to --no-auth-cache by default" do - expect(@svn.svn_arguments).to eq('--no-auth-cache') + expect(@svn.svn_arguments).to eq("--no-auth-cache") end it "sets svn binary to nil by default" do diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb index 2fd951b72d..2e7c1781d1 100644 --- a/spec/unit/resource/template_spec.rb +++ b/spec/unit/resource/template_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::Template do diff --git a/spec/unit/resource/timestamped_deploy_spec.rb b/spec/unit/resource/timestamped_deploy_spec.rb index 4ebfdaf059..851cbf4f35 100644 --- a/spec/unit/resource/timestamped_deploy_spec.rb +++ b/spec/unit/resource/timestamped_deploy_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::TimestampedDeploy, "initialize" do @@ -25,8 +25,8 @@ describe Chef::Resource::TimestampedDeploy, "initialize" do provider: Chef::Provider::Deploy::Timestamped, name: :timestamped_deploy, action: :deploy, - os: 'linux', - platform_family: 'rhel', + os: "linux", + platform_family: "rhel", ) end diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb index 3bf7e6187b..e259653120 100644 --- a/spec/unit/resource/user_spec.rb +++ b/spec/unit/resource/user_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::User, "initialize" do before(:each) do diff --git a/spec/unit/resource/windows_package_spec.rb b/spec/unit/resource/windows_package_spec.rb index 3623c24e29..ba336a4afd 100644 --- a/spec/unit/resource/windows_package_spec.rb +++ b/spec/unit/resource/windows_package_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::WindowsPackage, "initialize" do before(:each) do @@ -80,12 +80,12 @@ describe Chef::Resource::WindowsPackage, "initialize" do end it "supports the checksum attribute" do - resource.checksum('somechecksum') - expect(resource.checksum).to eq('somechecksum') + resource.checksum("somechecksum") + expect(resource.checksum).to eq("somechecksum") end - context 'when a URL is used' do - let(:resource_source) { 'https://foo.bar/solitare.msi' } + context "when a URL is used" do + let(:resource_source) { "https://foo.bar/solitare.msi" } let(:resource) { Chef::Resource::WindowsPackage.new(resource_source) } it "should return the source unmodified" do diff --git a/spec/unit/resource/windows_service_spec.rb b/spec/unit/resource/windows_service_spec.rb index 64bb05afc4..04a27090a5 100644 --- a/spec/unit/resource/windows_service_spec.rb +++ b/spec/unit/resource/windows_service_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource::WindowsService, "initialize" do static_provider_resolution( diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb index f24f1e3405..4c175bb905 100644 --- a/spec/unit/resource/yum_package_spec.rb +++ b/spec/unit/resource/yum_package_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/shared/unit/resource/static_provider_resolution' +require "spec_helper" +require "support/shared/unit/resource/static_provider_resolution" describe Chef::Resource::YumPackage, "initialize" do @@ -26,8 +26,8 @@ describe Chef::Resource::YumPackage, "initialize" do provider: Chef::Provider::Package::Yum, name: :yum_package, action: :install, - os: 'linux', - platform_family: 'rhel', + os: "linux", + platform_family: "rhel", ) end diff --git a/spec/unit/resource_collection/resource_list_spec.rb b/spec/unit/resource_collection/resource_list_spec.rb index 1e6c477854..a9f30f8bac 100644 --- a/spec/unit/resource_collection/resource_list_spec.rb +++ b/spec/unit/resource_collection/resource_list_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::ResourceCollection::ResourceList do let(:resource_list) { Chef::ResourceCollection::ResourceList.new() } diff --git a/spec/unit/resource_collection/resource_set_spec.rb b/spec/unit/resource_collection/resource_set_spec.rb index 0e25934216..a5f26dd4f9 100644 --- a/spec/unit/resource_collection/resource_set_spec.rb +++ b/spec/unit/resource_collection/resource_set_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::ResourceCollection::ResourceSet do let(:collection) { Chef::ResourceCollection::ResourceSet.new } diff --git a/spec/unit/resource_collection/stepable_iterator_spec.rb b/spec/unit/resource_collection/stepable_iterator_spec.rb index b34b7140fe..c81139fecb 100644 --- a/spec/unit/resource_collection/stepable_iterator_spec.rb +++ b/spec/unit/resource_collection/stepable_iterator_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::ResourceCollection::StepableIterator do CRSI = Chef::ResourceCollection::StepableIterator diff --git a/spec/unit/resource_collection_spec.rb b/spec/unit/resource_collection_spec.rb index d52e7e2c26..ff7e111956 100644 --- a/spec/unit/resource_collection_spec.rb +++ b/spec/unit/resource_collection_spec.rb @@ -17,7 +17,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::ResourceCollection do let(:rc) { Chef::ResourceCollection.new() } @@ -65,7 +65,7 @@ describe Chef::ResourceCollection do end it "should accept named arguments in any order" do - rc.insert(resource, :instance_name => 'foo', :resource_type =>'bar') + rc.insert(resource, :instance_name => "foo", :resource_type =>"bar") expect(rc[0]).to eq(resource) end diff --git a/spec/unit/resource_definition_spec.rb b/spec/unit/resource_definition_spec.rb index 1371a8b9a6..cd4a29bd47 100644 --- a/spec/unit/resource_definition_spec.rb +++ b/spec/unit/resource_definition_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::ResourceDefinition do let(:defn) { Chef::ResourceDefinition.new() } diff --git a/spec/unit/resource_reporter_spec.rb b/spec/unit/resource_reporter_spec.rb index 34d4b23106..aa162fd161 100644 --- a/spec/unit/resource_reporter_spec.rb +++ b/spec/unit/resource_reporter_spec.rb @@ -20,8 +20,8 @@ # require File.expand_path("../../spec_helper", __FILE__) -require 'chef/resource_reporter' -require 'socket' +require "chef/resource_reporter" +require "socket" describe Chef::ResourceReporter do before(:all) do @@ -51,7 +51,7 @@ describe Chef::ResourceReporter do @run_context = Chef::RunContext.new(@node, {}, @events) @run_status = Chef::RunStatus.new(@node, @events) @run_list = Chef::RunList.new - @run_list << 'recipe[lobster]' << 'role[rage]' << 'recipe[fist]' + @run_list << "recipe[lobster]" << "role[rage]" << "recipe[fist]" @expansion = Chef::RunList::RunListExpansion.new("_default", @run_list.run_list_items) @run_id = @run_status.run_id allow(Time).to receive(:now).and_return(@start_time, @end_time) @@ -446,7 +446,7 @@ describe Chef::ResourceReporter do context "when the resource is a RegistryKey with binary data" do let(:new_resource) do resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs') - resource.values([ { :name => 'rick', :type => :binary, :data => 255.chr * 1 } ]) + resource.values([ { :name => "rick", :type => :binary, :data => 255.chr * 1 } ]) allow(resource).to receive(:cookbook_name).and_return(@cookbook_name) allow(resource).to receive(:cookbook_version).and_return(@cookbook_version) resource @@ -454,7 +454,7 @@ describe Chef::ResourceReporter do let(:current_resource) do resource = Chef::Resource::RegistryKey.new('Wubba\Lubba\Dub\Dubs') - resource.values([ { :name => 'rick', :type => :binary, :data => 255.chr * 1 } ]) + resource.values([ { :name => "rick", :type => :binary, :data => 255.chr * 1 } ]) resource end @@ -568,12 +568,12 @@ describe Chef::ResourceReporter do it "sets before to {} instead of nil" do expect(@first_update_report).to have_key("before") - expect(@first_update_report['before']).to eq({}) + expect(@first_update_report["before"]).to eq({}) end it "sets after to {} instead of 'Running'" do expect(@first_update_report).to have_key("after") - expect(@first_update_report['after']).to eq({}) + expect(@first_update_report["after"]).to eq({}) end end @@ -593,7 +593,7 @@ describe Chef::ResourceReporter do expect(@rest_client).to receive(:post). with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id, :start_time => @start_time.to_s}, - {'X-Ops-Reporting-Protocol-Version' => Chef::ResourceReporter::PROTOCOL_VERSION}). + {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}). and_raise(@error) end @@ -622,7 +622,7 @@ describe Chef::ResourceReporter do @error = Net::HTTPServerException.new("500 message", @response) expect(@rest_client).to receive(:post). with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id, :start_time => @start_time.to_s}, - {'X-Ops-Reporting-Protocol-Version' => Chef::ResourceReporter::PROTOCOL_VERSION}). + {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}). and_raise(@error) end @@ -652,7 +652,7 @@ describe Chef::ResourceReporter do @error = Net::HTTPServerException.new("500 message", @response) expect(@rest_client).to receive(:post). with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id, :start_time => @start_time.to_s}, - {'X-Ops-Reporting-Protocol-Version' => Chef::ResourceReporter::PROTOCOL_VERSION}). + {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}). and_raise(@error) end @@ -673,7 +673,7 @@ describe Chef::ResourceReporter do response = {"uri"=>"https://example.com/reports/nodes/spitfire/runs/@run_id"} expect(@rest_client).to receive(:post). with("reports/nodes/spitfire/runs", {:action => :start, :run_id => @run_id, :start_time => @start_time.to_s}, - {'X-Ops-Reporting-Protocol-Version' => Chef::ResourceReporter::PROTOCOL_VERSION}). + {"X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION}). and_return(response) @resource_reporter.run_started(@run_status) end @@ -695,8 +695,8 @@ describe Chef::ResourceReporter do expect(@rest_client).to receive(:raw_request).ordered do |method, url, headers, data| expect(method).to eq(:POST) - expect(headers).to eq({'Content-Encoding' => 'gzip', - 'X-Ops-Reporting-Protocol-Version' => Chef::ResourceReporter::PROTOCOL_VERSION, + expect(headers).to eq({"Content-Encoding" => "gzip", + "X-Ops-Reporting-Protocol-Version" => Chef::ResourceReporter::PROTOCOL_VERSION, },) data_stream = Zlib::GzipReader.new(StringIO.new(data)) data = data_stream.read diff --git a/spec/unit/resource_resolver_spec.rb b/spec/unit/resource_resolver_spec.rb index b3bda9d945..05ee79144e 100644 --- a/spec/unit/resource_resolver_spec.rb +++ b/spec/unit/resource_resolver_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/resource_resolver' +require "spec_helper" +require "chef/resource_resolver" describe Chef::ResourceResolver do @@ -29,9 +29,9 @@ describe Chef::ResourceResolver do expect(described_class.list(:package)).to_not be_empty end - context 'instance methods' do + context "instance methods" do let(:resolver) do - described_class.new(Chef::Node.new, 'execute') + described_class.new(Chef::Node.new, "execute") end it '#resolve' do diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 82d224e810..53d546d059 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -19,10 +19,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Resource do - let(:cookbook_repo_path) { File.join(CHEF_SPEC_DATA, 'cookbooks') } + let(:cookbook_repo_path) { File.join(CHEF_SPEC_DATA, "cookbooks") } let(:cookbook_collection) { Chef::CookbookCollection.new(Chef::CookbookLoader.new(cookbook_repo_path)) } let(:node) { Chef::Node.new } let(:events) { Chef::EventDispatch::Dispatcher.new } @@ -205,7 +205,7 @@ describe Chef::Resource do end it "coerces arrays to names" do - expect(resource.name ['a', 'b']).to eql('a, b') + expect(resource.name ["a", "b"]).to eql("a, b") end it "should coerce objects to a string" do @@ -252,13 +252,13 @@ describe Chef::Resource do end it "creates a notification for a resource that is not yet in the resource collection" do - resource.notifies(:restart, :service => 'apache') + resource.notifies(:restart, :service => "apache") expected_notification = Chef::Resource::Notification.new({:service => "apache"}, :restart, resource) expect(resource.delayed_notifications).to include(expected_notification) end it "notifies another resource immediately" do - resource.notifies_immediately(:restart, :service => 'apache') + resource.notifies_immediately(:restart, :service => "apache") expected_notification = Chef::Resource::Notification.new({:service => "apache"}, :restart, resource) expect(resource.immediate_notifications).to include(expected_notification) end @@ -340,7 +340,7 @@ describe Chef::Resource do c = Class.new(Chef::Resource) do end - r = c.new('hi') + r = c.new("hi") r.declared_type = :d expect(c.resource_name).to be_nil expect(r.resource_name).to be_nil @@ -355,7 +355,7 @@ describe Chef::Resource do end end - r = c.new('hi') + r = c.new("hi") r.declared_type = :d expect(c.resource_name).to be_nil expect(r.resource_name).to eq :blah @@ -369,7 +369,7 @@ describe Chef::Resource do end end - r = c.new('hi') + r = c.new("hi") r.declared_type = :d expect(c.resource_name).to be_nil expect(r.resource_name).to be_nil @@ -379,10 +379,10 @@ describe Chef::Resource do it "resource_name without provides is honored" do c = Class.new(Chef::Resource) do - resource_name 'blah' + resource_name "blah" end - r = c.new('hi') + r = c.new("hi") r.declared_type = :d expect(c.resource_name).to eq :blah expect(r.resource_name).to eq :blah @@ -394,7 +394,7 @@ describe Chef::Resource do end c.resource_name = :blah - r = c.new('hi') + r = c.new("hi") r.declared_type = :d expect(c.resource_name).to eq :blah expect(r.resource_name).to eq :blah @@ -406,7 +406,7 @@ describe Chef::Resource do provides :self_resource_name_test_3 end - r = c.new('hi') + r = c.new("hi") r.declared_type = :d expect(c.resource_name).to eq :blah expect(r.resource_name).to eq :blah @@ -512,7 +512,7 @@ describe Chef::Resource do before do node.automatic_attrs[:platform] = "fubuntu" - node.automatic_attrs[:platform_version] = '10.04' + node.automatic_attrs[:platform_version] = "10.04" end it "should default to not retrying if a provider fails for a resource" do @@ -614,7 +614,7 @@ describe Chef::Resource do } before do node.automatic_attrs[:platform] = "fubuntu" - node.automatic_attrs[:platform_version] = '10.04' + node.automatic_attrs[:platform_version] = "10.04" end it "does not run only_if if no only_if command is given" do @@ -643,8 +643,8 @@ describe Chef::Resource do it "accepts command options for only_if conditionals" do expect_any_instance_of(Chef::Resource::Conditional).to receive(:evaluate_command).at_least(1).times - resource.only_if("true", :cwd => '/tmp') - expect(resource.only_if.first.command_opts).to eq({:cwd => '/tmp'}) + resource.only_if("true", :cwd => "/tmp") + expect(resource.only_if.first.command_opts).to eq({:cwd => "/tmp"}) resource.run_action(:purr) end @@ -656,7 +656,7 @@ describe Chef::Resource do it "runs not_if as a block when it is a ruby block" do expect_any_instance_of(Chef::Resource::Conditional).to receive(:evaluate_block).at_least(1).times - resource.not_if { puts 'foo' } + resource.not_if { puts "foo" } resource.run_action(:purr) end @@ -667,8 +667,8 @@ describe Chef::Resource do end it "accepts command options for not_if conditionals" do - resource.not_if("pwd" , :cwd => '/tmp') - expect(resource.not_if.first.command_opts).to eq({:cwd => '/tmp'}) + resource.not_if("pwd" , :cwd => "/tmp") + expect(resource.not_if.first.command_opts).to eq({:cwd => "/tmp"}) end it "accepts multiple not_if conditionals" do @@ -698,7 +698,7 @@ describe Chef::Resource do end it "should raise Chef::Exceptions::ValidationFailed on an attempt to set the guard_interpreter attribute to something other than a Symbol" do - expect { resource.guard_interpreter('command_dot_com') }.to raise_error(Chef::Exceptions::ValidationFailed) + expect { resource.guard_interpreter("command_dot_com") }.to raise_error(Chef::Exceptions::ValidationFailed) end it "should not raise an exception when setting the guard interpreter attribute to a Symbol" do @@ -804,7 +804,7 @@ describe Chef::Resource do } before do node.automatic_attrs[:platform] = "fubuntu" - node.automatic_attrs[:platform_version] = '10.04' + node.automatic_attrs[:platform_version] = "10.04" end it "should not run only_if/not_if conditionals (CHEF-972)" do @@ -850,21 +850,21 @@ describe Chef::Resource do Chef::Resource.send(:remove_const, :Klz) end - it 'adds mappings for a single platform' do + it "adds mappings for a single platform" do expect(Chef.resource_handler_map).to receive(:set).with( - :dinobot, Chef::Resource::Klz, { platform: ['autobots'] } + :dinobot, Chef::Resource::Klz, { platform: ["autobots"] } ) - klz.provides :dinobot, platform: ['autobots'] + klz.provides :dinobot, platform: ["autobots"] end - it 'adds mappings for multiple platforms' do + it "adds mappings for multiple platforms" do expect(Chef.resource_handler_map).to receive(:set).with( - :energy, Chef::Resource::Klz, { platform: ['autobots', 'decepticons']} + :energy, Chef::Resource::Klz, { platform: ["autobots", "decepticons"]} ) - klz.provides :energy, platform: ['autobots', 'decepticons'] + klz.provides :energy, platform: ["autobots", "decepticons"] end - it 'adds mappings for all platforms' do + it "adds mappings for all platforms" do expect(Chef.resource_handler_map).to receive(:set).with( :tape_deck, Chef::Resource::Klz, {} ) @@ -883,7 +883,7 @@ describe Chef::Resource do node.name("bumblebee") node.automatic[:platform] = "autobots" node.automatic[:platform_version] = "6.1" - Object.const_set('Soundwave', klz1) + Object.const_set("Soundwave", klz1) klz1.provides :soundwave end @@ -905,8 +905,8 @@ describe Chef::Resource do node.name("bumblebee") node.automatic[:platform] = "autobots" node.automatic[:platform_version] = "6.1" - klz2.provides :dinobot, :platform => ['autobots'] - Object.const_set('Grimlock', klz2) + klz2.provides :dinobot, :platform => ["autobots"] + Object.const_set("Grimlock", klz2) klz2.provides :grimlock end @@ -1019,7 +1019,7 @@ describe Chef::Resource do allowed_actions(%i{one two}) end end - let(:resource) { resource_class.new('test', nil) } + let(:resource) { resource_class.new("test", nil) } subject { resource.action } context "with a no action" do @@ -1041,7 +1041,7 @@ describe Chef::Resource do end context "with a string action" do - before { resource.action('two') } + before { resource.action("two") } it { is_expected.to eq [:two] } end @@ -1089,7 +1089,7 @@ describe Chef::Resource do end context "with a string default action" do - let(:default_action) { 'one' } + let(:default_action) { "one" } it { is_expected.to eq [:one] } end diff --git a/spec/unit/rest/auth_credentials_spec.rb b/spec/unit/rest/auth_credentials_spec.rb index dc66d12a19..88da44319b 100644 --- a/spec/unit/rest/auth_credentials_spec.rb +++ b/spec/unit/rest/auth_credentials_spec.rb @@ -19,9 +19,9 @@ # limitations under the License. # -require 'spec_helper' -require 'uri' -require 'net/https' +require "spec_helper" +require "uri" +require "net/https" KEY_DOT_PEM=<<-END_RSA_KEY -----BEGIN RSA PRIVATE KEY----- @@ -56,7 +56,7 @@ Y6S6MeZ69Rp89ma4ttMZ+kwi1+XyHqC/dlcVRW42Zl5Dc7BALRlJjQ== describe Chef::REST::AuthCredentials do before do - @key_file_fixture = CHEF_SPEC_DATA + '/ssl/private_key.pem' + @key_file_fixture = CHEF_SPEC_DATA + "/ssl/private_key.pem" @key = OpenSSL::PKey::RSA.new(IO.read(@key_file_fixture).strip) @auth_credentials = Chef::REST::AuthCredentials.new("client-name", @key) end @@ -72,7 +72,7 @@ describe Chef::REST::AuthCredentials do describe "when loading the private key" do it "strips extra whitespace before checking the key" do - key_file_fixture = CHEF_SPEC_DATA + '/ssl/private_key_with_whitespace.pem' + key_file_fixture = CHEF_SPEC_DATA + "/ssl/private_key_with_whitespace.pem" expect {Chef::REST::AuthCredentials.new("client-name", @key_file_fixture)}.not_to raise_error end end @@ -131,7 +131,7 @@ describe Chef::REST::RESTRequest do end before do - @auth_credentials = Chef::REST::AuthCredentials.new("client-name", CHEF_SPEC_DATA + '/ssl/private_key.pem') + @auth_credentials = Chef::REST::AuthCredentials.new("client-name", CHEF_SPEC_DATA + "/ssl/private_key.pem") @url = URI.parse("http://chef.example.com:4000/?q=chef_is_awesome") @req_body = '{"json_data":"as_a_string"}' @headers = { "Content-type" =>"application/json", diff --git a/spec/unit/rest_spec.rb b/spec/unit/rest_spec.rb index 3ecbbd14b8..ba5f837c07 100644 --- a/spec/unit/rest_spec.rb +++ b/spec/unit/rest_spec.rb @@ -19,10 +19,10 @@ # limitations under the License. # -require 'spec_helper' -require 'uri' -require 'net/https' -require 'stringio' +require "spec_helper" +require "uri" +require "net/https" +require "stringio" SIGNING_KEY_DOT_PEM="-----BEGIN RSA PRIVATE KEY----- MIIEpAIBAAKCAQEA49TA0y81ps0zxkOpmf5V4/c4IeR5yVyQFpX3JpxO4TquwnRh @@ -69,8 +69,8 @@ describe Chef::REST do rest end - let(:standard_read_headers) {{"Accept"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID"=>request_id, 'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}} - let(:standard_write_headers) {{"Accept"=>"application/json", "Content-Type"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID"=>request_id, 'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}} + let(:standard_read_headers) {{"Accept"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID"=>request_id, "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}} + let(:standard_write_headers) {{"Accept"=>"application/json", "Content-Type"=>"application/json", "Accept-Encoding"=>"gzip;q=1.0,deflate;q=0.6,identity;q=0.3", "X-REMOTE-REQUEST-ID"=>request_id, "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION}} before(:each) do Chef::Log.init(log_stringio) @@ -92,7 +92,7 @@ describe Chef::REST do Chef::REST.new(base_url, nil, nil, options) end - context 'when created with a chef zero URL' do + context "when created with a chef zero URL" do let(:url) { "chefzero://localhost:1" } @@ -115,12 +115,12 @@ describe Chef::REST do with(:GET, monkey_uri, standard_read_headers, false). and_return([1,2,3]) expect(rest).to receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3]) - expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true) + expect(rest).to receive("success_response?".to_sym).with(1).and_return(true) rest.get_rest("monkey") end it "makes a :GET reqest for a streaming download with the composed url" do - expect(rest).to receive(:streaming_request).with('monkey', {}) + expect(rest).to receive(:streaming_request).with("monkey", {}) rest.get_rest("monkey", true) end @@ -129,7 +129,7 @@ describe Chef::REST do with(:DELETE, monkey_uri, standard_read_headers, false). and_return([1,2,3]) expect(rest).to receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3]) - expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true) + expect(rest).to receive("success_response?".to_sym).with(1).and_return(true) rest.delete_rest("monkey") end @@ -138,7 +138,7 @@ describe Chef::REST do with(:POST, monkey_uri, standard_write_headers, "\"data\""). and_return([1,2,3]) expect(rest).to receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3]) - expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true) + expect(rest).to receive("success_response?".to_sym).with(1).and_return(true) rest.post_rest("monkey", "data") end @@ -147,7 +147,7 @@ describe Chef::REST do with(:PUT, monkey_uri, standard_write_headers, "\"data\""). and_return([1,2,3]) expect(rest).to receive(:apply_response_middleware).with(1,2,3).and_return([1,2,3]) - expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true) + expect(rest).to receive("success_response?".to_sym).with(1).and_return(true) rest.put_rest("monkey", "data") end end @@ -162,11 +162,11 @@ describe Chef::REST do Chef::Config[:client_key] = CHEF_SPEC_DATA + "/ssl/private_key.pem" end - it 'responds to raw_http_request as a public method' do + it "responds to raw_http_request as a public method" do expect(rest.public_methods.map(&:to_s)).to include("raw_http_request") end - it 'calls the authn middleware' do + it "calls the authn middleware" do data = "\"secure data\"" auth_headers = standard_write_headers.merge({"auth_done"=>"yep"}) @@ -177,18 +177,18 @@ describe Chef::REST do expect(rest).to receive(:send_http_request). with(:POST, monkey_uri, auth_headers, data). and_return([1,2,3]) - expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true) + expect(rest).to receive("success_response?".to_sym).with(1).and_return(true) rest.raw_http_request(:POST, monkey_uri, standard_write_headers, data) end - it 'sets correct authn headers' do + it "sets correct authn headers" do data = "\"secure data\"" method, uri, auth_headers, d = rest.authenticator.handle_request(:POST, monkey_uri, standard_write_headers, data) expect(rest).to receive(:send_http_request). with(:POST, monkey_uri, auth_headers, data). and_return([1,2,3]) - expect(rest).to receive('success_response?'.to_sym).with(1).and_return(true) + expect(rest).to receive("success_response?".to_sym).with(1).and_return(true) rest.raw_http_request(:POST, monkey_uri, standard_write_headers, data) end end @@ -287,12 +287,12 @@ describe Chef::REST do let(:base_headers) do #FIXME: huh? { - 'Accept' => 'application/json', - 'X-Chef-Version' => Chef::VERSION, - 'Accept-Encoding' => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE, - 'Host' => host_header, - 'X-REMOTE-REQUEST-ID' => request_id, - 'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION, + "Accept" => "application/json", + "X-Chef-Version" => Chef::VERSION, + "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE, + "Host" => host_header, + "X-REMOTE-REQUEST-ID" => request_id, + "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION, } end @@ -314,7 +314,7 @@ describe Chef::REST do # XXX: must reset to default b/c knife changes the UA Chef::REST::RESTRequest.user_agent = Chef::REST::RESTRequest::DEFAULT_UA rest.request(:GET, url, {}) - expect(request_mock['User-Agent']).to match(/^Chef Client\/#{Chef::VERSION}/) + expect(request_mock["User-Agent"]).to match(/^Chef Client\/#{Chef::VERSION}/) end # CHEF-3140 @@ -340,8 +340,8 @@ describe Chef::REST do context "when configured with custom http headers" do let(:custom_headers) do { - 'X-Custom-ChefSecret' => 'sharpknives', - 'X-Custom-RequestPriority' => 'extremely low', + "X-Custom-ChefSecret" => "sharpknives", + "X-Custom-RequestPriority" => "extremely low", } end @@ -371,7 +371,7 @@ describe Chef::REST do end it "should set the cookie for this request if one exists for the given host:port" do - expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", base_headers.merge('Cookie' => "cookie monster")).and_return(request_mock) + expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", base_headers.merge("Cookie" => "cookie monster")).and_return(request_mock) rest.request(:GET, url, {}) end end @@ -383,7 +383,7 @@ describe Chef::REST do it "should build a new HTTP POST request" do request = Net::HTTP::Post.new(url.path) - expected_headers = base_headers.merge("Content-Type" => 'application/json', 'Content-Length' => '13') + expected_headers = base_headers.merge("Content-Type" => "application/json", "Content-Length" => "13") expect(Net::HTTP::Post).to receive(:new).with("/?foo=bar", expected_headers).and_return(request) rest.request(:POST, url, {}, {:one=>:two}) @@ -392,7 +392,7 @@ describe Chef::REST do it "should build a new HTTP PUT request" do request = Net::HTTP::Put.new(url.path) - expected_headers = base_headers.merge("Content-Type" => 'application/json', 'Content-Length' => '13') + expected_headers = base_headers.merge("Content-Type" => "application/json", "Content-Length" => "13") expect(Net::HTTP::Put).to receive(:new).with("/?foo=bar",expected_headers).and_return(request) rest.request(:PUT, url, {}, {:one=>:two}) expect(request.body).to eq('{"one":"two"}') @@ -419,12 +419,12 @@ describe Chef::REST do context "when JSON is returned" do let(:body) { '{"ohai2u":"json_api"}' } it "should inflate the body as to an object" do - http_response.add_field('content-type', "application/json") + http_response.add_field("content-type", "application/json") expect(rest.request(:GET, url, {})).to eq({"ohai2u"=>"json_api"}) end it "should fail if the response is truncated" do - http_response.add_field('content-type', "application/json") + http_response.add_field("content-type", "application/json") http_response["Content-Length"] = (body.bytesize + 99).to_s expect { rest.request(:GET, url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch) end @@ -486,7 +486,7 @@ describe Chef::REST do allow(rest).to receive(:sleep) expect {rest.request(:GET, url)}.to raise_error(Net::HTTPFatalError) - expect(log_stringio.string).to match(Regexp.escape('INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four')) + expect(log_stringio.string).to match(Regexp.escape("INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four")) end end @@ -511,7 +511,7 @@ describe Chef::REST do it "decompresses the JSON error message" do expect {rest.request(:GET, url)}.to raise_error(Net::HTTPFatalError) - expect(log_stringio.string).to match(Regexp.escape('INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four')) + expect(log_stringio.string).to match(Regexp.escape("INFO: HTTP Request Returned 500 drooling from inside of mouth: Ears get sore!, Not even four")) end it "fails when the compressed body is truncated" do @@ -544,7 +544,7 @@ describe Chef::REST do let(:request_mock) { {} } let(:http_response) do - http_response = Net::HTTPSuccess.new("1.1",'200', "it-works") + http_response = Net::HTTPSuccess.new("1.1","200", "it-works") allow(http_response).to receive(:read_body) expect(http_response).not_to receive(:body) @@ -570,24 +570,24 @@ describe Chef::REST do end it " build a new HTTP GET request without the application/json accept header" do - expected_headers = {'Accept' => "*/*", - 'X-Chef-Version' => Chef::VERSION, - 'Accept-Encoding' => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE, - 'Host' => host_header, - 'X-REMOTE-REQUEST-ID'=> request_id, - 'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION, + expected_headers = {"Accept" => "*/*", + "X-Chef-Version" => Chef::VERSION, + "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE, + "Host" => host_header, + "X-REMOTE-REQUEST-ID"=> request_id, + "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION, } expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", expected_headers).and_return(request_mock) rest.streaming_request(url, {}) end it "build a new HTTP GET request with the X-Remote-Request-Id header" do - expected_headers = {'Accept' => "*/*", - 'X-Chef-Version' => Chef::VERSION, - 'Accept-Encoding' => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE, - 'Host' => host_header, - 'X-REMOTE-REQUEST-ID'=> request_id, - 'X-Ops-Server-API-Version' => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION, + expected_headers = {"Accept" => "*/*", + "X-Chef-Version" => Chef::VERSION, + "Accept-Encoding" => Chef::REST::RESTRequest::ENCODING_GZIP_DEFLATE, + "Host" => host_header, + "X-REMOTE-REQUEST-ID"=> request_id, + "X-Ops-Server-API-Version" => Chef::HTTP::Authenticator::DEFAULT_SERVER_API_VERSION, } expect(Net::HTTP::Get).to receive(:new).with("/?foo=bar", expected_headers).and_return(request_mock) rest.streaming_request(url, {}) @@ -622,13 +622,13 @@ describe Chef::REST do end it "does not raise a divide by zero exception if the content's actual size is 0" do - http_response['Content-Length'] = "5" - allow(http_response).to receive(:read_body).and_yield('') + http_response["Content-Length"] = "5" + allow(http_response).to receive(:read_body).and_yield("") expect { rest.streaming_request(url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch) end it "does not raise a divide by zero exception when the Content-Length is 0" do - http_response['Content-Length'] = "0" + http_response["Content-Length"] = "0" allow(http_response).to receive(:read_body).and_yield("ninja") expect { rest.streaming_request(url, {}) }.to raise_error(Chef::Exceptions::ContentLengthMismatch) end diff --git a/spec/unit/role_spec.rb b/spec/unit/role_spec.rb index 6e9b133c50..a48137d28a 100644 --- a/spec/unit/role_spec.rb +++ b/spec/unit/role_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/role' +require "spec_helper" +require "chef/role" describe Chef::Role do before(:each) do @@ -108,12 +108,12 @@ describe Chef::Role do describe "default_attributes" do it "should let you set the default attributes hash explicitly" do - expect(@role.default_attributes({ :one => 'two' })).to eq({ :one => 'two' }) + expect(@role.default_attributes({ :one => "two" })).to eq({ :one => "two" }) end it "should let you return the default attributes hash" do - @role.default_attributes({ :one => 'two' }) - expect(@role.default_attributes).to eq({ :one => 'two' }) + @role.default_attributes({ :one => "two" }) + expect(@role.default_attributes).to eq({ :one => "two" }) end it "should throw an ArgumentError if we aren't a kind of hash" do @@ -123,12 +123,12 @@ describe Chef::Role do describe "override_attributes" do it "should let you set the override attributes hash explicitly" do - expect(@role.override_attributes({ :one => 'two' })).to eq({ :one => 'two' }) + expect(@role.override_attributes({ :one => "two" })).to eq({ :one => "two" }) end it "should let you return the override attributes hash" do - @role.override_attributes({ :one => 'two' }) - expect(@role.override_attributes).to eq({ :one => 'two' }) + @role.override_attributes({ :one => "two" }) + expect(@role.override_attributes).to eq({ :one => "two" }) end it "should throw an ArgumentError if we aren't a kind of hash" do @@ -138,18 +138,18 @@ describe Chef::Role do describe "update_from!" do before(:each) do - @role.name('mars_volta') - @role.description('Great band!') - @role.run_list('one', 'two', 'role[a]') - @role.default_attributes({ :el_groupo => 'nuevo' }) - @role.override_attributes({ :deloused => 'in the comatorium' }) + @role.name("mars_volta") + @role.description("Great band!") + @role.run_list("one", "two", "role[a]") + @role.default_attributes({ :el_groupo => "nuevo" }) + @role.override_attributes({ :deloused => "in the comatorium" }) @example = Chef::Role.new - @example.name('newname') - @example.description('Really Great band!') - @example.run_list('alpha', 'bravo', 'role[alpha]') - @example.default_attributes({ :el_groupo => 'nuevo dos' }) - @example.override_attributes({ :deloused => 'in the comatorium XOXO' }) + @example.name("newname") + @example.description("Really Great band!") + @example.run_list("alpha", "bravo", "role[alpha]") + @example.default_attributes({ :el_groupo => "nuevo dos" }) + @example.override_attributes({ :deloused => "in the comatorium XOXO" }) end it "should update all fields except for name" do @@ -164,11 +164,11 @@ describe Chef::Role do describe "when serialized as JSON", :json => true do before(:each) do - @role.name('mars_volta') - @role.description('Great band!') - @role.run_list('one', 'two', 'role[a]') - @role.default_attributes({ :el_groupo => 'nuevo' }) - @role.override_attributes({ :deloused => 'in the comatorium' }) + @role.name("mars_volta") + @role.description("Great band!") + @role.run_list("one", "two", "role[a]") + @role.default_attributes({ :el_groupo => "nuevo" }) + @role.override_attributes({ :deloused => "in the comatorium" }) @serialized_role = Chef::JSONCompat.to_json(@role) end @@ -200,14 +200,14 @@ describe Chef::Role do describe "and it has per-environment run lists" do before do - @role.env_run_lists("_default" => ['one', 'two', 'role[a]'], "production" => ['role[monitoring]', 'role[auditing]', 'role[apache]'], "dev" => ["role[nginx]"]) + @role.env_run_lists("_default" => ["one", "two", "role[a]"], "production" => ["role[monitoring]", "role[auditing]", "role[apache]"], "dev" => ["role[nginx]"]) @serialized_role = Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@role), :create_additions => false) end it "includes the per-environment run lists" do #Activesupport messes with Chef json formatting #This test should pass with and without activesupport - expect(@serialized_role["env_run_lists"]["production"]).to eq(['role[monitoring]', 'role[auditing]', 'role[apache]']) + expect(@serialized_role["env_run_lists"]["production"]).to eq(["role[monitoring]", "role[auditing]", "role[apache]"]) expect(@serialized_role["env_run_lists"]["dev"]).to eq(["role[nginx]"]) end @@ -224,11 +224,11 @@ describe Chef::Role do describe "when created from JSON", :json => true do before(:each) do - @role.name('mars_volta') - @role.description('Great band!') - @role.run_list('one', 'two', 'role[a]') - @role.default_attributes({ 'el_groupo' => 'nuevo' }) - @role.override_attributes({ 'deloused' => 'in the comatorium' }) + @role.name("mars_volta") + @role.description("Great band!") + @role.run_list("one", "two", "role[a]") + @role.default_attributes({ "el_groupo" => "nuevo" }) + @role.override_attributes({ "deloused" => "in the comatorium" }) @deserial = Chef::Role.from_hash(Chef::JSONCompat.parse(Chef::JSONCompat.to_json(@role))) end @@ -256,13 +256,13 @@ EOR describe "when loading from disk" do before do - default_cache_path = windows? ? 'C:\chef' : '/var/chef' + default_cache_path = windows? ? 'C:\chef' : "/var/chef" allow(Chef::Config).to receive(:cache_path).and_return(default_cache_path) end it "should return a Chef::Role object from JSON" do expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.json"]) - file_path = File.join(Chef::Config[:role_path], 'memes/lolcat.json') + file_path = File.join(Chef::Config[:role_path], "memes/lolcat.json") expect(File).to receive(:exists?).with(file_path).exactly(1).times.and_return(true) expect(IO).to receive(:read).with(file_path).and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }') expect(@role).to be_a_kind_of(Chef::Role) @@ -271,7 +271,7 @@ EOR it "should return a Chef::Role object from a Ruby DSL" do expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.rb"]) - rb_path = File.join(Chef::Config[:role_path], 'memes/lolcat.rb') + rb_path = File.join(Chef::Config[:role_path], "memes/lolcat.rb") expect(File).to receive(:exists?).with(rb_path).exactly(2).times.and_return(true) expect(File).to receive(:readable?).with(rb_path).exactly(1).times.and_return(true) expect(IO).to receive(:read).with(rb_path).and_return(ROLE_DSL) @@ -281,8 +281,8 @@ EOR it "should prefer a Chef::Role Object from JSON over one from a Ruby DSL" do expect(Dir).to receive(:glob).and_return(["#{Chef::Config[:role_path]}/memes", "#{Chef::Config[:role_path]}/memes/lolcat.json", "#{Chef::Config[:role_path]}/memes/lolcat.rb"]) - js_path = File.join(Chef::Config[:role_path], 'memes/lolcat.json') - rb_path = File.join(Chef::Config[:role_path], 'memes/lolcat.rb') + js_path = File.join(Chef::Config[:role_path], "memes/lolcat.json") + rb_path = File.join(Chef::Config[:role_path], "memes/lolcat.rb") expect(File).to receive(:exists?).with(js_path).exactly(1).times.and_return(true) expect(File).not_to receive(:exists?).with(rb_path) expect(IO).to receive(:read).with(js_path).and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }') @@ -313,48 +313,48 @@ EOR describe "when loading from disk and role_path is an array" do before(:each) do - Chef::Config[:role_path] = ['/path1', '/path/path2'] + Chef::Config[:role_path] = ["/path1", "/path/path2"] end it "should return a Chef::Role object from JSON" do - expect(Dir).to receive(:glob).with(File.join('/path1', '**', '**')).exactly(1).times.and_return(['/path1/lolcat.json']) - expect(File).to receive(:exists?).with('/path1/lolcat.json').exactly(1).times.and_return(true) - expect(IO).to receive(:read).with('/path1/lolcat.json').and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }') + expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return(["/path1/lolcat.json"]) + expect(File).to receive(:exists?).with("/path1/lolcat.json").exactly(1).times.and_return(true) + expect(IO).to receive(:read).with("/path1/lolcat.json").and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }') expect(@role).to be_a_kind_of(Chef::Role) @role.class.from_disk("lolcat") end it "should return a Chef::Role object from JSON when role is in the second path" do - expect(Dir).to receive(:glob).with(File.join('/path1', '**', '**')).exactly(1).times.and_return([]) - expect(Dir).to receive(:glob).with(File.join('/path/path2', '**', '**')).exactly(1).times.and_return(['/path/path2/lolcat.json']) - expect(File).to receive(:exists?).with('/path/path2/lolcat.json').exactly(1).times.and_return(true) - expect(IO).to receive(:read).with('/path/path2/lolcat.json').and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }') + expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return([]) + expect(Dir).to receive(:glob).with(File.join("/path/path2", "**", "**")).exactly(1).times.and_return(["/path/path2/lolcat.json"]) + expect(File).to receive(:exists?).with("/path/path2/lolcat.json").exactly(1).times.and_return(true) + expect(IO).to receive(:read).with("/path/path2/lolcat.json").and_return('{"name": "ceiling_cat", "json_class": "Chef::Role" }') expect(@role).to be_a_kind_of(Chef::Role) @role.class.from_disk("lolcat") end it "should return a Chef::Role object from a Ruby DSL" do - expect(Dir).to receive(:glob).with(File.join('/path1', '**', '**')).exactly(1).times.and_return(['/path1/lolcat.rb']) - expect(File).to receive(:exists?).with('/path1/lolcat.rb').exactly(2).times.and_return(true) - expect(File).to receive(:readable?).with('/path1/lolcat.rb').and_return(true) - expect(IO).to receive(:read).with('/path1/lolcat.rb').exactly(1).times.and_return(ROLE_DSL) + expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return(["/path1/lolcat.rb"]) + expect(File).to receive(:exists?).with("/path1/lolcat.rb").exactly(2).times.and_return(true) + expect(File).to receive(:readable?).with("/path1/lolcat.rb").and_return(true) + expect(IO).to receive(:read).with("/path1/lolcat.rb").exactly(1).times.and_return(ROLE_DSL) expect(@role).to be_a_kind_of(Chef::Role) @role.class.from_disk("lolcat") end it "should return a Chef::Role object from a Ruby DSL when role is in the second path" do - expect(Dir).to receive(:glob).with(File.join('/path1', '**', '**')).exactly(1).times.and_return([]) - expect(Dir).to receive(:glob).with(File.join('/path/path2', '**', '**')).exactly(1).times.and_return(['/path/path2/lolcat.rb']) - expect(File).to receive(:exists?).with('/path/path2/lolcat.rb').exactly(2).times.and_return(true) - expect(File).to receive(:readable?).with('/path/path2/lolcat.rb').and_return(true) - expect(IO).to receive(:read).with('/path/path2/lolcat.rb').exactly(1).times.and_return(ROLE_DSL) + expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return([]) + expect(Dir).to receive(:glob).with(File.join("/path/path2", "**", "**")).exactly(1).times.and_return(["/path/path2/lolcat.rb"]) + expect(File).to receive(:exists?).with("/path/path2/lolcat.rb").exactly(2).times.and_return(true) + expect(File).to receive(:readable?).with("/path/path2/lolcat.rb").and_return(true) + expect(IO).to receive(:read).with("/path/path2/lolcat.rb").exactly(1).times.and_return(ROLE_DSL) expect(@role).to be_a_kind_of(Chef::Role) @role.class.from_disk("lolcat") end it "should raise an exception if the file does not exist" do - expect(Dir).to receive(:glob).with(File.join('/path1', '**', '**')).exactly(1).times.and_return([]) - expect(Dir).to receive(:glob).with(File.join('/path/path2', '**', '**')).exactly(1).times.and_return([]) + expect(Dir).to receive(:glob).with(File.join("/path1", "**", "**")).exactly(1).times.and_return([]) + expect(Dir).to receive(:glob).with(File.join("/path/path2", "**", "**")).exactly(1).times.and_return([]) expect {@role.class.from_disk("lolcat")}.to raise_error(Chef::Exceptions::RoleNotFound) end diff --git a/spec/unit/run_context/child_run_context_spec.rb b/spec/unit/run_context/child_run_context_spec.rb index 63586e459c..3654125a79 100644 --- a/spec/unit/run_context/child_run_context_spec.rb +++ b/spec/unit/run_context/child_run_context_spec.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/lib/library_load_order' +require "spec_helper" +require "support/lib/library_load_order" describe Chef::RunContext::ChildRunContext do context "with a run context with stuff in it" do @@ -46,14 +46,14 @@ describe Chef::RunContext::ChildRunContext do it "audits is not the same as the parent" do expect(child.audits.object_id).not_to eq run_context.audits.object_id - child.audits['hi'] = 'lo' - expect(child.audits['hi']).to eq('lo') - expect(run_context.audits['hi']).not_to eq('lo') + child.audits["hi"] = "lo" + expect(child.audits["hi"]).to eq("lo") + expect(run_context.audits["hi"]).not_to eq("lo") end it "resource_collection is not the same as the parent" do expect(child.resource_collection.object_id).not_to eq run_context.resource_collection.object_id - f = Chef::Resource::File.new('hi', child) + f = Chef::Resource::File.new("hi", child) child.resource_collection.insert(f) expect(child.resource_collection).to include f expect(run_context.resource_collection).not_to include f @@ -61,17 +61,17 @@ describe Chef::RunContext::ChildRunContext do it "immediate_notification_collection is not the same as the parent" do expect(child.immediate_notification_collection.object_id).not_to eq run_context.immediate_notification_collection.object_id - src = Chef::Resource::File.new('hi', child) - dest = Chef::Resource::File.new('argh', child) + src = Chef::Resource::File.new("hi", child) + dest = Chef::Resource::File.new("argh", child) notification = Chef::Resource::Notification.new(dest, :create, src) child.notifies_immediately(notification) - expect(child.immediate_notification_collection['file[hi]']).to eq([notification]) - expect(run_context.immediate_notification_collection['file[hi]']).not_to eq([notification]) + expect(child.immediate_notification_collection["file[hi]"]).to eq([notification]) + expect(run_context.immediate_notification_collection["file[hi]"]).not_to eq([notification]) end it "immediate_notifications is not the same as the parent" do - src = Chef::Resource::File.new('hi', child) - dest = Chef::Resource::File.new('argh', child) + src = Chef::Resource::File.new("hi", child) + dest = Chef::Resource::File.new("argh", child) notification = Chef::Resource::Notification.new(dest, :create, src) child.notifies_immediately(notification) expect(child.immediate_notifications(src)).to eq([notification]) @@ -80,17 +80,17 @@ describe Chef::RunContext::ChildRunContext do it "delayed_notification_collection is not the same as the parent" do expect(child.delayed_notification_collection.object_id).not_to eq run_context.delayed_notification_collection.object_id - src = Chef::Resource::File.new('hi', child) - dest = Chef::Resource::File.new('argh', child) + src = Chef::Resource::File.new("hi", child) + dest = Chef::Resource::File.new("argh", child) notification = Chef::Resource::Notification.new(dest, :create, src) child.notifies_delayed(notification) - expect(child.delayed_notification_collection['file[hi]']).to eq([notification]) - expect(run_context.delayed_notification_collection['file[hi]']).not_to eq([notification]) + expect(child.delayed_notification_collection["file[hi]"]).to eq([notification]) + expect(run_context.delayed_notification_collection["file[hi]"]).not_to eq([notification]) end it "delayed_notifications is not the same as the parent" do - src = Chef::Resource::File.new('hi', child) - dest = Chef::Resource::File.new('argh', child) + src = Chef::Resource::File.new("hi", child) + dest = Chef::Resource::File.new("argh", child) notification = Chef::Resource::Notification.new(dest, :create, src) child.notifies_delayed(notification) expect(child.delayed_notifications(src)).to eq([notification]) @@ -104,7 +104,7 @@ describe Chef::RunContext::ChildRunContext do context "after load('include::default')" do before do - run_list = Chef::RunList.new('include::default').expand('_default') + run_list = Chef::RunList.new("include::default").expand("_default") # TODO not sure why we had to do this to get everything to work ... node.automatic_attrs[:recipes] = [] child.load(run_list) diff --git a/spec/unit/run_context/cookbook_compiler_spec.rb b/spec/unit/run_context/cookbook_compiler_spec.rb index 20ec1d2ef7..43d14addb8 100644 --- a/spec/unit/run_context/cookbook_compiler_spec.rb +++ b/spec/unit/run_context/cookbook_compiler_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/lib/library_load_order' +require "spec_helper" +require "support/lib/library_load_order" # These tests rely on fixture data in spec/data/run_context/cookbooks. # @@ -45,7 +45,7 @@ describe Chef::RunContext::CookbookCompiler do let(:cookbook_collection) { Chef::CookbookCollection.new(cookbook_loader) } # Lazy evaluation of `expansion` here is used to mutate the run list before expanding it - let(:run_list_expansion) { node.run_list.expand('_default') } + let(:run_list_expansion) { node.run_list.expand("_default") } let(:compiler) do Chef::RunContext::CookbookCompiler.new(run_context, run_list_expansion, events) diff --git a/spec/unit/run_context_spec.rb b/spec/unit/run_context_spec.rb index efc2a6f63f..ca45ca415f 100644 --- a/spec/unit/run_context_spec.rb +++ b/spec/unit/run_context_spec.rb @@ -18,8 +18,8 @@ # limitations under the License. # -require 'spec_helper' -require 'support/lib/library_load_order' +require "spec_helper" +require "support/lib/library_load_order" describe Chef::RunContext do let(:chef_repo_path) { File.expand_path(File.join(CHEF_SPEC_DATA, "run_context", "cookbooks")) } @@ -104,7 +104,7 @@ describe Chef::RunContext do expect(node).to receive(:loaded_recipe).with(:test, "default") expect(node).to receive(:loaded_recipe).with(:test, "one") expect(node).to receive(:loaded_recipe).with(:test, "two") - run_context.load(node.run_list.expand('_default')) + run_context.load(node.run_list.expand("_default")) end it "should load all the definitions in the cookbooks for this node" do diff --git a/spec/unit/run_list/run_list_expansion_spec.rb b/spec/unit/run_list/run_list_expansion_spec.rb index a7df9e749b..1e509ac4d5 100644 --- a/spec/unit/run_list/run_list_expansion_spec.rb +++ b/spec/unit/run_list/run_list_expansion_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::RunList::RunListExpansion do before do @run_list = Chef::RunList.new - @run_list << 'recipe[lobster::mastercookbook@0.1.0]' << 'role[rage]' << 'recipe[fist@0.1]' + @run_list << "recipe[lobster::mastercookbook@0.1.0]" << "role[rage]" << "recipe[fist@0.1]" @expansion = Chef::RunList::RunListExpansion.new("_default", @run_list.run_list_items) end @@ -43,7 +43,7 @@ describe Chef::RunList::RunListExpansion do end it "has not applied its roles" do - expect(@expansion.applied_role?('rage')).to be_falsey + expect(@expansion.applied_role?("rage")).to be_falsey end end @@ -51,7 +51,7 @@ describe Chef::RunList::RunListExpansion do before do @rage_role = Chef::Role.new.tap do |r| r.name("rage") - r.env_run_lists('_default' => [], "prod" => ["recipe[prod-only]"]) + r.env_run_lists("_default" => [], "prod" => ["recipe[prod-only]"]) end @expansion = Chef::RunList::RunListExpansion.new("prod", @run_list.run_list_items) expect(@expansion).to receive(:fetch_role).and_return(@rage_role) @@ -67,30 +67,30 @@ describe Chef::RunList::RunListExpansion do describe "after applying a role" do before do allow(@expansion).to receive(:fetch_role).and_return(Chef::Role.new) - @expansion.inflate_role('rage', "role[base]") + @expansion.inflate_role("rage", "role[base]") end it "tracks the applied role" do - expect(@expansion.applied_role?('rage')).to be_truthy + expect(@expansion.applied_role?("rage")).to be_truthy end it "does not inflate the role again" do - expect(@expansion.inflate_role('rage', "role[base]")).to be_falsey + expect(@expansion.inflate_role("rage", "role[base]")).to be_falsey end end describe "after expanding a run list" do before do @first_role = Chef::Role.new - @first_role.name('rage') - @first_role.run_list('role[mollusk]') - @first_role.default_attributes({'foo' => 'bar'}) - @first_role.override_attributes({'baz' => 'qux'}) + @first_role.name("rage") + @first_role.run_list("role[mollusk]") + @first_role.default_attributes({"foo" => "bar"}) + @first_role.override_attributes({"baz" => "qux"}) @second_role = Chef::Role.new - @second_role.name('rage') - @second_role.run_list('recipe[crabrevenge]') - @second_role.default_attributes({'foo' => 'boo'}) - @second_role.override_attributes({'baz' => 'bux'}) + @second_role.name("rage") + @second_role.run_list("recipe[crabrevenge]") + @second_role.default_attributes({"foo" => "boo"}) + @second_role.override_attributes({"baz" => "bux"}) allow(@expansion).to receive(:fetch_role).and_return(@first_role, @second_role) @expansion.expand @json = '{"id":"_default","run_list":[{"type":"recipe","name":"lobster::mastercookbook","version":"0.1.0",' @@ -109,24 +109,24 @@ describe Chef::RunList::RunListExpansion do end it "has the ordered list of recipes" do - expect(@expansion.recipes).to eq(['lobster::mastercookbook', 'crabrevenge', 'fist']) + expect(@expansion.recipes).to eq(["lobster::mastercookbook", "crabrevenge", "fist"]) end it "has the merged attributes from the roles with outer roles overriding inner" do - expect(@expansion.default_attrs).to eq({'foo' => 'bar'}) - expect(@expansion.override_attrs).to eq({'baz' => 'qux'}) + expect(@expansion.default_attrs).to eq({"foo" => "bar"}) + expect(@expansion.override_attrs).to eq({"baz" => "qux"}) end it "has the list of all roles applied" do # this is the correct order, but 1.8 hash order is not stable - expect(@expansion.roles).to match_array(['rage', 'mollusk']) + expect(@expansion.roles).to match_array(["rage", "mollusk"]) end end describe "after expanding a run list with a non existent role" do before do - allow(@expansion).to receive(:fetch_role) { @expansion.role_not_found('crabrevenge', "role[base]") } + allow(@expansion).to receive(:fetch_role) { @expansion.role_not_found("crabrevenge", "role[base]") } @expansion.expand end @@ -136,7 +136,7 @@ describe Chef::RunList::RunListExpansion do end it "has a list of invalid role names" do - expect(@expansion.errors).to include('crabrevenge') + expect(@expansion.errors).to include("crabrevenge") end end diff --git a/spec/unit/run_list/run_list_item_spec.rb b/spec/unit/run_list/run_list_item_spec.rb index 16832c1b7d..c69ca8f220 100644 --- a/spec/unit/run_list/run_list_item_spec.rb +++ b/spec/unit/run_list/run_list_item_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::RunList::RunListItem do @@ -26,12 +26,12 @@ describe Chef::RunList::RunListItem do end it "raises an exception when the hash doesn't have an :name key" do - expect {Chef::RunList::RunListItem.new(:type => 'R') }.to raise_error(ArgumentError) + expect {Chef::RunList::RunListItem.new(:type => "R") }.to raise_error(ArgumentError) end it "sets the name and type as given in the hash" do - item = Chef::RunList::RunListItem.new(:type => 'fuuu', :name => 'uuuu') - expect(item.to_s).to eq('fuuu[uuuu]') + item = Chef::RunList::RunListItem.new(:type => "fuuu", :name => "uuuu") + expect(item.to_s).to eq("fuuu[uuuu]") end end @@ -41,33 +41,33 @@ describe Chef::RunList::RunListItem do item = Chef::RunList::RunListItem.new("recipe[rage]") expect(item).to be_a_recipe expect(item).not_to be_a_role - expect(item.to_s).to eq('recipe[rage]') - expect(item.name).to eq('rage') + expect(item.to_s).to eq("recipe[rage]") + expect(item.name).to eq("rage") end it "parses a qualified recipe with a version" do item = Chef::RunList::RunListItem.new("recipe[rage@0.1.0]") expect(item).to be_a_recipe expect(item).not_to be_a_role - expect(item.to_s).to eq('recipe[rage@0.1.0]') - expect(item.name).to eq('rage') - expect(item.version).to eq('0.1.0') + expect(item.to_s).to eq("recipe[rage@0.1.0]") + expect(item.name).to eq("rage") + expect(item.version).to eq("0.1.0") end it "parses a qualified role" do item = Chef::RunList::RunListItem.new("role[fist]") expect(item).to be_a_role expect(item).not_to be_a_recipe - expect(item.to_s).to eq('role[fist]') - expect(item.name).to eq('fist') + expect(item.to_s).to eq("role[fist]") + expect(item.name).to eq("fist") end it "parses an unqualified recipe" do item = Chef::RunList::RunListItem.new("lobster") expect(item).to be_a_recipe expect(item).not_to be_a_role - expect(item.to_s).to eq('recipe[lobster]') - expect(item.name).to eq('lobster') + expect(item.to_s).to eq("recipe[lobster]") + expect(item.name).to eq("lobster") end it "raises an exception when the string has typo on the type part" do @@ -85,33 +85,33 @@ describe Chef::RunList::RunListItem do describe "comparing to other run list items" do it "is equal to another run list item that has the same name and type" do - item1 = Chef::RunList::RunListItem.new('recipe[lrf]') - item2 = Chef::RunList::RunListItem.new('recipe[lrf]') + item1 = Chef::RunList::RunListItem.new("recipe[lrf]") + item2 = Chef::RunList::RunListItem.new("recipe[lrf]") expect(item1).to eq(item2) end it "is not equal to another run list item with the same name and different type" do - item1 = Chef::RunList::RunListItem.new('recipe[lrf]') - item2 = Chef::RunList::RunListItem.new('role[lrf]') + item1 = Chef::RunList::RunListItem.new("recipe[lrf]") + item2 = Chef::RunList::RunListItem.new("role[lrf]") expect(item1).not_to eq(item2) end it "is not equal to another run list item with the same type and different name" do - item1 = Chef::RunList::RunListItem.new('recipe[lrf]') - item2 = Chef::RunList::RunListItem.new('recipe[lobsterragefist]') + item1 = Chef::RunList::RunListItem.new("recipe[lrf]") + item2 = Chef::RunList::RunListItem.new("recipe[lobsterragefist]") expect(item1).not_to eq(item2) end it "is not equal to another run list item with the same name and type but different version" do - item1 = Chef::RunList::RunListItem.new('recipe[lrf,0.1.0]') - item2 = Chef::RunList::RunListItem.new('recipe[lrf,0.2.0]') + item1 = Chef::RunList::RunListItem.new("recipe[lrf,0.1.0]") + item2 = Chef::RunList::RunListItem.new("recipe[lrf,0.2.0]") expect(item1).not_to eq(item2) end end describe "comparing to strings" do it "is equal to a string if that string matches its to_s representation" do - expect(Chef::RunList::RunListItem.new('recipe[lrf]')).to eq('recipe[lrf]') + expect(Chef::RunList::RunListItem.new("recipe[lrf]")).to eq("recipe[lrf]") end end end diff --git a/spec/unit/run_list/versioned_recipe_list_spec.rb b/spec/unit/run_list/versioned_recipe_list_spec.rb index 356b9d682c..e1927f8310 100644 --- a/spec/unit/run_list/versioned_recipe_list_spec.rb +++ b/spec/unit/run_list/versioned_recipe_list_spec.rb @@ -15,7 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" describe Chef::RunList::VersionedRecipeList do diff --git a/spec/unit/run_list_spec.rb b/spec/unit/run_list_spec.rb index 634b5c54cf..da5bcf83cb 100644 --- a/spec/unit/run_list_spec.rb +++ b/spec/unit/run_list_spec.rb @@ -18,10 +18,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/version_class' -require 'chef/version_constraint' +require "chef/version_class" +require "chef/version_constraint" describe Chef::RunList do before(:each) do @@ -30,21 +30,21 @@ describe Chef::RunList do describe "<<" do it "should add a recipe to the run list and recipe list with the fully qualified name" do - @run_list << 'recipe[needy]' - expect(@run_list).to include('recipe[needy]') + @run_list << "recipe[needy]" + expect(@run_list).to include("recipe[needy]") expect(@run_list.recipes).to include("needy") end it "should add a role to the run list and role list with the fully qualified name" do @run_list << "role[woot]" - expect(@run_list).to include('role[woot]') - expect(@run_list.roles).to include('woot') + expect(@run_list).to include("role[woot]") + expect(@run_list.roles).to include("woot") end it "should accept recipes that are unqualified" do @run_list << "needy" - expect(@run_list).to include('recipe[needy]') - expect(@run_list.recipes.include?('needy')).to eq(true) + expect(@run_list).to include("recipe[needy]") + expect(@run_list.recipes.include?("needy")).to eq(true) end it "should not allow duplicates" do @@ -59,7 +59,7 @@ describe Chef::RunList do @run_list << "recipe[needy@0.1.0]" expect(@run_list.run_list.length).to eq(2) expect(@run_list.recipes.length).to eq(2) - expect(@run_list.recipes.include?('needy')).to eq(true) + expect(@run_list.recipes.include?("needy")).to eq(true) end it "should not allow duplicate versions of a recipe" do @@ -74,13 +74,13 @@ describe Chef::RunList do # Testing only the basic functionality here # since full behavior is tested above. it "should add a recipe to the run_list" do - @run_list.add 'recipe[needy]' - expect(@run_list).to include('recipe[needy]') + @run_list.add "recipe[needy]" + expect(@run_list).to include("recipe[needy]") end it "should add a role to the run_list" do - @run_list.add 'role[needy]' - expect(@run_list).to include('role[needy]') + @run_list.add "role[needy]" + expect(@run_list).to include("role[needy]") end end @@ -112,20 +112,20 @@ describe Chef::RunList do describe "[]" do it "should let you look up a member in the run list by position" do - @run_list << 'recipe[loulou]' - expect(@run_list[0]).to eq('recipe[loulou]') + @run_list << "recipe[loulou]" + expect(@run_list[0]).to eq("recipe[loulou]") end end describe "[]=" do it "should let you set a member of the run list by position" do - @run_list[0] = 'recipe[loulou]' - expect(@run_list[0]).to eq('recipe[loulou]') + @run_list[0] = "recipe[loulou]" + expect(@run_list[0]).to eq("recipe[loulou]") end it "should properly expand a member of the run list given by position" do - @run_list[0] = 'loulou' - expect(@run_list[0]).to eq('recipe[loulou]') + @run_list[0] = "loulou" + expect(@run_list[0]).to eq("recipe[loulou]") end end @@ -199,7 +199,7 @@ describe Chef::RunList do it "should load the role from the chef server" do #@rest.should_receive(:get).with("roles/stubby") expansion = @run_list.expand("_default", "server") - expect(expansion.recipes).to eq(['one', 'two', 'kitty']) + expect(expansion.recipes).to eq(["one", "two", "kitty"]) end it "should default to expanding from the server" do @@ -270,7 +270,7 @@ describe Chef::RunList do allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role) allow(Chef::Role).to receive(:from_disk).with("dog").and_return(dog) - expansion = @run_list.expand("_default", 'disk') + expansion = @run_list.expand("_default", "disk") expect(expansion.recipes[2]).to eq("three") expect(expansion.default_attrs[:seven]).to eq(:nine) end @@ -284,7 +284,7 @@ describe Chef::RunList do allow(Chef::Role).to receive(:from_disk).with("stubby").and_return(@role) expect(Chef::Role).to receive(:from_disk).with("dog").once.and_return(dog) - expansion = @run_list.expand("_default", 'disk') + expansion = @run_list.expand("_default", "disk") expect(expansion.recipes[2]).to eq("three") expect(expansion.recipes[3]).to eq("kitty") expect(expansion.default_attrs[:seven]).to eq(:nine) diff --git a/spec/unit/run_lock_spec.rb b/spec/unit/run_lock_spec.rb index 51e6ba1b84..7b474919e9 100644 --- a/spec/unit/run_lock_spec.rb +++ b/spec/unit/run_lock_spec.rb @@ -15,13 +15,13 @@ # 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 - default_cache_path = windows? ? 'C:\chef' : '/var/chef' - default_pid_location = windows? ? 'C:\chef\cache\chef-client-running.pid' : '/var/chef/cache/chef-client-running.pid' + default_cache_path = windows? ? 'C:\chef' : "/var/chef" + default_pid_location = windows? ? 'C:\chef\cache\chef-client-running.pid' : "/var/chef/cache/chef-client-running.pid" describe "when first created" do it "locates the lockfile in the file cache path by default" do diff --git a/spec/unit/run_status_spec.rb b/spec/unit/run_status_spec.rb index d658cb5a5a..970635cc0d 100644 --- a/spec/unit/run_status_spec.rb +++ b/spec/unit/run_status_spec.rb @@ -17,7 +17,7 @@ # -require 'spec_helper' +require "spec_helper" describe Chef::RunStatus do before do @@ -82,7 +82,7 @@ describe Chef::RunStatus do describe "with resources in the resource_collection" do before do - @all_resources = [Chef::Resource::Cat.new("whiskers"), Chef::Resource::ZenMaster.new('dtz')] + @all_resources = [Chef::Resource::Cat.new("whiskers"), Chef::Resource::ZenMaster.new("dtz")] @run_context.resource_collection.all_resources.replace(@all_resources) end diff --git a/spec/unit/runner_spec.rb b/spec/unit/runner_spec.rb index 46074728c2..44c40463ee 100644 --- a/spec/unit/runner_spec.rb +++ b/spec/unit/runner_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" class SnitchyProvider < Chef::Provider def self.all_actions_called diff --git a/spec/unit/scan_access_control_spec.rb b/spec/unit/scan_access_control_spec.rb index 8cf681e994..02928851b1 100644 --- a/spec/unit/scan_access_control_spec.rb +++ b/spec/unit/scan_access_control_spec.rb @@ -16,7 +16,7 @@ # require File.expand_path("../../spec_helper", __FILE__) -require 'chef/scan_access_control' +require "chef/scan_access_control" describe Chef::ScanAccessControl do @@ -33,7 +33,7 @@ describe Chef::ScanAccessControl do @new_resource.tap do |f| f.owner("root") f.group("root") - f.mode('0755') + f.mode("0755") end @scanner.set_all! end diff --git a/spec/unit/search/query_spec.rb b/spec/unit/search/query_spec.rb index d54e8b5391..84ac0c661f 100644 --- a/spec/unit/search/query_spec.rb +++ b/spec/unit/search/query_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'chef/search/query' +require "spec_helper" +require "chef/search/query" describe Chef::Search::Query do let(:rest) { double("Chef::ServerAPI") } @@ -29,8 +29,8 @@ describe Chef::Search::Query do let(:args) { { filter_key => filter_hash } } let(:filter_hash) { { - 'env' => [ 'chef_environment' ], - 'ruby_plat' => [ 'languages', 'ruby', 'platform' ], + "env" => [ "chef_environment" ], + "ruby_plat" => [ "languages", "ruby", "platform" ], } } let(:response) { @@ -251,12 +251,12 @@ describe Chef::Search::Query do it "returns start" do start = query.search(:node, "platform:rhel", args)[1] - expect(start).to eq(response['start']) + expect(start).to eq(response["start"]) end it "returns total" do total = query.search(:node, "platform:rhel", args)[2] - expect(total).to eq(response['total']) + expect(total).to eq(response["total"]) end it "returns rows with the filter applied" do diff --git a/spec/unit/shell/model_wrapper_spec.rb b/spec/unit/shell/model_wrapper_spec.rb index d6da2dcffc..d4a0b6df09 100644 --- a/spec/unit/shell/model_wrapper_spec.rb +++ b/spec/unit/shell/model_wrapper_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'ostruct' +require "spec_helper" +require "ostruct" describe Shell::ModelWrapper do before do @@ -81,14 +81,14 @@ describe Shell::ModelWrapper do end it "searches for objects using the given query string" do - expect(@searcher).to receive(:search).with(:node, 'name:app*').and_yield(@node_1).and_yield(@node_2) + expect(@searcher).to receive(:search).with(:node, "name:app*").and_yield(@node_1).and_yield(@node_2) expect(@wrapper.find("name:app*")).to include(@node_1, @node_2) end it "creates a 'AND'-joined query string from a HASH" do # Hash order woes - expect(@searcher).to receive(:search).with(:node, 'name:app* AND name:app*').and_yield(@node_1).and_yield(@node_2) - expect(@wrapper.find(:name=>"app*",'name'=>"app*")).to include(@node_1, @node_2) + expect(@searcher).to receive(:search).with(:node, "name:app* AND name:app*").and_yield(@node_1).and_yield(@node_2) + expect(@wrapper.find(:name=>"app*","name"=>"app*")).to include(@node_1, @node_2) end end diff --git a/spec/unit/shell/shell_ext_spec.rb b/spec/unit/shell/shell_ext_spec.rb index 9521ae646b..eaff3cc807 100644 --- a/spec/unit/shell/shell_ext_spec.rb +++ b/spec/unit/shell/shell_ext_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Shell::Extensions do describe "extending object for top level methods" do diff --git a/spec/unit/shell/shell_session_spec.rb b/spec/unit/shell/shell_session_spec.rb index d1cedb3236..218c814d43 100644 --- a/spec/unit/shell/shell_session_spec.rb +++ b/spec/unit/shell/shell_session_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" require "ostruct" @@ -49,7 +49,7 @@ end describe Shell::ClientSession do before do - Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new('shell::override')] } + Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] } @chef_rest = double("Chef::ServerAPI") @session = Shell::ClientSession.instance @node = Chef::Node.build("foo") @@ -80,7 +80,7 @@ end describe Shell::StandAloneSession do before do - Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new('shell::override')] } + Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] } @session = Shell::StandAloneSession.instance @node = @session.node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @@ -131,7 +131,7 @@ end describe Shell::SoloSession do before do - Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new('shell::override')] } + Chef::Config[:shell_config] = { :override_runlist => [Chef::RunList::RunListItem.new("shell::override")] } Chef::Config[:shell_solo] = true @session = Shell::SoloSession.instance @node = Chef::Node.new diff --git a/spec/unit/shell_out_spec.rb b/spec/unit/shell_out_spec.rb index 50b0b61cb7..35844f4961 100644 --- a/spec/unit/shell_out_spec.rb +++ b/spec/unit/shell_out_spec.rb @@ -1,4 +1,4 @@ -require File.expand_path('../../spec_helper', __FILE__) +require File.expand_path("../../spec_helper", __FILE__) describe "Chef::ShellOut deprecation notices" do it "logs a warning when initializing a new Chef::ShellOut object" do diff --git a/spec/unit/shell_spec.rb b/spec/unit/shell_spec.rb index 379043a017..6add9991e8 100644 --- a/spec/unit/shell_spec.rb +++ b/spec/unit/shell_spec.rb @@ -15,7 +15,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" require "ostruct" ObjectTestHarness = Proc.new do @@ -44,7 +44,7 @@ describe Shell do Shell.irb_conf = {} allow(Shell::ShellSession.instance).to receive(:reset!) allow(ChefConfig).to receive(:windows?).and_return(false) - allow(Chef::Util::PathHelper).to receive(:home).and_return('/home/foo') + allow(Chef::Util::PathHelper).to receive(:home).and_return("/home/foo") end describe "reporting its status" do @@ -58,7 +58,7 @@ describe Shell do describe "configuring IRB" do it "configures irb history" do Shell.configure_irb - expect(Shell.irb_conf[:HISTORY_FILE]).to eq(Chef::Util::PathHelper.home('.chef', 'chef_shell_history')) + expect(Shell.irb_conf[:HISTORY_FILE]).to eq(Chef::Util::PathHelper.home(".chef", "chef_shell_history")) expect(Shell.irb_conf[:SAVE_HISTORY]).to eq(1000) end diff --git a/spec/unit/user_spec.rb b/spec/unit/user_spec.rb index 97cc32eb3e..0bf3c2d332 100644 --- a/spec/unit/user_spec.rb +++ b/spec/unit/user_spec.rb @@ -21,10 +21,10 @@ # Open Source Chef Server 11 and should be removed once support # for OSC 11 ends. New development should occur in user_spec.rb. -require 'spec_helper' +require "spec_helper" -require 'chef/user' -require 'tempfile' +require "chef/user" +require "tempfile" describe Chef::User do before(:each) do diff --git a/spec/unit/user_v1_spec.rb b/spec/unit/user_v1_spec.rb index d2ba0cf4de..8bf27168d9 100644 --- a/spec/unit/user_v1_spec.rb +++ b/spec/unit/user_v1_spec.rb @@ -16,10 +16,10 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" -require 'chef/user_v1' -require 'tempfile' +require "chef/user_v1" +require "tempfile" describe Chef::UserV1 do before(:each) do @@ -312,13 +312,13 @@ describe Chef::UserV1 do end describe "Versioned API Interactions" do - let(:response_406) { OpenStruct.new(:code => '406') } + let(:response_406) { OpenStruct.new(:code => "406") } let(:exception_406) { Net::HTTPServerException.new("406 Not Acceptable", response_406) } before (:each) do @user = Chef::UserV1.new - allow(@user).to receive(:chef_root_rest_v0).and_return(double('chef rest root v0 object')) - allow(@user).to receive(:chef_root_rest_v1).and_return(double('chef rest root v1 object')) + allow(@user).to receive(:chef_root_rest_v0).and_return(double("chef rest root v0 object")) + allow(@user).to receive(:chef_root_rest_v1).and_return(double("chef rest root v1 object")) end describe "update" do @@ -374,7 +374,7 @@ describe Chef::UserV1 do end context "when the server returns a 400" do - let(:response_400) { OpenStruct.new(:code => '400') } + let(:response_400) { OpenStruct.new(:code => "400") } let(:exception_400) { Net::HTTPServerException.new("400 Bad Request", response_400) } context "when the 400 was due to public / private key fields no longer being supported" do diff --git a/spec/unit/util/backup_spec.rb b/spec/unit/util/backup_spec.rb index f548e8241d..ab44c9fdc2 100644 --- a/spec/unit/util/backup_spec.rb +++ b/spec/unit/util/backup_spec.rb @@ -17,8 +17,8 @@ # -require 'spec_helper' -require 'tmpdir' +require "spec_helper" +require "tmpdir" describe Chef::Util::Backup do @@ -71,15 +71,15 @@ describe Chef::Util::Backup do end it "should not delete anything if this is the only backup" do - expect(@backup).to receive(:sorted_backup_files).and_return(['a']) + expect(@backup).to receive(:sorted_backup_files).and_return(["a"]) expect(@backup).not_to receive(:delete_backup) @backup.backup! end it "should keep only 1 backup copy" do - expect(@backup).to receive(:sorted_backup_files).and_return(['a', 'b', 'c']) - expect(@backup).to receive(:delete_backup).with('b') - expect(@backup).to receive(:delete_backup).with('c') + expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b", "c"]) + expect(@backup).to receive(:delete_backup).with("b") + expect(@backup).to receive(:delete_backup).with("c") @backup.backup! end end @@ -90,15 +90,15 @@ describe Chef::Util::Backup do end it "should not delete anything if we only have one other backup" do - expect(@backup).to receive(:sorted_backup_files).and_return(['a', 'b']) + expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b"]) expect(@backup).not_to receive(:delete_backup) @backup.backup! end it "should keep only 2 backup copies" do - expect(@backup).to receive(:sorted_backup_files).and_return(['a', 'b', 'c', 'd']) - expect(@backup).to receive(:delete_backup).with('c') - expect(@backup).to receive(:delete_backup).with('d') + expect(@backup).to receive(:sorted_backup_files).and_return(["a", "b", "c", "d"]) + expect(@backup).to receive(:delete_backup).with("c") + expect(@backup).to receive(:delete_backup).with("d") @backup.backup! end end @@ -106,7 +106,7 @@ describe Chef::Util::Backup do describe "backup_filename" do it "should return a timestamped path" do - expect(@backup).to receive(:path).and_return('/a/b/c.txt') + expect(@backup).to receive(:path).and_return("/a/b/c.txt") expect(@backup.send(:backup_filename)).to match(%r|^/a/b/c.txt.chef-\d{14}.\d{6}$|) end it "should strip the drive letter off for windows" do @@ -114,21 +114,21 @@ describe Chef::Util::Backup do expect(@backup.send(:backup_filename)).to match(%r|^\\a\\b\\c.txt.chef-\d{14}.\d{6}$|) end it "should strip the drive letter off for windows (with forwardslashes)" do - expect(@backup).to receive(:path).and_return('c:/a/b/c.txt') + expect(@backup).to receive(:path).and_return("c:/a/b/c.txt") expect(@backup.send(:backup_filename)).to match(%r|^/a/b/c.txt.chef-\d{14}.\d{6}$|) end end describe "backup_path" do it "uses the file's directory when Chef::Config[:file_backup_path] is nil" do - expect(@backup).to receive(:path).and_return('/a/b/c.txt') + expect(@backup).to receive(:path).and_return("/a/b/c.txt") Chef::Config[:file_backup_path] = nil expect(@backup.send(:backup_path)).to match(%r|^/a/b/c.txt.chef-\d{14}.\d{6}$|) end it "uses the configured Chef::Config[:file_backup_path]" do - expect(@backup).to receive(:path).and_return('/a/b/c.txt') - Chef::Config[:file_backup_path] = '/backupdir' + expect(@backup).to receive(:path).and_return("/a/b/c.txt") + Chef::Config[:file_backup_path] = "/backupdir" expect(@backup.send(:backup_path)).to match(%r|^/backupdir[\\/]+a/b/c.txt.chef-\d{14}.\d{6}$|) end diff --git a/spec/unit/util/diff_spec.rb b/spec/unit/util/diff_spec.rb index b0a57a32c0..f46bc31488 100644 --- a/spec/unit/util/diff_spec.rb +++ b/spec/unit/util/diff_spec.rb @@ -17,8 +17,8 @@ # -require 'spec_helper' -require 'tmpdir' +require "spec_helper" +require "tmpdir" shared_context "using file paths with spaces" do let!(:old_tempfile) { Tempfile.new("chef-util diff-spec") } diff --git a/spec/unit/util/dsc/configuration_generator_spec.rb b/spec/unit/util/dsc/configuration_generator_spec.rb index 9fbd3aaa51..f05780285f 100644 --- a/spec/unit/util/dsc/configuration_generator_spec.rb +++ b/spec/unit/util/dsc/configuration_generator_spec.rb @@ -16,25 +16,25 @@ # limitations under the License. # -require 'chef' -require 'chef/util/dsc/configuration_generator' +require "chef" +require "chef/util/dsc/configuration_generator" describe Chef::Util::DSC::ConfigurationGenerator do let(:conf_man) do node = Chef::Node.new - Chef::Util::DSC::ConfigurationGenerator.new(node, 'tmp') + Chef::Util::DSC::ConfigurationGenerator.new(node, "tmp") end describe '#validate_configuration_name!' do - it 'should not raise an error if a name contains all upper case letters' do + it "should not raise an error if a name contains all upper case letters" do conf_man.send(:validate_configuration_name!, "HELLO") end - it 'should not raise an error if the name contains all lower case letters' do + it "should not raise an error if the name contains all lower case letters" do conf_man.send(:validate_configuration_name!, "hello") end - it 'should not raise an error if no special characters are used except _' do + it "should not raise an error if no special characters are used except _" do conf_man.send(:validate_configuration_name!, "hello_world") end @@ -48,67 +48,67 @@ describe Chef::Util::DSC::ConfigurationGenerator do end describe "#get_merged_configuration_flags" do - context 'when strings are used as switches' do - it 'should merge the hash if there are no restricted switches' do - merged = conf_man.send(:get_merged_configuration_flags!, {'flag' => 'a'}, 'hello') + context "when strings are used as switches" do + it "should merge the hash if there are no restricted switches" do + merged = conf_man.send(:get_merged_configuration_flags!, {"flag" => "a"}, "hello") expect(merged).to include(:flag) - expect(merged[:flag]).to eql('a') + expect(merged[:flag]).to eql("a") expect(merged).to include(:outputpath) end - it 'should raise an ArgumentError if you try to override outputpath' do + it "should raise an ArgumentError if you try to override outputpath" do expect { - conf_man.send(:get_merged_configuration_flags!, {'outputpath' => 'a'}, 'hello') + conf_man.send(:get_merged_configuration_flags!, {"outputpath" => "a"}, "hello") }.to raise_error(ArgumentError) end - it 'should be case insensitive for switches that are not allowed' do + it "should be case insensitive for switches that are not allowed" do expect { - conf_man.send(:get_merged_configuration_flags!, {'OutputPath' => 'a'}, 'hello') + conf_man.send(:get_merged_configuration_flags!, {"OutputPath" => "a"}, "hello") }.to raise_error(ArgumentError) end - it 'should be case insensitive to switches that are allowed' do - merged = conf_man.send(:get_merged_configuration_flags!, {'FLAG' => 'a'}, 'hello') + it "should be case insensitive to switches that are allowed" do + merged = conf_man.send(:get_merged_configuration_flags!, {"FLAG" => "a"}, "hello") expect(merged).to include(:flag) end end - context 'when symbols are used as switches' do - it 'should merge the hash if there are no restricted switches' do - merged = conf_man.send(:get_merged_configuration_flags!, {:flag => 'a'}, 'hello') + context "when symbols are used as switches" do + it "should merge the hash if there are no restricted switches" do + merged = conf_man.send(:get_merged_configuration_flags!, {:flag => "a"}, "hello") expect(merged).to include(:flag) - expect(merged[:flag]).to eql('a') + expect(merged[:flag]).to eql("a") expect(merged).to include(:outputpath) end - it 'should raise an ArgumentError if you try to override outputpath' do + it "should raise an ArgumentError if you try to override outputpath" do expect { - conf_man.send(:get_merged_configuration_flags!, {:outputpath => 'a'}, 'hello') + conf_man.send(:get_merged_configuration_flags!, {:outputpath => "a"}, "hello") }.to raise_error(ArgumentError) end - it 'should be case insensitive for switches that are not allowed' do + it "should be case insensitive for switches that are not allowed" do expect { - conf_man.send(:get_merged_configuration_flags!, {:OutputPath => 'a'}, 'hello') + conf_man.send(:get_merged_configuration_flags!, {:OutputPath => "a"}, "hello") }.to raise_error(ArgumentError) end - it 'should be case insensitive to switches that are allowed' do - merged = conf_man.send(:get_merged_configuration_flags!, {:FLAG => 'a'}, 'hello') + it "should be case insensitive to switches that are allowed" do + merged = conf_man.send(:get_merged_configuration_flags!, {:FLAG => "a"}, "hello") expect(merged).to include(:flag) end end - context 'when there are no flags' do - it 'should supply an output path if configuration_flags is an empty hash' do - merged = conf_man.send(:get_merged_configuration_flags!, {}, 'hello') + context "when there are no flags" do + it "should supply an output path if configuration_flags is an empty hash" do + merged = conf_man.send(:get_merged_configuration_flags!, {}, "hello") expect(merged).to include(:outputpath) expect(merged.length).to eql(1) end - it 'should supply an output path if configuration_flags is an empty hash' do - merged = conf_man.send(:get_merged_configuration_flags!, nil, 'hello') + it "should supply an output path if configuration_flags is an empty hash" do + merged = conf_man.send(:get_merged_configuration_flags!, nil, "hello") expect(merged).to include(:outputpath) expect(merged.length).to eql(1) end @@ -130,7 +130,7 @@ describe Chef::Util::DSC::ConfigurationGenerator do [a,b].join("++") end allow(file_like_object).to receive(:write) - conf_man.send(:write_document_generation_script, 'file', 'hello', {}) + conf_man.send(:write_document_generation_script, "file", "hello", {}) expect(file_like_object).to have_received(:write) end end @@ -143,24 +143,24 @@ describe Chef::Util::DSC::ConfigurationGenerator do [a,b].join("++") end - allow(Dir).to receive(:entries).with("tmp++hello") {['f1', 'f2', 'hello.mof', 'f3']} - expect(conf_man.send(:find_configuration_document, 'hello')).to eql('tmp++hello++hello.mof') + allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "hello.mof", "f3"]} + expect(conf_man.send(:find_configuration_document, "hello")).to eql("tmp++hello++hello.mof") end it "should return nil if the mof file is not found" do allow(File).to receive(:join) do |a, b| [a,b].join("++") end - allow(Dir).to receive(:entries).with("tmp++hello") {['f1', 'f2', 'f3']} - expect(conf_man.send(:find_configuration_document, 'hello')).to be_nil + allow(Dir).to receive(:entries).with("tmp++hello") {["f1", "f2", "f3"]} + expect(conf_man.send(:find_configuration_document, "hello")).to be_nil end end describe "#configuration_code" do it "should build dsc" do - dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", {}) found_configuration = false - dsc.split(';').each do |command| + dsc.split(";").each do |command| if command.downcase =~ /\s*configuration\s+'hello'\s*\{\s*node\s+'localhost'\s*\{\s*archive\s*\{\s*\}\s*\}\s*\}\s*/ found_configuration = true end @@ -169,22 +169,22 @@ describe Chef::Util::DSC::ConfigurationGenerator do end context "with imports" do it "should import all resources when a module has an empty list" do - dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => []}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => []}) expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/) end it "should import all resources when a module has a list with *" do - dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', '*', 'BarResource']}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "*", "BarResource"]}) expect(dsc).to match(/Import-DscResource -ModuleName FooModule\s*\n/) end it "should import specific resources when a module has list without * that is not empty" do - dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', 'BarResource']}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "BarResource"]}) expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/) end it "should import multiple modules with multiple import statements" do - dsc = conf_man.send(:configuration_code, 'archive{}', 'hello', {'FooModule' => ['FooResource', 'BarResource'], 'BazModule' => []}) + dsc = conf_man.send(:configuration_code, "archive{}", "hello", {"FooModule" => ["FooResource", "BarResource"], "BazModule" => []}) expect(dsc).to match(/Import-DscResource -ModuleName FooModule -Name FooResource,BarResource/) expect(dsc).to match(/Import-DscResource -ModuleName BazModule\s*\n/) end diff --git a/spec/unit/util/dsc/lcm_output_parser_spec.rb b/spec/unit/util/dsc/lcm_output_parser_spec.rb index 3d44e07885..2990e1f28e 100644 --- a/spec/unit/util/dsc/lcm_output_parser_spec.rb +++ b/spec/unit/util/dsc/lcm_output_parser_spec.rb @@ -16,24 +16,24 @@ # limitations under the License. # -require 'chef/util/dsc/lcm_output_parser' +require "chef/util/dsc/lcm_output_parser" describe Chef::Util::DSC::LocalConfigurationManager::Parser do - context 'empty input parameter' do - it 'raises an exception when there are no valid lines' do + context "empty input parameter" do + it "raises an exception when there are no valid lines" do str = <<-EOF EOF expect {Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str)}.to raise_error(Chef::Exceptions::LCMParser) end - it 'raises an exception for a nil input' do + it "raises an exception for a nil input" do expect {Chef::Util::DSC::LocalConfigurationManager::Parser::parse(nil)}.to raise_error(Chef::Exceptions::LCMParser) end end - context 'correctly formatted output from lcm' do - it 'returns a single resource when only 1 logged with the correct name' do + context "correctly formatted output from lcm" do + it "returns a single resource when only 1 logged with the correct name" do str = <<EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ Start Resource ] [name] @@ -42,10 +42,10 @@ logtype: [machinename]: LCM: [ End Set ] EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) expect(resources.length).to eq(1) - expect(resources[0].name).to eq('[name]') + expect(resources[0].name).to eq("[name]") end - it 'identifies when a resource changes the state of the system' do + it "identifies when a resource changes the state of the system" do str = <<EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ Start Resource ] [name] @@ -58,7 +58,7 @@ EOF expect(resources[0].changes_state?).to be_truthy end - it 'preserves the log provided for how the system changed the state' do + it "preserves the log provided for how the system changed the state" do str = <<EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ Start Resource ] [name] @@ -72,7 +72,7 @@ EOF expect(resources[0].change_log).to match_array(["[name]","[message]","[name]"]) end - it 'should return false for changes_state?' do + it "should return false for changes_state?" do str = <<EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ Start Resource ] [name] @@ -84,7 +84,7 @@ EOF expect(resources[0].changes_state?).to be_falsey end - it 'should return an empty array for change_log if changes_state? is false' do + it "should return an empty array for change_log if changes_state? is false" do str = <<EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ Start Resource ] [name] @@ -97,8 +97,8 @@ EOF end end - context 'Incorrectly formatted output from LCM' do - it 'should allow missing a [End Resource] when its the last one and still find all the resource' do + context "Incorrectly formatted output from LCM" do + it "should allow missing a [End Resource] when its the last one and still find all the resource" do str = <<-EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ Start Resource ] [name] @@ -119,7 +119,7 @@ EOF expect(resources[1].changes_state?).to be_truthy end - it 'should allow missing a [End Resource] when its the first one and still find all the resource' do + it "should allow missing a [End Resource] when its the first one and still find all the resource" do str = <<-EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ Start Resource ] [name] @@ -140,7 +140,7 @@ EOF expect(resources[1].changes_state?).to be_truthy end - it 'should allow missing set and end resource and assume an unconverged resource in this case' do + it "should allow missing set and end resource and assume an unconverged resource in this case" do str = <<-EOF logtype: [machinename]: LCM: [ Start Set ] logtype: [machinename]: LCM: [ Start Resource ] [name] @@ -156,9 +156,9 @@ logtype: [machinename]: LCM: [ End Set ] EOF resources = Chef::Util::DSC::LocalConfigurationManager::Parser::parse(str) expect(resources[0].changes_state?).to be_truthy - expect(resources[0].name).to eql('[name]') + expect(resources[0].name).to eql("[name]") expect(resources[1].changes_state?).to be_truthy - expect(resources[1].name).to eql('[name2]') + expect(resources[1].name).to eql("[name2]") end end end diff --git a/spec/unit/util/dsc/local_configuration_manager_spec.rb b/spec/unit/util/dsc/local_configuration_manager_spec.rb index 1cff9e445b..eb860b5c30 100644 --- a/spec/unit/util/dsc/local_configuration_manager_spec.rb +++ b/spec/unit/util/dsc/local_configuration_manager_spec.rb @@ -16,12 +16,12 @@ # limitations under the License. # -require 'chef' -require 'chef/util/dsc/local_configuration_manager' +require "chef" +require "chef/util/dsc/local_configuration_manager" describe Chef::Util::DSC::LocalConfigurationManager do - let(:lcm) { Chef::Util::DSC::LocalConfigurationManager.new(nil, 'tmp') } + let(:lcm) { Chef::Util::DSC::LocalConfigurationManager.new(nil, "tmp") } let(:normal_lcm_output) { <<-EOH logtype: [machinename]: LCM: [ Start Set ] @@ -50,12 +50,12 @@ EOH double("LCM cmdlet status", :stderr => lcm_standard_error, :return_value => lcm_standard_output, :succeeded? => lcm_cmdlet_success) } - describe 'test_configuration method invocation' do - context 'when interacting with the LCM using a PowerShell cmdlet' do + describe "test_configuration method invocation" do + context "when interacting with the LCM using a PowerShell cmdlet" do before(:each) do allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status) end - context 'that returns successfully' do + context "that returns successfully" do before(:each) do allow(lcm).to receive(:run_configuration_cmdlet).and_return(lcm_status) end @@ -64,16 +64,16 @@ EOH let(:lcm_standard_error) { nil } let(:lcm_cmdlet_success) { true } - it 'should successfully return resource information for normally formatted output when cmdlet the cmdlet succeeds' do - test_configuration_result = lcm.test_configuration('config', {}) + it "should successfully return resource information for normally formatted output when cmdlet the cmdlet succeeds" do + test_configuration_result = lcm.test_configuration("config", {}) expect(test_configuration_result.class).to be(Array) expect(test_configuration_result.length).to be > 0 expect(Chef::Log).not_to receive(:warn) end end - context 'that fails due to missing what-if switch in DSC resource cmdlet implementation' do - let(:lcm_standard_output) { '' } + context "that fails due to missing what-if switch in DSC resource cmdlet implementation" do + let(:lcm_standard_output) { "" } let(:lcm_standard_error) { no_whatif_lcm_output } let(:lcm_cmdlet_success) { false } @@ -81,58 +81,58 @@ EOH expect(lcm.send(:whatif_not_supported?, no_whatif_lcm_output)).to be_truthy end - it 'should should return a (possibly empty) array of ResourceInfo instances' do + it "should should return a (possibly empty) array of ResourceInfo instances" do expect(Chef::Log).to receive(:warn).at_least(:once) expect(lcm).to receive(:whatif_not_supported?).and_call_original test_configuration_result = nil - expect {test_configuration_result = lcm.test_configuration('config', {})}.not_to raise_error + expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error expect(test_configuration_result.class).to be(Array) end end - context 'that fails due to a DSC resource not being imported before StartDSCConfiguration -whatif is executed' do - let(:lcm_standard_output) { '' } + context "that fails due to a DSC resource not being imported before StartDSCConfiguration -whatif is executed" do + let(:lcm_standard_output) { "" } let(:lcm_standard_error) { dsc_resource_import_failure_output } let(:lcm_cmdlet_success) { false } - it 'should log a warning if the message is formatted as expected when a resource import failure occurs' do + it "should log a warning if the message is formatted as expected when a resource import failure occurs" do expect(Chef::Log).to receive(:warn).at_least(:once) expect(lcm).to receive(:dsc_module_import_failure?).and_call_original test_configuration_result = nil - expect {test_configuration_result = lcm.test_configuration('config', {})}.not_to raise_error + expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error end - it 'should return a (possibly empty) array of ResourceInfo instances' do + it "should return a (possibly empty) array of ResourceInfo instances" do expect(Chef::Log).to receive(:warn).at_least(:once) test_configuration_result = nil - expect {test_configuration_result = lcm.test_configuration('config', {})}.not_to raise_error + expect {test_configuration_result = lcm.test_configuration("config", {})}.not_to raise_error expect(test_configuration_result.class).to be(Array) end end - context 'that fails due to an unknown PowerShell cmdlet error' do - let(:lcm_standard_output) { 'some output' } - let(:lcm_standard_error) { 'Abort, Retry, Fail?' } + context "that fails due to an unknown PowerShell cmdlet error" do + let(:lcm_standard_output) { "some output" } + let(:lcm_standard_error) { "Abort, Retry, Fail?" } let(:lcm_cmdlet_success) { false } - it 'should log a warning' do + it "should log a warning" do expect(Chef::Log).to receive(:warn).at_least(:once) expect(lcm).to receive(:dsc_module_import_failure?).and_call_original - expect {lcm.test_configuration('config', {})}.not_to raise_error + expect {lcm.test_configuration("config", {})}.not_to raise_error end end end - it 'should identify a correctly formatted error message as a resource import failure' do + it "should identify a correctly formatted error message as a resource import failure" do expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output)).to be(true) end - it 'should not identify an incorrectly formatted error message as a resource import failure' do - expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub('module', 'gibberish'))).to be(false) + it "should not identify an incorrectly formatted error message as a resource import failure" do + expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("module", "gibberish"))).to be(false) end - it 'should not identify a message without a CimException reference as a resource import failure' do - expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub('CimException', 'ArgumentException'))).to be(false) + it "should not identify a message without a CimException reference as a resource import failure" do + expect(lcm.send(:dsc_module_import_failure?, dsc_resource_import_failure_output.gsub("CimException", "ArgumentException"))).to be(false) end end end diff --git a/spec/unit/util/dsc/resource_store.rb b/spec/unit/util/dsc/resource_store.rb index 181ac2bb6c..97652a3d1c 100644 --- a/spec/unit/util/dsc/resource_store.rb +++ b/spec/unit/util/dsc/resource_store.rb @@ -16,61 +16,61 @@ # limitations under the License. # -require 'chef' -require 'chef/util/dsc/resource_store' +require "chef" +require "chef/util/dsc/resource_store" describe Chef::Util::DSC::ResourceStore do let(:resource_store) { Chef::Util::DSC::ResourceStore.new } let(:resource_a) { { - 'ResourceType' => 'AFoo', - 'Name' => 'Foo', - 'Module' => {'Name' => 'ModuleA'}, + "ResourceType" => "AFoo", + "Name" => "Foo", + "Module" => {"Name" => "ModuleA"}, } } let(:resource_b) { { - 'ResourceType' => 'BFoo', - 'Name' => 'Foo', - 'Module' => {'Name' => 'ModuleB'}, + "ResourceType" => "BFoo", + "Name" => "Foo", + "Module" => {"Name" => "ModuleB"}, } } - context 'when resources are not cached' do + context "when resources are not cached" do context 'when calling #resources' do - it 'returns an empty array' do + it "returns an empty array" do expect(resource_store.resources).to eql([]) end end context 'when calling #find' do - it 'returns an empty list if it cannot find any matching resources' do + it "returns an empty list if it cannot find any matching resources" do expect(resource_store).to receive(:query_resource).and_return([]) - expect(resource_store.find('foo')).to eql([]) + expect(resource_store.find("foo")).to eql([]) end - it 'returns the resource if it is found (comparisons are case insensitive)' do + it "returns the resource if it is found (comparisons are case insensitive)" do expect(resource_store).to receive(:query_resource).and_return([resource_a]) - expect(resource_store.find('foo')).to eql([resource_a]) + expect(resource_store.find("foo")).to eql([resource_a]) end - it 'returns multiple resoures if they are found' do + it "returns multiple resoures if they are found" do expect(resource_store).to receive(:query_resource).and_return([resource_a, resource_b]) - expect(resource_store.find('foo')).to include(resource_a, resource_b) + expect(resource_store.find("foo")).to include(resource_a, resource_b) end - it 'deduplicates resources by ResourceName' do + it "deduplicates resources by ResourceName" do expect(resource_store).to receive(:query_resource).and_return([resource_a, resource_a]) - resource_store.find('foo') + resource_store.find("foo") expect(resource_store.resources).to eq([resource_a]) end end end - context 'when resources are cached' do - it 'recalls resources from the cache if present' do + context "when resources are cached" do + it "recalls resources from the cache if present" do expect(resource_store).not_to receive(:query_resource) expect(resource_store).to receive(:resources).and_return([resource_a]) - resource_store.find('foo') + resource_store.find("foo") end end end diff --git a/spec/unit/util/editor_spec.rb b/spec/unit/util/editor_spec.rb index 968302df17..9db7e85931 100644 --- a/spec/unit/util/editor_spec.rb +++ b/spec/unit/util/editor_spec.rb @@ -1,14 +1,14 @@ -require 'spec_helper' -require 'chef/util/editor' +require "spec_helper" +require "chef/util/editor" describe Chef::Util::Editor do describe '#initialize' do - it 'takes an Enumerable of lines' do + it "takes an Enumerable of lines" do editor = described_class.new(File.open(__FILE__)) expect(editor.lines).to be == IO.readlines(__FILE__) end - it 'makes a copy of an Array' do + it "makes a copy of an Array" do array = Array.new editor = described_class.new(array) expect(editor.lines).to_not be(array) @@ -16,137 +16,137 @@ describe Chef::Util::Editor do end subject(:editor) { described_class.new(input_lines) } - let(:input_lines) { ['one', 'two', 'two', 'three'] } + let(:input_lines) { ["one", "two", "two", "three"] } describe '#append_line_after' do - context 'when there is no match' do - subject(:execute) { editor.append_line_after('missing', 'new') } + context "when there is no match" do + subject(:execute) { editor.append_line_after("missing", "new") } - it('returns the number of added lines') { is_expected.to eq(0) } - it 'does not add any lines' do + it("returns the number of added lines") { is_expected.to eq(0) } + it "does not add any lines" do expect { execute }.to_not change { editor.lines } end end - context 'when there is a match' do - subject(:execute) { editor.append_line_after('two', 'new') } + context "when there is a match" do + subject(:execute) { editor.append_line_after("two", "new") } - it('returns the number of added lines') { is_expected.to eq(2) } - it 'adds a line after each match' do + it("returns the number of added lines") { is_expected.to eq(2) } + it "adds a line after each match" do execute - expect(editor.lines).to be == ['one', 'two', 'new', 'two', 'new', 'three'] + expect(editor.lines).to be == ["one", "two", "new", "two", "new", "three"] end end - it 'matches a Regexp' do - expect(editor.append_line_after(/^ee/, 'new')).to be == 0 - expect(editor.append_line_after(/ee$/, 'new')).to be == 1 + it "matches a Regexp" do + expect(editor.append_line_after(/^ee/, "new")).to be == 0 + expect(editor.append_line_after(/ee$/, "new")).to be == 1 end end describe '#append_line_if_missing' do - context 'when there is no match' do - subject(:execute) { editor.append_line_if_missing('missing', 'new') } + context "when there is no match" do + subject(:execute) { editor.append_line_if_missing("missing", "new") } - it('returns the number of added lines') { is_expected.to eq(1) } - it 'adds a line to the end' do + it("returns the number of added lines") { is_expected.to eq(1) } + it "adds a line to the end" do execute - expect(editor.lines).to be == ['one', 'two', 'two', 'three', 'new'] + expect(editor.lines).to be == ["one", "two", "two", "three", "new"] end end - context 'when there is a match' do - subject(:execute) { editor.append_line_if_missing('one', 'new') } + context "when there is a match" do + subject(:execute) { editor.append_line_if_missing("one", "new") } - it('returns the number of added lines') { is_expected.to eq(0) } - it 'does not add any lines' do + it("returns the number of added lines") { is_expected.to eq(0) } + it "does not add any lines" do expect { execute }.to_not change { editor.lines } end end - it 'matches a Regexp' do - expect(editor.append_line_if_missing(/ee$/, 'new')).to be == 0 - expect(editor.append_line_if_missing(/^ee/, 'new')).to be == 1 + it "matches a Regexp" do + expect(editor.append_line_if_missing(/ee$/, "new")).to be == 0 + expect(editor.append_line_if_missing(/^ee/, "new")).to be == 1 end end describe '#remove_lines' do - context 'when there is no match' do - subject(:execute) { editor.remove_lines('missing') } + context "when there is no match" do + subject(:execute) { editor.remove_lines("missing") } - it('returns the number of removed lines') { is_expected.to eq(0) } - it 'does not remove any lines' do + it("returns the number of removed lines") { is_expected.to eq(0) } + it "does not remove any lines" do expect { execute }.to_not change { editor.lines } end end - context 'when there is a match' do - subject(:execute) { editor.remove_lines('two') } + context "when there is a match" do + subject(:execute) { editor.remove_lines("two") } - it('returns the number of removed lines') { is_expected.to eq(2) } - it 'removes the matching lines' do + it("returns the number of removed lines") { is_expected.to eq(2) } + it "removes the matching lines" do execute - expect(editor.lines).to be == ['one', 'three'] + expect(editor.lines).to be == ["one", "three"] end end - it 'matches a Regexp' do + it "matches a Regexp" do expect(editor.remove_lines(/^ee/)).to be == 0 expect(editor.remove_lines(/ee$/)).to be == 1 end end describe '#replace' do - context 'when there is no match' do - subject(:execute) { editor.replace('missing', 'new') } + context "when there is no match" do + subject(:execute) { editor.replace("missing", "new") } - it('returns the number of changed lines') { is_expected.to eq(0) } - it 'does not change any lines' do + it("returns the number of changed lines") { is_expected.to eq(0) } + it "does not change any lines" do expect { execute }.to_not change { editor.lines } end end - context 'when there is a match' do - subject(:execute) { editor.replace('two', 'new') } + context "when there is a match" do + subject(:execute) { editor.replace("two", "new") } - it('returns the number of changed lines') { is_expected.to eq(2) } - it 'replaces the matching portions' do + it("returns the number of changed lines") { is_expected.to eq(2) } + it "replaces the matching portions" do execute - expect(editor.lines).to be == ['one', 'new', 'new', 'three'] + expect(editor.lines).to be == ["one", "new", "new", "three"] end end - it 'matches a Regexp' do - expect(editor.replace(/^ee/, 'new')).to be == 0 - expect(editor.replace(/ee$/, 'new')).to be == 1 - expect(editor.lines).to be == ['one', 'two', 'two', 'thrnew'] + it "matches a Regexp" do + expect(editor.replace(/^ee/, "new")).to be == 0 + expect(editor.replace(/ee$/, "new")).to be == 1 + expect(editor.lines).to be == ["one", "two", "two", "thrnew"] end end describe '#replace_lines' do - context 'when there is no match' do - subject(:execute) { editor.replace_lines('missing', 'new') } + context "when there is no match" do + subject(:execute) { editor.replace_lines("missing", "new") } - it('returns the number of changed lines') { is_expected.to eq(0) } - it 'does not change any lines' do + it("returns the number of changed lines") { is_expected.to eq(0) } + it "does not change any lines" do expect { execute }.to_not change { editor.lines } end end - context 'when there is a match' do - subject(:execute) { editor.replace_lines('two', 'new') } + context "when there is a match" do + subject(:execute) { editor.replace_lines("two", "new") } - it('returns the number of replaced lines') { is_expected.to eq(2) } - it 'replaces the matching line' do + it("returns the number of replaced lines") { is_expected.to eq(2) } + it "replaces the matching line" do execute - expect(editor.lines).to be == ['one', 'new', 'new', 'three'] + expect(editor.lines).to be == ["one", "new", "new", "three"] end end - it 'matches a Regexp' do - expect(editor.replace_lines(/^ee/, 'new')).to be == 0 - expect(editor.replace_lines(/ee$/, 'new')).to be == 1 - expect(editor.lines).to be == ['one', 'two', 'two', 'new'] + it "matches a Regexp" do + expect(editor.replace_lines(/^ee/, "new")).to be == 0 + expect(editor.replace_lines(/ee$/, "new")).to be == 1 + expect(editor.lines).to be == ["one", "two", "two", "new"] end end end diff --git a/spec/unit/util/file_edit_spec.rb b/spec/unit/util/file_edit_spec.rb index b99cf2f426..5f9b559a4c 100644 --- a/spec/unit/util/file_edit_spec.rb +++ b/spec/unit/util/file_edit_spec.rb @@ -16,8 +16,8 @@ # limitations under the License. # -require 'spec_helper' -require 'tempfile' +require "spec_helper" +require "tempfile" describe Chef::Util::FileEdit do @@ -93,7 +93,7 @@ twice end let(:target_file) do - f = Tempfile.open('file_edit_spec') + f = Tempfile.open("file_edit_spec") f.write(starting_content) f.close f diff --git a/spec/unit/util/powershell/cmdlet_spec.rb b/spec/unit/util/powershell/cmdlet_spec.rb index 5ddf9282c4..d2a7960db2 100644 --- a/spec/unit/util/powershell/cmdlet_spec.rb +++ b/spec/unit/util/powershell/cmdlet_spec.rb @@ -16,25 +16,25 @@ # limitations under the License. # -require 'chef' -require 'chef/util/powershell/cmdlet' +require "chef" +require "chef/util/powershell/cmdlet" describe Chef::Util::Powershell::Cmdlet do before (:all) do @node = Chef::Node.new - @cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, 'Some-Commandlet') + @cmdlet = Chef::Util::Powershell::Cmdlet.new(@node, "Some-Commandlet") end describe '#validate_switch_name!' do - it 'should not raise an error if a name contains all upper case letters' do + it "should not raise an error if a name contains all upper case letters" do @cmdlet.send(:validate_switch_name!, "HELLO") end - it 'should not raise an error if the name contains all lower case letters' do + it "should not raise an error if the name contains all lower case letters" do @cmdlet.send(:validate_switch_name!, "hello") end - it 'should not raise an error if no special characters are used except _' do + it "should not raise an error if no special characters are used except _" do @cmdlet.send(:validate_switch_name!, "hello_world") end @@ -55,51 +55,51 @@ describe Chef::Util::Powershell::Cmdlet do end end - it 'does not do anything to a string without special characters' do - expect(@cmdlet.send(:escape_parameter_value, 'stuff')).to eql('stuff') + it "does not do anything to a string without special characters" do + expect(@cmdlet.send(:escape_parameter_value, "stuff")).to eql("stuff") end end describe '#escape_string_parameter_value' do it "surrounds a string with ''" do - expect(@cmdlet.send(:escape_string_parameter_value, 'stuff')).to eql("'stuff'") + expect(@cmdlet.send(:escape_string_parameter_value, "stuff")).to eql("'stuff'") end end describe '#command_switches_string' do - it 'raises an ArgumentError if the key is not a symbol' do + it "raises an ArgumentError if the key is not a symbol" do expect { - @cmdlet.send(:command_switches_string, {'foo' => 'bar'}) + @cmdlet.send(:command_switches_string, {"foo" => "bar"}) }.to raise_error(ArgumentError) end - it 'does not allow invalid switch names' do + it "does not allow invalid switch names" do expect { - @cmdlet.send(:command_switches_string, {:foo! => 'bar'}) + @cmdlet.send(:command_switches_string, {:foo! => "bar"}) }.to raise_error(ArgumentError) end - it 'ignores switches with a false value' do - expect(@cmdlet.send(:command_switches_string, {foo: false})).to eql('') + it "ignores switches with a false value" do + expect(@cmdlet.send(:command_switches_string, {foo: false})).to eql("") end - it 'should correctly handle a value type of string' do - expect(@cmdlet.send(:command_switches_string, {foo: 'bar'})).to eql("-foo 'bar'") + it "should correctly handle a value type of string" do + expect(@cmdlet.send(:command_switches_string, {foo: "bar"})).to eql("-foo 'bar'") end - it 'should correctly handle a value type of string even when it is 0 length' do - expect(@cmdlet.send(:command_switches_string, {foo: ''})).to eql("-foo ''") + it "should correctly handle a value type of string even when it is 0 length" do + expect(@cmdlet.send(:command_switches_string, {foo: ""})).to eql("-foo ''") end - it 'should not quote integers' do + it "should not quote integers" do expect(@cmdlet.send(:command_switches_string, {foo: 1})).to eql("-foo 1") end - it 'should not quote floats' do + it "should not quote floats" do expect(@cmdlet.send(:command_switches_string, {foo: 1.0})).to eql("-foo 1.0") end - it 'has just the switch when the value is true' do + it "has just the switch when the value is true" do expect(@cmdlet.send(:command_switches_string, {foo: true})).to eql("-foo") end end diff --git a/spec/unit/util/powershell/ps_credential_spec.rb b/spec/unit/util/powershell/ps_credential_spec.rb index 668ec525c6..2ec7ff6238 100644 --- a/spec/unit/util/powershell/ps_credential_spec.rb +++ b/spec/unit/util/powershell/ps_credential_spec.rb @@ -16,27 +16,27 @@ # limitations under the License. # -require 'chef' -require 'chef/util/powershell/ps_credential' +require "chef" +require "chef/util/powershell/ps_credential" describe Chef::Util::Powershell::PSCredential do - let (:username) { 'foo' } - let (:password) { 'ThIsIsThEpAsSwOrD' } + let (:username) { "foo" } + let (:password) { "ThIsIsThEpAsSwOrD" } - context 'when username and password are provided' do + context "when username and password are provided" do let(:ps_credential) { Chef::Util::Powershell::PSCredential.new(username, password)} - context 'when calling to_psobject' do - it 'should create the script to create a PSCredential when calling' do - allow(ps_credential).to receive(:encrypt).with(password).and_return('encrypted') + context "when calling to_psobject" do + it "should create the script to create a PSCredential when calling" do + allow(ps_credential).to receive(:encrypt).with(password).and_return("encrypted") expect(ps_credential.to_psobject).to eq( "New-Object System.Management.Automation.PSCredential("\ "'#{username}',('encrypted' | ConvertTo-SecureString))") end end - context 'when to_text is called' do - it 'should not contain the password' do - allow(ps_credential).to receive(:encrypt).with(password).and_return('encrypted') + context "when to_text is called" do + it "should not contain the password" do + allow(ps_credential).to receive(:encrypt).with(password).and_return("encrypted") expect(ps_credential.to_text).not_to match(/#{password}/) end end diff --git a/spec/unit/util/selinux_spec.rb b/spec/unit/util/selinux_spec.rb index 0ed138c7bc..60f1ba8fae 100644 --- a/spec/unit/util/selinux_spec.rb +++ b/spec/unit/util/selinux_spec.rb @@ -17,7 +17,7 @@ # -require 'spec_helper' +require "spec_helper" describe Chef::Util::Selinux do class TestClass @@ -40,7 +40,7 @@ describe Chef::Util::Selinux do end it "each part of ENV['PATH'] should be checked" do - expected_paths = ENV['PATH'].split(File::PATH_SEPARATOR) + [ '/bin', '/usr/bin', '/sbin', '/usr/sbin' ] + expected_paths = ENV["PATH"].split(File::PATH_SEPARATOR) + [ "/bin", "/usr/bin", "/sbin", "/usr/sbin" ] expected_paths.each do |bin_path| selinux_path = File.join(bin_path, "selinuxenabled") diff --git a/spec/unit/util/threaded_job_queue_spec.rb b/spec/unit/util/threaded_job_queue_spec.rb index 22626328be..e4eb58d8bd 100644 --- a/spec/unit/util/threaded_job_queue_spec.rb +++ b/spec/unit/util/threaded_job_queue_spec.rb @@ -13,7 +13,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' +require "spec_helper" class WorkerThreadError < StandardError end diff --git a/spec/unit/version/platform_spec.rb b/spec/unit/version/platform_spec.rb index dd425b32a5..6c9720fe6d 100644 --- a/spec/unit/version/platform_spec.rb +++ b/spec/unit/version/platform_spec.rb @@ -14,13 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' -require 'chef/version/platform' +require "spec_helper" +require "chef/version/platform" describe Chef::Version::Platform do it "is a subclass of Chef::Version" do - v = Chef::Version::Platform.new('1.1') + v = Chef::Version::Platform.new("1.1") expect(v).to be_an_instance_of(Chef::Version::Platform) expect(v).to be_a_kind_of(Chef::Version) end diff --git a/spec/unit/version_class_spec.rb b/spec/unit/version_class_spec.rb index f1f55c7b05..2e70b7e00c 100644 --- a/spec/unit/version_class_spec.rb +++ b/spec/unit/version_class_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' -require 'chef/version_class' +require "spec_helper" +require "chef/version_class" describe Chef::Version do before do diff --git a/spec/unit/version_constraint/platform_spec.rb b/spec/unit/version_constraint/platform_spec.rb index f38eb49689..a4ddc4e0bd 100644 --- a/spec/unit/version_constraint/platform_spec.rb +++ b/spec/unit/version_constraint/platform_spec.rb @@ -14,8 +14,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' -require 'chef/version_constraint/platform' +require "spec_helper" +require "chef/version_constraint/platform" describe Chef::VersionConstraint::Platform do diff --git a/spec/unit/version_constraint_spec.rb b/spec/unit/version_constraint_spec.rb index 0ae502f66d..e50fd2115c 100644 --- a/spec/unit/version_constraint_spec.rb +++ b/spec/unit/version_constraint_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'spec_helper' -require 'chef/version_constraint' +require "spec_helper" +require "chef/version_constraint" describe Chef::VersionConstraint do describe "validation" do @@ -88,7 +88,7 @@ describe Chef::VersionConstraint do expect(@vc).to include Chef::Version.new("1.4") end it "Chef::CookbookVersion" do - cv = Chef::CookbookVersion.new("alice", '/tmp/blah.txt') + cv = Chef::CookbookVersion.new("alice", "/tmp/blah.txt") cv.version = "1.4" expect(@vc).to include cv end @@ -149,31 +149,31 @@ describe Chef::VersionConstraint do end end - describe 'to_s' do - it 'shows a patch-level if one is given' do - vc = Chef::VersionConstraint.new '~> 1.2.0' + describe "to_s" do + it "shows a patch-level if one is given" do + vc = Chef::VersionConstraint.new "~> 1.2.0" - expect(vc.to_s).to eq('~> 1.2.0') + expect(vc.to_s).to eq("~> 1.2.0") end - it 'shows no patch-level if one is not given' do - vc = Chef::VersionConstraint.new '~> 1.2' + it "shows no patch-level if one is not given" do + vc = Chef::VersionConstraint.new "~> 1.2" - expect(vc.to_s).to eq('~> 1.2') + expect(vc.to_s).to eq("~> 1.2") end end - describe 'inspect' do - it 'shows a patch-level if one is given' do - vc = Chef::VersionConstraint.new '~> 1.2.0' + describe "inspect" do + it "shows a patch-level if one is given" do + vc = Chef::VersionConstraint.new "~> 1.2.0" - expect(vc.inspect).to eq('(~> 1.2.0)') + expect(vc.inspect).to eq("(~> 1.2.0)") end - it 'shows no patch-level if one is not given' do - vc = Chef::VersionConstraint.new '~> 1.2' + it "shows no patch-level if one is not given" do + vc = Chef::VersionConstraint.new "~> 1.2" - expect(vc.inspect).to eq('(~> 1.2)') + expect(vc.inspect).to eq("(~> 1.2)") end end end diff --git a/spec/unit/win32/registry_spec.rb b/spec/unit/win32/registry_spec.rb index 56def30638..fc0a21242b 100644 --- a/spec/unit/win32/registry_spec.rb +++ b/spec/unit/win32/registry_spec.rb @@ -16,7 +16,7 @@ # limitations under the License. # -require 'spec_helper' +require "spec_helper" describe Chef::Win32::Registry do include_context "Win32" @@ -25,9 +25,9 @@ describe Chef::Win32::Registry do let(:value1_upcase_name) { {:name => "ONE", :type => :string, :data => "1"} } let(:key_path) { 'HKCU\Software\OpscodeNumbers' } let(:key) { 'Software\OpscodeNumbers' } - let(:key_parent) { 'Software' } - let(:key_to_delete) { 'OpscodeNumbers' } - let(:sub_key) {'OpscodePrimes'} + let(:key_parent) { "Software" } + let(:key_to_delete) { "OpscodeNumbers" } + let(:sub_key) {"OpscodePrimes"} let(:missing_key_path) {'HKCU\Software'} let(:registry) { Chef::Win32::Registry.new() } let(:hive_mock) { double("::Win32::Registry::KHKEY_CURRENT_USER") } @@ -49,10 +49,10 @@ describe Chef::Win32::Registry do end after(:each) do - Win32::Registry.send(:remove_const, 'KEY_SET_VALUE') if defined?(Win32::Registry::KEY_SET_VALUE) - Win32::Registry.send(:remove_const, 'KEY_QUERY_VALUE') if defined?(Win32::Registry::KEY_QUERY_VALUE) - Win32::Registry.send(:remove_const, 'KEY_READ') if defined?(Win32::Registry::KEY_READ) - Win32::Registry.send(:remove_const, 'KEY_WRITE') if defined?(Win32::Registry::KEY_WRITE) + Win32::Registry.send(:remove_const, "KEY_SET_VALUE") if defined?(Win32::Registry::KEY_SET_VALUE) + Win32::Registry.send(:remove_const, "KEY_QUERY_VALUE") if defined?(Win32::Registry::KEY_QUERY_VALUE) + Win32::Registry.send(:remove_const, "KEY_READ") if defined?(Win32::Registry::KEY_READ) + Win32::Registry.send(:remove_const, "KEY_WRITE") if defined?(Win32::Registry::KEY_WRITE) end describe "get_values" do diff --git a/spec/unit/windows_service_spec.rb b/spec/unit/windows_service_spec.rb index adc128c9d8..a614e6630d 100644 --- a/spec/unit/windows_service_spec.rb +++ b/spec/unit/windows_service_spec.rb @@ -15,13 +15,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # -require 'spec_helper' +require "spec_helper" if Chef::Platform.windows? - require 'chef/application/windows_service' + require "chef/application/windows_service" end describe "Chef::Application::WindowsService", :windows_only do - let(:shell_out_result) { double('shellout', stdout: nil, stderr: nil) } + let(:shell_out_result) { double("shellout", stdout: nil, stderr: nil) } let(:config_options) do { log_location: STDOUT, @@ -57,8 +57,8 @@ describe "Chef::Application::WindowsService", :windows_only do subject.service_main end - context 'has a log location configured' do - let(:tempfile) { Tempfile.new 'log_file' } + context "has a log location configured" do + let(:tempfile) { Tempfile.new "log_file" } let(:config_options) do { log_location: tempfile.path, @@ -79,7 +79,7 @@ describe "Chef::Application::WindowsService", :windows_only do subject.service_main end - context 'configured to Event Logger' do + context "configured to Event Logger" do let(:config_options) do { log_location: Chef::Log::WinEvt.new, @@ -98,7 +98,7 @@ describe "Chef::Application::WindowsService", :windows_only do end end - context 'configueres a watchdog timeout' do + context "configueres a watchdog timeout" do let(:timeout) { 10 } before do |