diff --git a/libraries/dir_utils.rb b/libraries/dir_utils.rb index 9a7517c1..5c2f5853 100644 --- a/libraries/dir_utils.rb +++ b/libraries/dir_utils.rb @@ -1,17 +1,15 @@ module Ark module DirUtils - # Delete all files and directories inside the given directory. # @param work_dir Path of the directory to be cleaned up. def delete_files_and_directories_inside(work_dir) # Ensure we only have "/"-like separators in the provided path # (windows path separator is not supported by Dir) - directory_content_pattern = ::File.join(work_dir, "*").gsub(%r:\\:, "/") + directory_content_pattern = ::File.join(work_dir, '*').gsub(/\\/, '/') ::Dir[directory_content_pattern].each do |path| ::FileUtils.rm_rf(path) end end - end end diff --git a/spec/resources/default_spec.rb b/spec/resources/default_spec.rb index b9635103..614198c3 100644 --- a/spec/resources/default_spec.rb +++ b/spec/resources/default_spec.rb @@ -136,7 +136,7 @@ end def node_attributes - { platform: 'windows', version: '2008R2', file_cache_path: "/var/chef/cache" } + { platform: 'windows', version: '2008R2', file_cache_path: '/var/chef/cache' } end it 'installs' do @@ -165,17 +165,17 @@ def node_attributes end end - describe "install with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::install_with_clean_up_before_unpack" } + describe 'install with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::install_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to install_ark("test_install") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to install_ark('test_install') - resource = chef_run.directory("/usr/local/test_install-2") - expect(resource).to notify("ruby_block[clean up /usr/local/test_install-2 before unpack]") + resource = chef_run.directory('/usr/local/test_install-2') + expect(resource).to notify('ruby_block[clean up /usr/local/test_install-2 before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_install-2.tar.gz") - expect(resource).to notify("ruby_block[clean up /usr/local/test_install-2 before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_install-2.tar.gz') + expect(resource).to notify('ruby_block[clean up /usr/local/test_install-2 before unpack]') end end @@ -198,17 +198,17 @@ def node_attributes end end - describe "put with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::put_with_clean_up_before_unpack" } + describe 'put with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::put_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to put_ark("test_put") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to put_ark('test_put') - resource = chef_run.directory("/usr/local/test_put") - expect(resource).to notify("ruby_block[clean up /usr/local/test_put before unpack]") + resource = chef_run.directory('/usr/local/test_put') + expect(resource).to notify('ruby_block[clean up /usr/local/test_put before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_put.tar.gz") - expect(resource).to notify("ruby_block[clean up /usr/local/test_put before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_put.tar.gz') + expect(resource).to notify('ruby_block[clean up /usr/local/test_put before unpack]') end end @@ -231,17 +231,17 @@ def node_attributes end end - describe "dump with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::dump_with_clean_up_before_unpack" } + describe 'dump with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::dump_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to dump_ark("test_dump") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to dump_ark('test_dump') - resource = chef_run.directory("/usr/local/foo_dump") - expect(resource).to notify("ruby_block[clean up /usr/local/foo_dump before unpack]") + resource = chef_run.directory('/usr/local/foo_dump') + expect(resource).to notify('ruby_block[clean up /usr/local/foo_dump before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_dump.zip") - expect(resource).to notify("ruby_block[clean up /usr/local/foo_dump before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_dump.zip') + expect(resource).to notify('ruby_block[clean up /usr/local/foo_dump before unpack]') end end @@ -264,17 +264,17 @@ def node_attributes end end - describe "unzip with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::unzip_with_clean_up_before_unpack" } + describe 'unzip with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::unzip_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to unzip_ark("test_unzip") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to unzip_ark('test_unzip') - resource = chef_run.directory("/usr/local/foo_dump") - expect(resource).to notify("ruby_block[clean up /usr/local/foo_dump before unpack]") + resource = chef_run.directory('/usr/local/foo_dump') + expect(resource).to notify('ruby_block[clean up /usr/local/foo_dump before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_unzip.zip") - expect(resource).to notify("ruby_block[clean up /usr/local/foo_dump before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_unzip.zip') + expect(resource).to notify('ruby_block[clean up /usr/local/foo_dump before unpack]') end end @@ -300,17 +300,17 @@ def node_attributes end end - describe "cherry_pick with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::cherry_pick_with_clean_up_before_unpack" } + describe 'cherry_pick with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::cherry_pick_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to cherry_pick_ark("test_cherry_pick") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to cherry_pick_ark('test_cherry_pick') - resource = chef_run.directory("/usr/local/foo_cherry_pick") - expect(resource).to notify("ruby_block[clean up /usr/local/foo_cherry_pick before unpack]") + resource = chef_run.directory('/usr/local/foo_cherry_pick') + expect(resource).to notify('ruby_block[clean up /usr/local/foo_cherry_pick before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_cherry_pick.tar.gz") - expect(resource).to notify("ruby_block[clean up /usr/local/foo_cherry_pick before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_cherry_pick.tar.gz') + expect(resource).to notify('ruby_block[clean up /usr/local/foo_cherry_pick before unpack]') end end @@ -338,17 +338,17 @@ def node_attributes end end - describe "setup_py_build with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::setup_py_build_with_clean_up_before_unpack" } + describe 'setup_py_build with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::setup_py_build_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to setup_py_build_ark("test_setup_py_build") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to setup_py_build_ark('test_setup_py_build') - resource = chef_run.directory("/usr/local/test_setup_py_build-1") - expect(resource).to notify("ruby_block[clean up /usr/local/test_setup_py_build-1 before unpack]") + resource = chef_run.directory('/usr/local/test_setup_py_build-1') + expect(resource).to notify('ruby_block[clean up /usr/local/test_setup_py_build-1 before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_setup_py_build-1.tar.gz") - expect(resource).to notify("ruby_block[clean up /usr/local/test_setup_py_build-1 before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_setup_py_build-1.tar.gz') + expect(resource).to notify('ruby_block[clean up /usr/local/test_setup_py_build-1 before unpack]') end end @@ -373,17 +373,17 @@ def node_attributes end end - describe "setup_py_install with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::setup_py_install_with_clean_up_before_unpack" } + describe 'setup_py_install with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::setup_py_install_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to setup_py_install_ark("test_setup_py_install") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to setup_py_install_ark('test_setup_py_install') - resource = chef_run.directory("/usr/local/test_setup_py_install-1") - expect(resource).to notify("ruby_block[clean up /usr/local/test_setup_py_install-1 before unpack]") + resource = chef_run.directory('/usr/local/test_setup_py_install-1') + expect(resource).to notify('ruby_block[clean up /usr/local/test_setup_py_install-1 before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_setup_py_install-1.tar.gz") - expect(resource).to notify("ruby_block[clean up /usr/local/test_setup_py_install-1 before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_setup_py_install-1.tar.gz') + expect(resource).to notify('ruby_block[clean up /usr/local/test_setup_py_install-1 before unpack]') end end @@ -408,17 +408,17 @@ def node_attributes end end - describe "setup_py with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::setup_py_with_clean_up_before_unpack" } + describe 'setup_py with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::setup_py_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to setup_py_ark("test_setup_py") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to setup_py_ark('test_setup_py') - resource = chef_run.directory("/usr/local/test_setup_py-1") - expect(resource).to notify("ruby_block[clean up /usr/local/test_setup_py-1 before unpack]") + resource = chef_run.directory('/usr/local/test_setup_py-1') + expect(resource).to notify('ruby_block[clean up /usr/local/test_setup_py-1 before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_setup_py-1.tar.gz") - expect(resource).to notify("ruby_block[clean up /usr/local/test_setup_py-1 before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_setup_py-1.tar.gz') + expect(resource).to notify('ruby_block[clean up /usr/local/test_setup_py-1 before unpack]') end end @@ -452,17 +452,17 @@ def node_attributes end end - describe "install_with_make with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::install_with_make_with_clean_up_before_unpack" } + describe 'install_with_make with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::install_with_make_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to install_with_make_ark("test_install_with_make") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to install_with_make_ark('test_install_with_make') - resource = chef_run.directory("/usr/local/test_install_with_make-1.5") - expect(resource).to notify("ruby_block[clean up /usr/local/test_install_with_make-1.5 before unpack]") + resource = chef_run.directory('/usr/local/test_install_with_make-1.5') + expect(resource).to notify('ruby_block[clean up /usr/local/test_install_with_make-1.5 before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_install_with_make-1.5.tar.gz") - expect(resource).to notify("ruby_block[clean up /usr/local/test_install_with_make-1.5 before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_install_with_make-1.5.tar.gz') + expect(resource).to notify('ruby_block[clean up /usr/local/test_install_with_make-1.5 before unpack]') end end @@ -492,17 +492,17 @@ def node_attributes end end - describe "configure with clean_up_before_unpack == true", wip: true do - let(:example_recipe) { "ark_spec::configure_with_clean_up_before_unpack" } + describe 'configure with clean_up_before_unpack == true', wip: true do + let(:example_recipe) { 'ark_spec::configure_with_clean_up_before_unpack' } - it "cleans up target directory before to unpack the archive" do - expect(chef_run).to configure_ark("test_configure") + it 'cleans up target directory before to unpack the archive' do + expect(chef_run).to configure_ark('test_configure') - resource = chef_run.directory("/usr/local/test_configure-1") - expect(resource).to notify("ruby_block[clean up /usr/local/test_configure-1 before unpack]") + resource = chef_run.directory('/usr/local/test_configure-1') + expect(resource).to notify('ruby_block[clean up /usr/local/test_configure-1 before unpack]') - resource = chef_run.remote_file("/var/chef/cache/test_configure-1.tar.gz") - expect(resource).to notify("ruby_block[clean up /usr/local/test_configure-1 before unpack]") + resource = chef_run.remote_file('/var/chef/cache/test_configure-1.tar.gz') + expect(resource).to notify('ruby_block[clean up /usr/local/test_configure-1 before unpack]') end end end