diff options
Diffstat (limited to 'spec/unit/chef_fs')
-rw-r--r-- | spec/unit/chef_fs/config_spec.rb | 18 | ||||
-rw-r--r-- | spec/unit/chef_fs/data_handler/group_handler_spec.rb | 30 | ||||
-rw-r--r-- | spec/unit/chef_fs/diff_spec.rb | 120 | ||||
-rw-r--r-- | spec/unit/chef_fs/file_pattern_spec.rb | 732 | ||||
-rw-r--r-- | spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb | 12 | ||||
-rw-r--r-- | spec/unit/chef_fs/file_system/operation_failed_error_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/chef_fs/file_system_spec.rb | 138 | ||||
-rw-r--r-- | spec/unit/chef_fs/parallelizer.rb | 50 | ||||
-rw-r--r-- | spec/unit/chef_fs/path_util_spec.rb | 88 |
9 files changed, 601 insertions, 601 deletions
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 |