diff options
author | Maxime Brugidou <m.brugidou@criteo.com> | 2015-10-13 12:52:53 +0200 |
---|---|---|
committer | Bryan McLellan <btm@chef.io> | 2015-11-25 12:41:46 -0500 |
commit | 199ec5d16985b6717e0a3b23594ca90c4c50e9c3 (patch) | |
tree | 9bb26ea528601610b16a0c371eef15303345876d | |
parent | 5fd2df311af0b5867c6c845321901f841fc1c7de (diff) | |
download | chef-199ec5d16985b6717e0a3b23594ca90c4c50e9c3.tar.gz |
Add make_child_entry in ChefFS CookbookSubdir
Following a517fa8a we can't call `child` on cookbook subdirs.
-rw-r--r-- | lib/chef/chef_fs/file_system/cookbook_subdir.rb | 5 | ||||
-rw-r--r-- | spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb | 34 |
2 files changed, 39 insertions, 0 deletions
diff --git a/lib/chef/chef_fs/file_system/cookbook_subdir.rb b/lib/chef/chef_fs/file_system/cookbook_subdir.rb index 73c709e01e..e7a6d3bccd 100644 --- a/lib/chef/chef_fs/file_system/cookbook_subdir.rb +++ b/lib/chef/chef_fs/file_system/cookbook_subdir.rb @@ -45,6 +45,11 @@ class Chef true end + def make_child_entry(name) + result = @children.select { |child| child.name == name }.first if @children + result || NonexistentFSObject.new(name, self) + end + def rest parent.rest 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 new file mode 100644 index 0000000000..94a636fc0a --- /dev/null +++ b/spec/unit/chef_fs/file_system/cookbook_subdir_spec.rb @@ -0,0 +1,34 @@ +# +# Author:: John Keiser (<jkeiser@opscode.com>) +# Copyright:: Copyright (c) 2012 Opscode, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +require 'spec_helper' +require 'chef/chef_fs/file_system/cookbook_subdir' + +describe Chef::ChefFS::FileSystem::CookbookSubdir do + let(:root) do + Chef::ChefFS::FileSystem::BaseFSDir.new('', nil) + end + + let(:cookbook_subdir) do + Chef::ChefFS::FileSystem::CookbookSubdir.new('test', root, false, true) + end + + it 'can get child' do + cookbook_subdir.child('test') + end +end |