diff options
author | Thom May <thom@chef.io> | 2017-03-21 10:31:40 +0000 |
---|---|---|
committer | Thom May <thom@chef.io> | 2017-04-04 07:18:09 +0100 |
commit | 8f62f18a24e3213ef4b2f13a5abf0135bf6c2429 (patch) | |
tree | 7e3073c1b9a7aeb1fd54b08a191ad3bfcf0674f0 /spec/unit/cookbook/cookbook_version_loader_spec.rb | |
parent | e3b9e67a880bcd658517f90a6add837c0e026798 (diff) | |
download | chef-8f62f18a24e3213ef4b2f13a5abf0135bf6c2429.tar.gz |
RFC 67: Remove cookbook segments
This implements RFC 67, which removes cookbook segments, and moves to a
single list of all the files contained in a cookbook. This allows us to
move forward with better audit modes and also proper shipping of ohai
plugins.
Signed-off-by: Thom May <thom@chef.io>
Diffstat (limited to 'spec/unit/cookbook/cookbook_version_loader_spec.rb')
-rw-r--r-- | spec/unit/cookbook/cookbook_version_loader_spec.rb | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/spec/unit/cookbook/cookbook_version_loader_spec.rb b/spec/unit/cookbook/cookbook_version_loader_spec.rb index 786e17f35b..40a054abee 100644 --- a/spec/unit/cookbook/cookbook_version_loader_spec.rb +++ b/spec/unit/cookbook/cookbook_version_loader_spec.rb @@ -40,42 +40,45 @@ describe Chef::Cookbook::CookbookVersionLoader do File.join(cookbook_path, cookbook_relative_path) end + def full_paths_for_part(part) + loaded_cookbook.files_for(part).inject([]) { |memo, f| memo << f[:full_path]; memo } + end + it "loads attribute files of the cookbook" do - expect(loaded_cookbook.attribute_filenames).to include(full_path("/attributes/default.rb")) - expect(loaded_cookbook.attribute_filenames).to include(full_path("/attributes/smokey.rb")) + expect(full_paths_for_part("attributes")).to include(full_path("/attributes/default.rb")) + expect(full_paths_for_part("attributes")).to include(full_path("/attributes/smokey.rb")) end it "loads definition files" do - expect(loaded_cookbook.definition_filenames).to include(full_path("/definitions/client.rb")) - expect(loaded_cookbook.definition_filenames).to include(full_path("/definitions/server.rb")) + expect(full_paths_for_part("definitions")).to include(full_path("/definitions/client.rb")) + expect(full_paths_for_part("definitions")).to include(full_path("/definitions/server.rb")) end it "loads recipes" do - expect(loaded_cookbook.recipe_filenames).to include(full_path("/recipes/default.rb")) - expect(loaded_cookbook.recipe_filenames).to include(full_path("/recipes/gigantor.rb")) - expect(loaded_cookbook.recipe_filenames).to include(full_path("/recipes/one.rb")) - expect(loaded_cookbook.recipe_filenames).to include(full_path("/recipes/return.rb")) + expect(full_paths_for_part("recipes")).to include(full_path("/recipes/default.rb")) + expect(full_paths_for_part("recipes")).to include(full_path("/recipes/gigantor.rb")) + expect(full_paths_for_part("recipes")).to include(full_path("/recipes/one.rb")) + expect(full_paths_for_part("recipes")).to include(full_path("/recipes/return.rb")) end it "loads libraries" do - expect(loaded_cookbook.library_filenames).to include(full_path("/libraries/openldap.rb")) - expect(loaded_cookbook.library_filenames).to include(full_path("/libraries/openldap/version.rb")) + expect(full_paths_for_part("libraries")).to include(full_path("/libraries/openldap.rb")) + expect(full_paths_for_part("libraries")).to include(full_path("/libraries/openldap/version.rb")) end it "loads static files in the files/ dir" do - expect(loaded_cookbook.file_filenames).to include(full_path("/files/default/remotedir/remotesubdir/remote_subdir_file1.txt")) - expect(loaded_cookbook.file_filenames).to include(full_path("/files/default/remotedir/remotesubdir/remote_subdir_file2.txt")) + expect(full_paths_for_part("files")).to include(full_path("/files/default/remotedir/remotesubdir/remote_subdir_file1.txt")) + expect(full_paths_for_part("files")).to include(full_path("/files/default/remotedir/remotesubdir/remote_subdir_file2.txt")) end it "loads files that start with a ." do - expect(loaded_cookbook.file_filenames).to include(full_path("/files/default/.dotfile")) - expect(loaded_cookbook.file_filenames).to include(full_path("/files/default/.ssh/id_rsa")) - expect(loaded_cookbook.file_filenames).to include(full_path("/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir")) + expect(full_paths_for_part("files")).to include(full_path("/files/default/.dotfile")) + expect(full_paths_for_part("files")).to include(full_path("/files/default/.ssh/id_rsa")) + expect(full_paths_for_part("files")).to include(full_path("/files/default/remotedir/.a_dotdir/.a_dotfile_in_a_dotdir")) end it "loads root files that start with a ." do expect(loaded_cookbook.all_files).to include(full_path(".root_dotfile")) - expect(loaded_cookbook.root_filenames).to include(full_path(".root_dotfile")) end it "loads all unignored files, even if they don't match a segment type" do @@ -97,9 +100,9 @@ describe Chef::Cookbook::CookbookVersionLoader do let(:cookbook_path) { File.join(CHEF_SPEC_DATA, "kitchen/openldap") } it "skips ignored files" do - expect(loaded_cookbook.recipe_filenames).to include(full_path("recipes/gigantor.rb")) - expect(loaded_cookbook.recipe_filenames).to include(full_path("recipes/woot.rb")) - expect(loaded_cookbook.recipe_filenames).to_not include(full_path("recipes/ignoreme.rb")) + expect(full_paths_for_part("recipes")).to include(full_path("recipes/gigantor.rb")) + expect(full_paths_for_part("recipes")).to include(full_path("recipes/woot.rb")) + expect(full_paths_for_part("recipes")).to_not include(full_path("recipes/ignoreme.rb")) end end |