summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/functional/resource/group_spec.rb12
-rw-r--r--spec/functional/resource/link_spec.rb14
-rw-r--r--spec/functional/resource/powershell_script_spec.rb8
-rw-r--r--spec/functional/run_lock_spec.rb48
-rw-r--r--spec/functional/win32/registry_spec.rb16
-rw-r--r--spec/integration/knife/common_options_spec.rb24
-rw-r--r--spec/integration/knife/serve_spec.rb10
-rw-r--r--spec/spec_helper.rb10
-rw-r--r--spec/support/shared/functional/file_resource.rb36
-rw-r--r--spec/unit/mixin/template_spec.rb60
-rw-r--r--spec/unit/mixin/windows_architecture_helper_spec.rb8
-rw-r--r--spec/unit/node_spec.rb10
-rw-r--r--spec/unit/provider/remote_directory_spec.rb18
-rw-r--r--spec/unit/provider_resolver_spec.rb10
14 files changed, 142 insertions, 142 deletions
diff --git a/spec/functional/resource/group_spec.rb b/spec/functional/resource/group_spec.rb
index 7e5b0725c1..a682e9c0c7 100644
--- a/spec/functional/resource/group_spec.rb
+++ b/spec/functional/resource/group_spec.rb
@@ -307,12 +307,12 @@ describe Chef::Resource::Group, :requires_root_or_running_windows do
let(:number) do
# Loop until we pick a gid that is not in use.
loop do
- begin
- gid = rand(2000..9999) # avoid low group numbers
- return nil if Etc.getgrgid(gid).nil? # returns nil on windows
- rescue ArgumentError # group does not exist
- return gid
- end
+
+ gid = rand(2000..9999) # avoid low group numbers
+ return nil if Etc.getgrgid(gid).nil? # returns nil on windows
+ rescue ArgumentError # group does not exist
+ return gid
+
end
end
diff --git a/spec/functional/resource/link_spec.rb b/spec/functional/resource/link_spec.rb
index c9177ebc77..fc260845e4 100644
--- a/spec/functional/resource/link_spec.rb
+++ b/spec/functional/resource/link_spec.rb
@@ -55,13 +55,13 @@ describe Chef::Resource::Link do
end
after(:each) do
- begin
- cleanup_link(to) if File.exists?(to)
- cleanup_link(target_file) if File.exists?(target_file)
- cleanup_link(CHEF_SPEC_BACKUP_PATH) if File.exists?(CHEF_SPEC_BACKUP_PATH)
- rescue
- puts "Could not remove a file: #{$!}"
- end
+
+ cleanup_link(to) if File.exists?(to)
+ cleanup_link(target_file) if File.exists?(target_file)
+ cleanup_link(CHEF_SPEC_BACKUP_PATH) if File.exists?(CHEF_SPEC_BACKUP_PATH)
+ rescue
+ puts "Could not remove a file: #{$!}"
+
end
def user(user)
diff --git a/spec/functional/resource/powershell_script_spec.rb b/spec/functional/resource/powershell_script_spec.rb
index 5e8a00fd4d..70442eb2b1 100644
--- a/spec/functional/resource/powershell_script_spec.rb
+++ b/spec/functional/resource/powershell_script_spec.rb
@@ -273,10 +273,10 @@ describe Chef::Resource::WindowsScript::PowershellScript, :windows_only do
context "when running on a 32-bit version of Windows", :windows32_only do
it "raises an exception if :x86_64 process architecture is specified" do
- begin
- expect(resource.architecture(:x86_64)).to raise_error Chef::Exceptions::Win32ArchitectureIncorrect
- rescue Chef::Exceptions::Win32ArchitectureIncorrect
- end
+
+ expect(resource.architecture(:x86_64)).to raise_error Chef::Exceptions::Win32ArchitectureIncorrect
+ rescue Chef::Exceptions::Win32ArchitectureIncorrect
+
end
end
end
diff --git a/spec/functional/run_lock_spec.rb b/spec/functional/run_lock_spec.rb
index fa450b9c8d..a7440638d7 100644
--- a/spec/functional/run_lock_spec.rb
+++ b/spec/functional/run_lock_spec.rb
@@ -61,17 +61,17 @@ describe Chef::RunLock do
let!(:p1) { ClientProcess.new(self, "p1") }
let!(:p2) { ClientProcess.new(self, "p2") }
after(:each) do |example|
- begin
- p1.stop
- p2.stop
- rescue
- example.exception = $!
- raise
- ensure
- if example.exception
- print_events
- end
+
+ p1.stop
+ p2.stop
+ rescue
+ example.exception = $!
+ raise
+ ensure
+ if example.exception
+ print_events
end
+
end
def print_events
@@ -445,21 +445,21 @@ describe Chef::RunLock do
def start
example.log_event("#{name}.start")
@pid = fork do
- begin
- Timeout.timeout(CLIENT_PROCESS_TIMEOUT) do
- run_lock = TestRunLock.new(example.lockfile)
- run_lock.client_process = self
- fire_event("started")
- run_lock.acquire
- fire_event("acquired lock")
- run_lock.save_pid
- fire_event("saved pid")
- exit!(0)
- end
- rescue
- fire_event($!.message.lines.join(" // "))
- raise
+
+ Timeout.timeout(CLIENT_PROCESS_TIMEOUT) do
+ run_lock = TestRunLock.new(example.lockfile)
+ run_lock.client_process = self
+ fire_event("started")
+ run_lock.acquire
+ fire_event("acquired lock")
+ run_lock.save_pid
+ fire_event("saved pid")
+ exit!(0)
end
+ rescue
+ fire_event($!.message.lines.join(" // "))
+ raise
+
end
example.log_event("#{name}.start forked (pid #{pid})")
end
diff --git a/spec/functional/win32/registry_spec.rb b/spec/functional/win32/registry_spec.rb
index 638197a30a..3a1c71edf1 100644
--- a/spec/functional/win32/registry_spec.rb
+++ b/spec/functional/win32/registry_spec.rb
@@ -267,10 +267,10 @@ describe "Chef::Win32::Registry", :windows_only do
describe "create_key" do
before(:all) do
::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root") do |reg|
- begin
- reg.delete_key("Trunk", true)
- rescue
- end
+
+ reg.delete_key("Trunk", true)
+ rescue
+
end
end
@@ -362,10 +362,10 @@ describe "Chef::Win32::Registry", :windows_only do
before(:all) do
::Win32::Registry::HKEY_CURRENT_USER.create "Software\\Root\\Trunk"
::Win32::Registry::HKEY_CURRENT_USER.open("Software\\Root\\Trunk") do |reg|
- begin
- reg.delete_key("Red", true)
- rescue
- end
+
+ reg.delete_key("Red", true)
+ rescue
+
end
end
diff --git a/spec/integration/knife/common_options_spec.rb b/spec/integration/knife/common_options_spec.rb
index cadd8d66c0..468b7af8be 100644
--- a/spec/integration/knife/common_options_spec.rb
+++ b/spec/integration/knife/common_options_spec.rb
@@ -125,12 +125,12 @@ describe "knife common options", :workstation do
context "when the default port (8889) is already bound" do
before :each do
- begin
- @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.
- end
+
+ @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.
+
end
after :each do
@server.stop if @server
@@ -144,12 +144,12 @@ describe "knife common options", :workstation do
context "when port 9999 is already bound" do
before :each do
- begin
- @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.
- end
+
+ @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.
+
end
after :each do
@server.stop if @server
diff --git a/spec/integration/knife/serve_spec.rb b/spec/integration/knife/serve_spec.rb
index 05018c746e..fa9b1dc47c 100644
--- a/spec/integration/knife/serve_spec.rb
+++ b/spec/integration/knife/serve_spec.rb
@@ -26,11 +26,11 @@ describe "knife serve", :workstation do
def with_knife_serve
exception = nil
t = Thread.new do
- begin
- knife("serve --chef-zero-port=8890")
- rescue
- exception = $!
- end
+
+ knife("serve --chef-zero-port=8890")
+ rescue
+ exception = $!
+
end
begin
Chef::Config.log_level = :debug
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 91e0d31680..6dcd4b0551 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -297,11 +297,11 @@ RSpec.configure do |config|
# Protect Rspec from accidental exit(0) causing rspec to terminate without error
config.around(:example) do |ex|
- begin
- ex.run
- rescue SystemExit => e
- raise UnexpectedSystemExit.from(e)
- end
+
+ ex.run
+ rescue SystemExit => e
+ raise UnexpectedSystemExit.from(e)
+
end
end
diff --git a/spec/support/shared/functional/file_resource.rb b/spec/support/shared/functional/file_resource.rb
index 8319dee41e..77e823a682 100644
--- a/spec/support/shared/functional/file_resource.rb
+++ b/spec/support/shared/functional/file_resource.rb
@@ -476,12 +476,12 @@ shared_examples_for "a configured file resource" do
end
it "issues a warning/assumption in whyrun mode" do
- begin
- Chef::Config[:why_run] = true
- resource.run_action(:create) # should not raise
- ensure
- Chef::Config[:why_run] = false
- end
+
+ Chef::Config[:why_run] = true
+ resource.run_action(:create) # should not raise
+ ensure
+ Chef::Config[:why_run] = false
+
end
end
@@ -504,12 +504,12 @@ shared_examples_for "a configured file resource" do
end
it "issues a warning/assumption in whyrun mode" do
- begin
- Chef::Config[:why_run] = true
- resource.run_action(:create) # should not raise
- ensure
- Chef::Config[:why_run] = false
- end
+
+ Chef::Config[:why_run] = true
+ resource.run_action(:create) # should not raise
+ ensure
+ Chef::Config[:why_run] = false
+
end
end
@@ -535,12 +535,12 @@ shared_examples_for "a configured file resource" do
end
it "issues a warning/assumption in whyrun mode" do
- begin
- Chef::Config[:why_run] = true
- resource.run_action(:create) # should not raise
- ensure
- Chef::Config[:why_run] = false
- end
+
+ Chef::Config[:why_run] = true
+ resource.run_action(:create) # should not raise
+ ensure
+ Chef::Config[:why_run] = false
+
end
end
diff --git a/spec/unit/mixin/template_spec.rb b/spec/unit/mixin/template_spec.rb
index 88a16c2a84..63522839e9 100644
--- a/spec/unit/mixin/template_spec.rb
+++ b/spec/unit/mixin/template_spec.rb
@@ -104,16 +104,16 @@ describe Chef::Mixin::Template, "render_template" do
end
it "should render local files" do
- begin
- tf = Tempfile.new("partial")
- tf.write "test"
- tf.rewind
-
- output = @template_context.render_template_from_string("before {<%= render '#{tf.path}', :local => true %>} after")
- expect(output).to eq("before {test} after")
- ensure
- tf.close
- end
+
+ tf = Tempfile.new("partial")
+ tf.write "test"
+ tf.rewind
+
+ output = @template_context.render_template_from_string("before {<%= render '#{tf.path}', :local => true %>} after")
+ expect(output).to eq("before {test} after")
+ ensure
+ tf.close
+
end
it "should render partials from a different cookbook" do
@@ -124,16 +124,16 @@ describe Chef::Mixin::Template, "render_template" do
end
it "should render using the source argument if provided" do
- begin
- tf = Tempfile.new("partial")
- tf.write "test"
- tf.rewind
-
- output = @template_context.render_template_from_string("before {<%= render 'something', :local => true, :source => '#{tf.path}' %>} after")
- expect(output).to eq("before {test} after")
- ensure
- tf.close
- end
+
+ tf = Tempfile.new("partial")
+ tf.write "test"
+ tf.rewind
+
+ output = @template_context.render_template_from_string("before {<%= render 'something', :local => true, :source => '#{tf.path}' %>} after")
+ expect(output).to eq("before {test} after")
+ ensure
+ tf.close
+
end
it "should pass the node to partials" do
@@ -195,11 +195,11 @@ describe Chef::Mixin::Template, "render_template" do
describe "the raised TemplateError" do
subject(:exception) do
- begin
- do_raise
- rescue Chef::Mixin::Template::TemplateError => e
- e
- end
+
+ do_raise
+ rescue Chef::Mixin::Template::TemplateError => e
+ e
+
end
it "should contain template file and line numbers" do
@@ -274,11 +274,11 @@ describe Chef::Mixin::Template, "render_template" do
describe "the raised TemplateError" do
before :each do
- begin
- do_raise
- rescue Chef::Mixin::Template::TemplateError => e
- @exception = e
- end
+
+ do_raise
+ rescue Chef::Mixin::Template::TemplateError => e
+ @exception = e
+
end
it "should have the original exception" do
diff --git a/spec/unit/mixin/windows_architecture_helper_spec.rb b/spec/unit/mixin/windows_architecture_helper_spec.rb
index 311d9ccea3..b2d64f44b2 100644
--- a/spec/unit/mixin/windows_architecture_helper_spec.rb
+++ b/spec/unit/mixin/windows_architecture_helper_spec.rb
@@ -50,10 +50,10 @@ describe Chef::Mixin::WindowsArchitectureHelper do
it "raises an error if an invalid architecture is passed to assert_valid_windows_architecture!" do
@invalid_architectures.each do |architecture|
- begin
- expect(assert_valid_windows_architecture!(architecture)).to raise_error Chef::Exceptions::Win32ArchitectureIncorrect
- rescue Chef::Exceptions::Win32ArchitectureIncorrect
- end
+
+ expect(assert_valid_windows_architecture!(architecture)).to raise_error Chef::Exceptions::Win32ArchitectureIncorrect
+ rescue Chef::Exceptions::Win32ArchitectureIncorrect
+
end
end
diff --git a/spec/unit/node_spec.rb b/spec/unit/node_spec.rb
index 55a858ce04..ec7beb9a50 100644
--- a/spec/unit/node_spec.rb
+++ b/spec/unit/node_spec.rb
@@ -1773,11 +1773,11 @@ describe Chef::Node do
end
let(:http_exception) do
- begin
- response.error!
- rescue => e
- e
- end
+
+ response.error!
+ rescue => e
+ e
+
end
let(:trimmed_node) do
diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb
index f9559d8827..a845664a0d 100644
--- a/spec/unit/provider/remote_directory_spec.rb
+++ b/spec/unit/provider/remote_directory_spec.rb
@@ -201,17 +201,17 @@ describe Chef::Provider::RemoteDirectory do
@fclass = Chef::CFCCheck.new
Dir.mktmpdir do |tmp_dir|
- begin
- @fclass.file_class.symlink(tmp_dir.dup, symlinked_dir_path)
- expect(::File.exist?(symlinked_dir_path)).to be_truthy
- @provider.run_action
+ @fclass.file_class.symlink(tmp_dir.dup, symlinked_dir_path)
+ expect(::File.exist?(symlinked_dir_path)).to be_truthy
+
+ @provider.run_action
+
+ expect(::File.exist?(symlinked_dir_path)).to be_falsey
+ expect(::File.exist?(tmp_dir)).to be_truthy
+ rescue Chef::Exceptions::Win32APIError
+ skip "This must be run as an Administrator to create symlinks"
- expect(::File.exist?(symlinked_dir_path)).to be_falsey
- expect(::File.exist?(tmp_dir)).to be_truthy
- rescue Chef::Exceptions::Win32APIError
- skip "This must be run as an Administrator to create symlinks"
- end
end
end
end
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index f4212e3a8d..20c07a5c45 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -54,11 +54,11 @@ describe Chef::ProviderResolver do
let(:provider_resolver) { Chef::ProviderResolver.new(node, resource, action) }
let(:resolved_provider) do
- begin
- resource ? resource.provider_for_action(action).class : nil
- rescue Chef::Exceptions::ProviderNotFound
- nil
- end
+
+ resource ? resource.provider_for_action(action).class : nil
+ rescue Chef::Exceptions::ProviderNotFound
+ nil
+
end
let(:service_name) { "test" }