diff options
Diffstat (limited to 'spec/functional/resource')
18 files changed, 39 insertions, 39 deletions
diff --git a/spec/functional/resource/apt_package_spec.rb b/spec/functional/resource/apt_package_spec.rb index ad4378b83a..6145ea598d 100644 --- a/spec/functional/resource/apt_package_spec.rb +++ b/spec/functional/resource/apt_package_spec.rb @@ -187,9 +187,9 @@ describe Chef::Resource::AptPackage, metadata do end it "raises a reasonable error for action :install" do - expect do + expect { package_resource.run_action(:install) - end.to raise_error(Mixlib::ShellOut::ShellCommandFailed) + }.to raise_error(Mixlib::ShellOut::ShellCommandFailed) end end diff --git a/spec/functional/resource/chocolatey_package_spec.rb b/spec/functional/resource/chocolatey_package_spec.rb index c5590b2d88..eccea739e6 100644 --- a/spec/functional/resource/chocolatey_package_spec.rb +++ b/spec/functional/resource/chocolatey_package_spec.rb @@ -33,7 +33,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do end context "installing a package" do - after { remove_package } + after do remove_package end it "installs the latest version" do subject.run_action(:install) @@ -78,7 +78,7 @@ describe Chef::Resource::ChocolateyPackage, :windows_only, :choco_installed do end context "upgrading a package" do - after { remove_package } + after do remove_package end it "upgrades to a specific version" do subject.version "1.0" diff --git a/spec/functional/resource/cron_spec.rb b/spec/functional/resource/cron_spec.rb index 16b0d2645c..e5bc166958 100644 --- a/spec/functional/resource/cron_spec.rb +++ b/spec/functional/resource/cron_spec.rb @@ -86,7 +86,7 @@ describe Chef::Resource::Cron, :requires_root, :unix_only do end it "should create exactly one crontab entry" do - 5.times { new_resource.run_action(:create) } + 5.times do new_resource.run_action(:create) end cron_should_exists(new_resource.name, new_resource.command) end end diff --git a/spec/functional/resource/dsc_resource_spec.rb b/spec/functional/resource/dsc_resource_spec.rb index 8f5ba5fd9e..58b915f802 100644 --- a/spec/functional/resource/dsc_resource_spec.rb +++ b/spec/functional/resource/dsc_resource_spec.rb @@ -67,9 +67,9 @@ describe Chef::Resource::DscResource, :windows_powershell_dsc_only 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| + contents = File.open(tmp_file_name, "rb:bom|UTF-16LE") { |f| f.read.encode("UTF-8") - end + } expect(contents).to eq(test_text) expect(new_resource).to be_updated end diff --git a/spec/functional/resource/execute_spec.rb b/spec/functional/resource/execute_spec.rb index 3e57795f73..bec056fed2 100644 --- a/spec/functional/resource/execute_spec.rb +++ b/spec/functional/resource/execute_spec.rb @@ -29,7 +29,7 @@ describe Chef::Resource::Execute do describe "when guard is ruby block" do it "guard can still run" do - resource.only_if { true } + resource.only_if do true end resource.run_action(:run) expect(resource).to be_updated_by_last_action end diff --git a/spec/functional/resource/file_spec.rb b/spec/functional/resource/file_spec.rb index 291311f3e2..197e8c1469 100644 --- a/spec/functional/resource/file_spec.rb +++ b/spec/functional/resource/file_spec.rb @@ -140,7 +140,7 @@ describe Chef::Resource::File do context "and the target file exists and has the correct content" do before(:each) do - File.open(path, "w") { |f| f.print expected_content } + File.open(path, "w") do |f| f.print expected_content end @expected_checksum = sha256_checksum(path) diff --git a/spec/functional/resource/git_spec.rb b/spec/functional/resource/git_spec.rb index e978041038..a10bcad2e3 100644 --- a/spec/functional/resource/git_spec.rb +++ b/spec/functional/resource/git_spec.rb @@ -76,7 +76,7 @@ describe Chef::Resource::Git, requires_git: true do Chef::Log.level = :warn # silence git command live streams @old_file_cache_path = Chef::Config[:file_cache_path] shell_out!("git clone \"#{git_bundle_repo}\" example", cwd: origin_repo_dir) - File.open("#{origin_repo}/.git/config", "a+") { |f| f.print(git_user_config) } + File.open("#{origin_repo}/.git/config", "a+") do |f| f.print(git_user_config) end Chef::Config[:file_cache_path] = file_cache_path end diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb index 4593dc1971..996047e342 100644 --- a/spec/functional/resource/link_spec.rb +++ b/spec/functional/resource/link_spec.rb @@ -281,7 +281,7 @@ describe Chef::Resource::Link do # 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") } + File.open(to, "w") do |file| file.write("wowzers") end expect(IO.read(target_file)).to eq("wowzers") end it "marks the resource updated" do @@ -306,7 +306,7 @@ describe Chef::Resource::Link do # 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") } + File.open(to, "w") do |file| file.write("wowzers") end expect(IO.read(target_file)).to eq("wowzers") end it "does not mark the resource updated" do @@ -355,7 +355,7 @@ describe Chef::Resource::Link do before(:each) do resource.owner(test_user) @other_target = File.join(test_file_dir, make_tmpname("other_spec")) - File.open(@other_target, "w") { |file| file.write("eek") } + File.open(@other_target, "w") do |file| file.write("eek") end symlink(@other_target, target_file) chown(target_file, test_user) expect(symlink?(target_file)).to be_truthy @@ -465,7 +465,7 @@ describe Chef::Resource::Link 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") } + File.open(@other_target, "w") do |file| file.write("eek") end symlink(@other_target, to) expect(symlink?(to)).to be_truthy expect(readlink(to)).to eq(canonicalize(@other_target)) @@ -646,7 +646,7 @@ describe Chef::Resource::Link 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") } + File.open(@other_target, "w") do |file| file.write("eek") end symlink(@other_target, to) expect(symlink?(to)).to be_truthy expect(readlink(to)).to eq(canonicalize(@other_target)) diff --git a/spec/functional/resource/msu_package_spec.rb b/spec/functional/resource/msu_package_spec.rb index d6811d99e7..8f28def693 100644 --- a/spec/functional/resource/msu_package_spec.rb +++ b/spec/functional/resource/msu_package_spec.rb @@ -40,7 +40,7 @@ describe Chef::Resource::MsuPackage, :win2012r2_only do end context "installing package" do - after { remove_package } + after do remove_package end it "installs the package successfully" do subject.run_action(:install) diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb index 74ece0d33c..39c614ab91 100644 --- a/spec/functional/resource/powershell_script_spec.rb +++ b/spec/functional/resource/powershell_script_spec.rb @@ -255,7 +255,7 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do it "raises an error when given a block and a guard_interpreter" do resource.guard_interpreter :sh - resource.only_if { true } + resource.only_if do true end expect { resource.should_skip?(:run) }.to raise_error(ArgumentError, /guard_interpreter does not support blocks/) end diff --git a/spec/functional/resource/reboot_spec.rb b/spec/functional/resource/reboot_spec.rb index 5489dc1c72..5b8752f06f 100644 --- a/spec/functional/resource/reboot_spec.rb +++ b/spec/functional/resource/reboot_spec.rb @@ -80,9 +80,9 @@ describe Chef::Resource::Reboot do it "should have modified the run context correctly" do # this doesn't actually test the flow of Chef::Client#do_run, unfortunately. - expect do + expect { resource.run_action(:reboot_now) - end.to throw_symbol(:end_client_run_early) + }.to throw_symbol(:end_client_run_early) test_reboot_action(resource) end diff --git a/spec/functional/resource/remote_directory_spec.rb b/spec/functional/resource/remote_directory_spec.rb index c25e51cf2a..58b2ed70ec 100644 --- a/spec/functional/resource/remote_directory_spec.rb +++ b/spec/functional/resource/remote_directory_spec.rb @@ -136,8 +136,8 @@ describe Chef::Resource::RemoteDirectory 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" } + File.open(modified_file, "a") do |f| f.puts "santa is real" end + File.open(modified_subdir_file, "a") do |f| f.puts "so is rudolph" end modified_file_checksum = sha256_checksum(modified_file) modified_subdir_file_checksum = sha256_checksum(modified_subdir_file) diff --git a/spec/functional/resource/windows_certificate_spec.rb b/spec/functional/resource/windows_certificate_spec.rb index 9b79de6a77..fa14c5b59b 100644 --- a/spec/functional/resource/windows_certificate_spec.rb +++ b/spec/functional/resource/windows_certificate_spec.rb @@ -93,7 +93,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only, :appveyor_only do end end - after { cleanup(store) } + after do cleanup(store) end subject(:win_certificate) do new_resource.store_name = store @@ -453,7 +453,7 @@ describe Chef::Resource::WindowsCertificate, :windows_only, :appveyor_only do win_certificate.source = cer_path win_certificate.run_action(:create) end - before { win_certificate.source = tests_thumbprint } + before do win_certificate.source = tests_thumbprint end it "Initial check if certificate is present" do expect(no_of_certificates).to eq(1) end diff --git a/spec/functional/resource/windows_package_spec.rb b/spec/functional/resource/windows_package_spec.rb index bc508dc526..faad96e9e1 100644 --- a/spec/functional/resource/windows_package_spec.rb +++ b/spec/functional/resource/windows_package_spec.rb @@ -70,7 +70,7 @@ 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 do subject.version("8.0.56336") end it "removes specified version" do subject.run_action(:remove) @@ -121,7 +121,7 @@ describe Chef::Resource::WindowsPackage, :windows_only, :volatile do end describe "package version and installer type" do - after { subject.run_action(:remove) } + after do subject.run_action(:remove) end context "null soft" do let(:pkg_name) { "Ultra Defragmenter" } diff --git a/spec/functional/resource/windows_path_spec.rb b/spec/functional/resource/windows_path_spec.rb index 912abe6b24..1d08d6113c 100644 --- a/spec/functional/resource/windows_path_spec.rb +++ b/spec/functional/resource/windows_path_spec.rb @@ -35,7 +35,7 @@ describe Chef::Resource::WindowsPath, :windows_only do end describe "adding path" do - after { remove_path } + after do remove_path end it "appends the user given path in the Environment variable Path" do subject.run_action(:add) @@ -44,7 +44,7 @@ describe Chef::Resource::WindowsPath, :windows_only do end describe "removing path" do - before { add_path } + before do add_path end it "removes the user given path from the Environment variable Path" do subject.run_action(:remove) diff --git a/spec/functional/resource/windows_service_spec.rb b/spec/functional/resource/windows_service_spec.rb index 999b235df1..9d5459caac 100644 --- a/spec/functional/resource/windows_service_spec.rb +++ b/spec/functional/resource/windows_service_spec.rb @@ -59,7 +59,7 @@ describe Chef::Resource::WindowsService, :windows_only, :system_windows_service_ let(:service_resource) do r = Chef::Resource::WindowsService.new(service_params[:service_name], run_context) - %i{run_as_user run_as_password}.each { |prop| r.send(prop, service_params[prop]) } + %i{run_as_user run_as_password}.each do |prop| r.send(prop, service_params[prop]) end r end diff --git a/spec/functional/resource/windows_task_spec.rb b/spec/functional/resource/windows_task_spec.rb index fa51ad3f8a..3365d37a34 100644 --- a/spec/functional/resource/windows_task_spec.rb +++ b/spec/functional/resource/windows_task_spec.rb @@ -32,7 +32,7 @@ describe Chef::Resource::WindowsTask, :windows_only do end describe "action :create" do - after { delete_task } + after do delete_task end context "when command is with arguments" do subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) @@ -1340,7 +1340,7 @@ describe Chef::Resource::WindowsTask, :windows_only do context "task_name with parent folder" do describe "task_name with path '\\foo\\chef-client-functional-test' " do let(:task_name) { "\\foo\\chef-client-functional-test" } - after { delete_task } + after do delete_task end subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) new_resource.command task_name @@ -1366,7 +1366,7 @@ describe Chef::Resource::WindowsTask, :windows_only do describe "task_name with path '\\foo\\bar\\chef-client-functional-test' " do let(:task_name) { "\\foo\\bar\\chef-client-functional-test" } - after { delete_task } + after do delete_task end subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) new_resource.command task_name @@ -1392,7 +1392,7 @@ describe Chef::Resource::WindowsTask, :windows_only do end describe "priority" do - after { delete_task } + after do delete_task end subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) new_resource.command task_name @@ -1494,7 +1494,7 @@ describe Chef::Resource::WindowsTask, :windows_only do end describe "Examples of idempotent checks for each frequency" do - after { delete_task } + after do delete_task end context "For frequency :once" do subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) @@ -1853,7 +1853,7 @@ describe Chef::Resource::WindowsTask, :windows_only do end describe "action :run" do - after { delete_task } + after do delete_task end subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) @@ -1873,7 +1873,7 @@ describe Chef::Resource::WindowsTask, :windows_only do end describe "action :end", :volatile do - after { delete_task } + after do delete_task end subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) @@ -1894,7 +1894,7 @@ describe Chef::Resource::WindowsTask, :windows_only do describe "action :enable" do let(:task_name) { "chef-client-functional-test-enable" } - after { delete_task } + after do delete_task end subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) @@ -1917,7 +1917,7 @@ describe Chef::Resource::WindowsTask, :windows_only do describe "action :disable" do let(:task_name) { "chef-client-functional-test-disable" } - after { delete_task } + after do delete_task end subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) @@ -1936,7 +1936,7 @@ describe Chef::Resource::WindowsTask, :windows_only do end describe "action :change" do - after { delete_task } + after do delete_task end subject do new_resource = Chef::Resource::WindowsTask.new(task_name, run_context) new_resource.command task_name diff --git a/spec/functional/resource/zypper_package_spec.rb b/spec/functional/resource/zypper_package_spec.rb index c95c3575ca..f7067aad81 100644 --- a/spec/functional/resource/zypper_package_spec.rb +++ b/spec/functional/resource/zypper_package_spec.rb @@ -64,7 +64,7 @@ describe Chef::Resource::ZypperPackage, :requires_root, :suse_only do end context "installing a package" do - after { remove_package } + after do remove_package end it "installs the latest version" do zypper_package.run_action(:install) expect(zypper_package.updated_by_last_action?).to be true |