diff options
Diffstat (limited to 'spec/integration/knife')
-rw-r--r-- | spec/integration/knife/chef_fs_data_store_spec.rb | 298 | ||||
-rw-r--r-- | spec/integration/knife/chef_repo_path_spec.rb | 496 | ||||
-rw-r--r-- | spec/integration/knife/chef_repository_file_system_spec.rb | 164 | ||||
-rw-r--r-- | spec/integration/knife/chefignore_spec.rb | 160 | ||||
-rw-r--r-- | spec/integration/knife/common_options_spec.rb | 78 | ||||
-rw-r--r-- | spec/integration/knife/cookbook_api_ipv6_spec.rb | 8 | ||||
-rw-r--r-- | spec/integration/knife/delete_spec.rb | 512 | ||||
-rw-r--r-- | spec/integration/knife/deps_spec.rb | 556 | ||||
-rw-r--r-- | spec/integration/knife/diff_spec.rb | 466 | ||||
-rw-r--r-- | spec/integration/knife/download_spec.rb | 876 | ||||
-rw-r--r-- | spec/integration/knife/list_spec.rb | 266 | ||||
-rw-r--r-- | spec/integration/knife/raw_spec.rb | 74 | ||||
-rw-r--r-- | spec/integration/knife/redirection_spec.rb | 20 | ||||
-rw-r--r-- | spec/integration/knife/serve_spec.rb | 20 | ||||
-rw-r--r-- | spec/integration/knife/show_spec.rb | 114 | ||||
-rw-r--r-- | spec/integration/knife/upload_spec.rb | 1180 |
16 files changed, 2644 insertions, 2644 deletions
diff --git a/spec/integration/knife/chef_fs_data_store_spec.rb b/spec/integration/knife/chef_fs_data_store_spec.rb index c1f2c7134f..b4f2d4ca71 100644 --- a/spec/integration/knife/chef_fs_data_store_spec.rb +++ b/spec/integration/knife/chef_fs_data_store_spec.rb @@ -15,14 +15,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/list' -require 'chef/knife/delete' -require 'chef/knife/show' -require 'chef/knife/raw' -require 'chef/knife/cookbook_upload' - -describe 'ChefFSDataStore tests', :workstation do +require "support/shared/integration/integration_helper" +require "chef/knife/list" +require "chef/knife/delete" +require "chef/knife/show" +require "chef/knife/raw" +require "chef/knife/cookbook_upload" + +describe "ChefFSDataStore tests", :workstation do include IntegrationSupport include KnifeSupport @@ -31,18 +31,18 @@ describe 'ChefFSDataStore tests', :workstation do when_the_repository "has one of each thing" do before do - file 'clients/x.json', {} - file 'cookbooks/x/metadata.rb', cookbook_x_100_metadata_rb - file 'data_bags/x/y.json', {} - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/x.json', {} + file "clients/x.json", {} + file "cookbooks/x/metadata.rb", cookbook_x_100_metadata_rb + file "data_bags/x/y.json", {} + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/x.json", {} end - context 'GET /TYPE' do - it 'knife list -z -R returns everything' do - knife('list -z -Rfp /').should_succeed <<EOM + context "GET /TYPE" do + it "knife list -z -R returns everything" do + knife("list -z -Rfp /").should_succeed <<EOM /clients/ /clients/x.json /cookbooks/ @@ -63,128 +63,128 @@ EOM end end - context 'DELETE /TYPE/NAME' do - it 'knife delete -z /clients/x.json works' do - knife('delete -z /clients/x.json').should_succeed "Deleted /clients/x.json\n" - knife('list -z -Rfp /clients').should_succeed '' + context "DELETE /TYPE/NAME" do + it "knife delete -z /clients/x.json works" do + knife("delete -z /clients/x.json").should_succeed "Deleted /clients/x.json\n" + knife("list -z -Rfp /clients").should_succeed "" end - it 'knife delete -z -r /cookbooks/x works' do - knife('delete -z -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -z -Rfp /cookbooks').should_succeed '' + it "knife delete -z -r /cookbooks/x works" do + knife("delete -z -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -z -Rfp /cookbooks").should_succeed "" end - it 'knife delete -z -r /data_bags/x works' do - knife('delete -z -r /data_bags/x').should_succeed "Deleted /data_bags/x\n" - knife('list -z -Rfp /data_bags').should_succeed '' + it "knife delete -z -r /data_bags/x works" do + knife("delete -z -r /data_bags/x").should_succeed "Deleted /data_bags/x\n" + knife("list -z -Rfp /data_bags").should_succeed "" end - it 'knife delete -z /data_bags/x/y.json works' do - knife('delete -z /data_bags/x/y.json').should_succeed "Deleted /data_bags/x/y.json\n" - knife('list -z -Rfp /data_bags').should_succeed "/data_bags/x/\n" + it "knife delete -z /data_bags/x/y.json works" do + knife("delete -z /data_bags/x/y.json").should_succeed "Deleted /data_bags/x/y.json\n" + knife("list -z -Rfp /data_bags").should_succeed "/data_bags/x/\n" end - it 'knife delete -z /environments/x.json works' do - knife('delete -z /environments/x.json').should_succeed "Deleted /environments/x.json\n" - knife('list -z -Rfp /environments').should_succeed '' + it "knife delete -z /environments/x.json works" do + knife("delete -z /environments/x.json").should_succeed "Deleted /environments/x.json\n" + knife("list -z -Rfp /environments").should_succeed "" end - it 'knife delete -z /nodes/x.json works' do - knife('delete -z /nodes/x.json').should_succeed "Deleted /nodes/x.json\n" - knife('list -z -Rfp /nodes').should_succeed '' + it "knife delete -z /nodes/x.json works" do + knife("delete -z /nodes/x.json").should_succeed "Deleted /nodes/x.json\n" + knife("list -z -Rfp /nodes").should_succeed "" end - it 'knife delete -z /roles/x.json works' do - knife('delete -z /roles/x.json').should_succeed "Deleted /roles/x.json\n" - knife('list -z -Rfp /roles').should_succeed '' + it "knife delete -z /roles/x.json works" do + knife("delete -z /roles/x.json").should_succeed "Deleted /roles/x.json\n" + knife("list -z -Rfp /roles").should_succeed "" end - it 'knife delete -z /users/x.json works' do - knife('delete -z /users/x.json').should_succeed "Deleted /users/x.json\n" - knife('list -z -Rfp /users').should_succeed '' + it "knife delete -z /users/x.json works" do + knife("delete -z /users/x.json").should_succeed "Deleted /users/x.json\n" + knife("list -z -Rfp /users").should_succeed "" end end - context 'GET /TYPE/NAME' do - it 'knife show -z /clients/x.json works' do - knife('show -z /clients/x.json').should_succeed( /"x"/ ) + context "GET /TYPE/NAME" do + it "knife show -z /clients/x.json works" do + knife("show -z /clients/x.json").should_succeed( /"x"/ ) end - it 'knife show -z /cookbooks/x/metadata.rb works' do - knife('show -z /cookbooks/x/metadata.rb').should_succeed "/cookbooks/x/metadata.rb:\n#{cookbook_x_100_metadata_rb}\n" + it "knife show -z /cookbooks/x/metadata.rb works" do + knife("show -z /cookbooks/x/metadata.rb").should_succeed "/cookbooks/x/metadata.rb:\n#{cookbook_x_100_metadata_rb}\n" end - it 'knife show -z /data_bags/x/y.json works' do - knife('show -z /data_bags/x/y.json').should_succeed( /"y"/ ) + it "knife show -z /data_bags/x/y.json works" do + knife("show -z /data_bags/x/y.json").should_succeed( /"y"/ ) end - it 'knife show -z /environments/x.json works' do - knife('show -z /environments/x.json').should_succeed( /"x"/ ) + it "knife show -z /environments/x.json works" do + knife("show -z /environments/x.json").should_succeed( /"x"/ ) end - it 'knife show -z /nodes/x.json works' do - knife('show -z /nodes/x.json').should_succeed( /"x"/ ) + it "knife show -z /nodes/x.json works" do + knife("show -z /nodes/x.json").should_succeed( /"x"/ ) end - it 'knife show -z /roles/x.json works' do - knife('show -z /roles/x.json').should_succeed( /"x"/ ) + it "knife show -z /roles/x.json works" do + knife("show -z /roles/x.json").should_succeed( /"x"/ ) end - it 'knife show -z /users/x.json works' do - knife('show -z /users/x.json').should_succeed( /"x"/ ) + it "knife show -z /users/x.json works" do + knife("show -z /users/x.json").should_succeed( /"x"/ ) end end - context 'PUT /TYPE/NAME' do + context "PUT /TYPE/NAME" do before do - file 'empty.json', {} - file 'dummynode.json', { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} - file 'rolestuff.json', '{"description":"hi there","name":"x"}' - file 'cookbooks_to_upload/x/metadata.rb', cookbook_x_100_metadata_rb + file "empty.json", {} + file "dummynode.json", { "name" => "x", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} + file "rolestuff.json", '{"description":"hi there","name":"x"}' + file "cookbooks_to_upload/x/metadata.rb", cookbook_x_100_metadata_rb end - it 'knife raw -z -i empty.json -m PUT /clients/x' do + it "knife raw -z -i empty.json -m PUT /clients/x" do knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_succeed( /"x"/ ) - knife('list --local /clients').should_succeed "/clients/x.json\n" + knife("list --local /clients").should_succeed "/clients/x.json\n" end - it 'knife cookbook upload works' do + it "knife cookbook upload works" do knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} x").should_succeed :stderr => <<EOM Uploading x [1.0.0] Uploaded 1 cookbook. EOM - knife('list --local -Rfp /cookbooks').should_succeed "/cookbooks/x/\n/cookbooks/x/metadata.rb\n" + knife("list --local -Rfp /cookbooks").should_succeed "/cookbooks/x/\n/cookbooks/x/metadata.rb\n" end - it 'knife raw -z -i empty.json -m PUT /data/x/y' do + it "knife raw -z -i empty.json -m PUT /data/x/y" do knife("raw -z -i #{path_to('empty.json')} -m PUT /data/x/y").should_succeed( /"y"/ ) - knife('list --local -Rfp /data_bags').should_succeed "/data_bags/x/\n/data_bags/x/y.json\n" + knife("list --local -Rfp /data_bags").should_succeed "/data_bags/x/\n/data_bags/x/y.json\n" end - it 'knife raw -z -i empty.json -m PUT /environments/x' do + it "knife raw -z -i empty.json -m PUT /environments/x" do knife("raw -z -i #{path_to('empty.json')} -m PUT /environments/x").should_succeed( /"x"/ ) - knife('list --local /environments').should_succeed "/environments/x.json\n" + knife("list --local /environments").should_succeed "/environments/x.json\n" end - it 'knife raw -z -i dummynode.json -m PUT /nodes/x' do + it "knife raw -z -i dummynode.json -m PUT /nodes/x" do knife("raw -z -i #{path_to('dummynode.json')} -m PUT /nodes/x").should_succeed( /"x"/ ) - knife('list --local /nodes').should_succeed "/nodes/x.json\n" - knife('show -z /nodes/x.json --verbose').should_succeed /"bar"/ + knife("list --local /nodes").should_succeed "/nodes/x.json\n" + knife("show -z /nodes/x.json --verbose").should_succeed /"bar"/ end - it 'knife raw -z -i empty.json -m PUT /roles/x' do + it "knife raw -z -i empty.json -m PUT /roles/x" do knife("raw -z -i #{path_to('empty.json')} -m PUT /roles/x").should_succeed( /"x"/ ) - knife('list --local /roles').should_succeed "/roles/x.json\n" + knife("list --local /roles").should_succeed "/roles/x.json\n" end - it 'knife raw -z -i empty.json -m PUT /users/x' do + it "knife raw -z -i empty.json -m PUT /users/x" do knife("raw -z -i #{path_to('empty.json')} -m PUT /users/x").should_succeed( /"x"/ ) - knife('list --local /users').should_succeed "/users/x.json\n" + knife("list --local /users").should_succeed "/users/x.json\n" end - it 'After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty', :skip => (RUBY_VERSION < "1.9") do + it "After knife raw -z -i rolestuff.json -m PUT /roles/x, the output is pretty", :skip => (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m PUT /roles/x").should_succeed( /"x"/ ) - expect(IO.read(path_to('roles/x.json'))).to eq <<EOM.strip + expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip { "name": "x", "description": "hi there" @@ -194,65 +194,65 @@ EOM end end - when_the_repository 'is empty' do - context 'POST /TYPE/NAME' do + when_the_repository "is empty" do + context "POST /TYPE/NAME" do before do - file 'empty.json', { 'name' => 'z' } - file 'dummynode.json', { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} - file 'empty_x.json', { 'name' => 'x' } - file 'empty_id.json', { 'id' => 'z' } - file 'rolestuff.json', '{"description":"hi there","name":"x"}' - file 'cookbooks_to_upload/z/metadata.rb', cookbook_z_100_metadata_rb + file "empty.json", { "name" => "z" } + file "dummynode.json", { "name" => "z", "chef_environment" => "rspec" , "json_class" => "Chef::Node", "normal" => {"foo" => "bar"}} + file "empty_x.json", { "name" => "x" } + file "empty_id.json", { "id" => "z" } + file "rolestuff.json", '{"description":"hi there","name":"x"}' + file "cookbooks_to_upload/z/metadata.rb", cookbook_z_100_metadata_rb end - it 'knife raw -z -i empty.json -m POST /clients' do + it "knife raw -z -i empty.json -m POST /clients" do knife("raw -z -i #{path_to('empty.json')} -m POST /clients").should_succeed( /uri/ ) - knife('list --local /clients').should_succeed "/clients/z.json\n" + knife("list --local /clients").should_succeed "/clients/z.json\n" end - it 'knife cookbook upload works' do + it "knife cookbook upload works" do knife("cookbook upload -z --cookbook-path #{path_to('cookbooks_to_upload')} z").should_succeed :stderr => <<EOM Uploading z [1.0.0] Uploaded 1 cookbook. EOM - knife('list --local -Rfp /cookbooks').should_succeed "/cookbooks/z/\n/cookbooks/z/metadata.rb\n" + knife("list --local -Rfp /cookbooks").should_succeed "/cookbooks/z/\n/cookbooks/z/metadata.rb\n" end - it 'knife raw -z -i empty.json -m POST /data' do + it "knife raw -z -i empty.json -m POST /data" do knife("raw -z -i #{path_to('empty.json')} -m POST /data").should_succeed( /uri/ ) - knife('list --local -Rfp /data_bags').should_succeed "/data_bags/z/\n" + knife("list --local -Rfp /data_bags").should_succeed "/data_bags/z/\n" end - it 'knife raw -z -i empty.json -m POST /data/x' do + it "knife raw -z -i empty.json -m POST /data/x" do knife("raw -z -i #{path_to('empty_x.json')} -m POST /data").should_succeed( /uri/ ) knife("raw -z -i #{path_to('empty_id.json')} -m POST /data/x").should_succeed( /"z"/ ) - knife('list --local -Rfp /data_bags').should_succeed "/data_bags/x/\n/data_bags/x/z.json\n" + knife("list --local -Rfp /data_bags").should_succeed "/data_bags/x/\n/data_bags/x/z.json\n" end - it 'knife raw -z -i empty.json -m POST /environments' do + it "knife raw -z -i empty.json -m POST /environments" do knife("raw -z -i #{path_to('empty.json')} -m POST /environments").should_succeed( /uri/ ) - knife('list --local /environments').should_succeed "/environments/z.json\n" + knife("list --local /environments").should_succeed "/environments/z.json\n" end - it 'knife raw -z -i dummynode.json -m POST /nodes' do + it "knife raw -z -i dummynode.json -m POST /nodes" do knife("raw -z -i #{path_to('dummynode.json')} -m POST /nodes").should_succeed( /uri/ ) - knife('list --local /nodes').should_succeed "/nodes/z.json\n" - knife('show -z /nodes/z.json').should_succeed /"bar"/ + knife("list --local /nodes").should_succeed "/nodes/z.json\n" + knife("show -z /nodes/z.json").should_succeed /"bar"/ end - it 'knife raw -z -i empty.json -m POST /roles' do + it "knife raw -z -i empty.json -m POST /roles" do knife("raw -z -i #{path_to('empty.json')} -m POST /roles").should_succeed( /uri/ ) - knife('list --local /roles').should_succeed "/roles/z.json\n" + knife("list --local /roles").should_succeed "/roles/z.json\n" end - it 'knife raw -z -i empty.json -m POST /users' do + it "knife raw -z -i empty.json -m POST /users" do knife("raw -z -i #{path_to('empty.json')} -m POST /users").should_succeed( /uri/ ) - knife('list --local /users').should_succeed "/users/z.json\n" + knife("list --local /users").should_succeed "/users/z.json\n" end - it 'After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty', :skip => (RUBY_VERSION < "1.9") do + it "After knife raw -z -i rolestuff.json -m POST /roles, the output is pretty", :skip => (RUBY_VERSION < "1.9") do knife("raw -z -i #{path_to('rolestuff.json')} -m POST /roles").should_succeed( /uri/ ) - expect(IO.read(path_to('roles/x.json'))).to eq <<EOM.strip + expect(IO.read(path_to("roles/x.json"))).to eq <<EOM.strip { "name": "x", "description": "hi there" @@ -261,8 +261,8 @@ EOM end end - it 'knife list -z -R returns nothing' do - knife('list -z -Rfp /').should_succeed <<EOM + it "knife list -z -R returns nothing" do + knife("list -z -Rfp /").should_succeed <<EOM /clients/ /cookbooks/ /data_bags/ @@ -273,96 +273,96 @@ EOM EOM end - context 'DELETE /TYPE/NAME' do - it 'knife delete -z /clients/x.json fails with an error' do - knife('delete -z /clients/x.json').should_fail "ERROR: /clients/x.json: No such file or directory\n" + context "DELETE /TYPE/NAME" do + it "knife delete -z /clients/x.json fails with an error" do + knife("delete -z /clients/x.json").should_fail "ERROR: /clients/x.json: No such file or directory\n" end - it 'knife delete -z -r /cookbooks/x fails with an error' do - knife('delete -z -r /cookbooks/x').should_fail "ERROR: /cookbooks/x: No such file or directory\n" + it "knife delete -z -r /cookbooks/x fails with an error" do + knife("delete -z -r /cookbooks/x").should_fail "ERROR: /cookbooks/x: No such file or directory\n" end - it 'knife delete -z -r /data_bags/x fails with an error' do - knife('delete -z -r /data_bags/x').should_fail "ERROR: /data_bags/x: No such file or directory\n" + it "knife delete -z -r /data_bags/x fails with an error" do + knife("delete -z -r /data_bags/x").should_fail "ERROR: /data_bags/x: No such file or directory\n" end - it 'knife delete -z /data_bags/x/y.json fails with an error' do - knife('delete -z /data_bags/x/y.json').should_fail "ERROR: /data_bags/x/y.json: No such file or directory\n" + it "knife delete -z /data_bags/x/y.json fails with an error" do + knife("delete -z /data_bags/x/y.json").should_fail "ERROR: /data_bags/x/y.json: No such file or directory\n" end - it 'knife delete -z /environments/x.json fails with an error' do - knife('delete -z /environments/x.json').should_fail "ERROR: /environments/x.json: No such file or directory\n" + it "knife delete -z /environments/x.json fails with an error" do + knife("delete -z /environments/x.json").should_fail "ERROR: /environments/x.json: No such file or directory\n" end - it 'knife delete -z /nodes/x.json fails with an error' do - knife('delete -z /nodes/x.json').should_fail "ERROR: /nodes/x.json: No such file or directory\n" + it "knife delete -z /nodes/x.json fails with an error" do + knife("delete -z /nodes/x.json").should_fail "ERROR: /nodes/x.json: No such file or directory\n" end - it 'knife delete -z /roles/x.json fails with an error' do - knife('delete -z /roles/x.json').should_fail "ERROR: /roles/x.json: No such file or directory\n" + it "knife delete -z /roles/x.json fails with an error" do + knife("delete -z /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n" end - it 'knife delete -z /users/x.json fails with an error' do - knife('delete -z /users/x.json').should_fail "ERROR: /users/x.json: No such file or directory\n" + it "knife delete -z /users/x.json fails with an error" do + knife("delete -z /users/x.json").should_fail "ERROR: /users/x.json: No such file or directory\n" end end - context 'GET /TYPE/NAME' do - it 'knife show -z /clients/x.json fails with an error' do - knife('show -z /clients/x.json').should_fail "ERROR: /clients/x.json: No such file or directory\n" + context "GET /TYPE/NAME" do + it "knife show -z /clients/x.json fails with an error" do + knife("show -z /clients/x.json").should_fail "ERROR: /clients/x.json: No such file or directory\n" end - it 'knife show -z /cookbooks/x/metadata.rb fails with an error' do - knife('show -z /cookbooks/x/metadata.rb').should_fail "ERROR: /cookbooks/x/metadata.rb: No such file or directory\n" + it "knife show -z /cookbooks/x/metadata.rb fails with an error" do + knife("show -z /cookbooks/x/metadata.rb").should_fail "ERROR: /cookbooks/x/metadata.rb: No such file or directory\n" end - it 'knife show -z /data_bags/x/y.json fails with an error' do - knife('show -z /data_bags/x/y.json').should_fail "ERROR: /data_bags/x/y.json: No such file or directory\n" + it "knife show -z /data_bags/x/y.json fails with an error" do + knife("show -z /data_bags/x/y.json").should_fail "ERROR: /data_bags/x/y.json: No such file or directory\n" end - it 'knife show -z /environments/x.json fails with an error' do - knife('show -z /environments/x.json').should_fail "ERROR: /environments/x.json: No such file or directory\n" + it "knife show -z /environments/x.json fails with an error" do + knife("show -z /environments/x.json").should_fail "ERROR: /environments/x.json: No such file or directory\n" end - it 'knife show -z /nodes/x.json fails with an error' do - knife('show -z /nodes/x.json').should_fail "ERROR: /nodes/x.json: No such file or directory\n" + it "knife show -z /nodes/x.json fails with an error" do + knife("show -z /nodes/x.json").should_fail "ERROR: /nodes/x.json: No such file or directory\n" end - it 'knife show -z /roles/x.json fails with an error' do - knife('show -z /roles/x.json').should_fail "ERROR: /roles/x.json: No such file or directory\n" + it "knife show -z /roles/x.json fails with an error" do + knife("show -z /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n" end - it 'knife show -z /users/x.json fails with an error' do - knife('show -z /users/x.json').should_fail "ERROR: /users/x.json: No such file or directory\n" + it "knife show -z /users/x.json fails with an error" do + knife("show -z /users/x.json").should_fail "ERROR: /users/x.json: No such file or directory\n" end end - context 'PUT /TYPE/NAME' do + context "PUT /TYPE/NAME" do before do - file 'empty.json', {} + file "empty.json", {} end - it 'knife raw -z -i empty.json -m PUT /clients/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /clients/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /clients/x").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /data/x/y fails with 404' do + it "knife raw -z -i empty.json -m PUT /data/x/y fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /data/x/y").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /environments/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /environments/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /environments/x").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /nodes/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /nodes/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /nodes/x").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /roles/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /roles/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /roles/x").should_fail( /404/ ) end - it 'knife raw -z -i empty.json -m PUT /users/x fails with 404' do + it "knife raw -z -i empty.json -m PUT /users/x fails with 404" do knife("raw -z -i #{path_to('empty.json')} -m PUT /users/x").should_fail( /404/ ) end end diff --git a/spec/integration/knife/chef_repo_path_spec.rb b/spec/integration/knife/chef_repo_path_spec.rb index 31525cdf25..b5c86d7a00 100644 --- a/spec/integration/knife/chef_repo_path_spec.rb +++ b/spec/integration/knife/chef_repo_path_spec.rb @@ -15,49 +15,49 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/list' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/list" +require "chef/knife/show" -describe 'chef_repo_path tests', :workstation do +describe "chef_repo_path tests", :workstation do include IntegrationSupport include KnifeSupport let(:error_rel_path_outside_repo) { /^ERROR: Attempt to use relative path '' when current directory is outside the repository path/ } # TODO alternate repo_path / *_path - context 'alternate *_path' do - when_the_repository 'has clients and clients2, cookbooks and cookbooks2, etc.' do + context "alternate *_path" do + when_the_repository "has clients and clients2, cookbooks and cookbooks2, etc." do before do - file 'clients/client1.json', {} - file 'cookbooks/cookbook1/metadata.rb', '' - file 'data_bags/bag/item.json', {} - file 'environments/env1.json', {} - file 'nodes/node1.json', {} - file 'roles/role1.json', {} - file 'users/user1.json', {} - - file 'clients2/client2.json', {} - file 'cookbooks2/cookbook2/metadata.rb', '' - file 'data_bags2/bag2/item2.json', {} - file 'environments2/env2.json', {} - file 'nodes2/node2.json', {} - file 'roles2/role2.json', {} - file 'users2/user2.json', {} - - directory 'chef_repo2' do - file 'clients/client3.json', {} - file 'cookbooks/cookbook3/metadata.rb', '' - file 'data_bags/bag3/item3.json', {} - file 'environments/env3.json', {} - file 'nodes/node3.json', {} - file 'roles/role3.json', {} - file 'users/user3.json', {} + file "clients/client1.json", {} + file "cookbooks/cookbook1/metadata.rb", "" + file "data_bags/bag/item.json", {} + file "environments/env1.json", {} + file "nodes/node1.json", {} + file "roles/role1.json", {} + file "users/user1.json", {} + + file "clients2/client2.json", {} + file "cookbooks2/cookbook2/metadata.rb", "" + file "data_bags2/bag2/item2.json", {} + file "environments2/env2.json", {} + file "nodes2/node2.json", {} + file "roles2/role2.json", {} + file "users2/user2.json", {} + + directory "chef_repo2" do + file "clients/client3.json", {} + file "cookbooks/cookbook3/metadata.rb", "" + file "data_bags/bag3/item3.json", {} + file "environments/env3.json", {} + file "nodes/node3.json", {} + file "roles/role3.json", {} + file "users/user3.json", {} end end - it 'knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff' do + it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do Chef::Config.delete(:chef_repo_path) knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<EOM /clients/ @@ -79,15 +79,15 @@ describe 'chef_repo_path tests', :workstation do EOM end - context 'when all _paths are set to alternates' do + context "when all _paths are set to alternates" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, "#{object_name}s2") end - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2') + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "chef_repo2") end - it 'knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff' do + it "knife list --local -Rfp --chef-repo-path chef_repo2 / grabs chef_repo2 stuff" do knife("list --local -Rfp --chef-repo-path #{path_to('chef_repo2')} /").should_succeed <<EOM /clients/ /clients/client3.json @@ -108,24 +108,24 @@ EOM EOM end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client2.json cookbooks/ @@ -146,31 +146,31 @@ EOM end end - context 'when cwd is inside data_bags2' do - before { cwd 'data_bags2' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside data_bags2" do + before { cwd "data_bags2" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag2/ bag2/item2.json EOM end - it 'knife list --local -Rfp ../roles lists roles' do - knife('list --local -Rfp ../roles').should_succeed "/roles/role2.json\n" + it "knife list --local -Rfp ../roles lists roles" do + knife("list --local -Rfp ../roles").should_succeed "/roles/role2.json\n" end end end - context 'when all _paths except chef_repo_path are set to alternates' do + context "when all _paths except chef_repo_path are set to alternates" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, "#{object_name}s2") end end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client2.json cookbooks/ @@ -191,24 +191,24 @@ EOM end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside data_bags2' do - before { cwd 'data_bags2' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside data_bags2" do + before { cwd "data_bags2" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag2/ bag2/item2.json EOM @@ -216,32 +216,32 @@ EOM end end - context 'when only chef_repo_path is set to its alternate' do + context "when only chef_repo_path is set to its alternate" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2') + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "chef_repo2") end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client3.json cookbooks/ @@ -262,10 +262,10 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag3/ bag3/item3.json EOM @@ -273,7 +273,7 @@ EOM end end - context 'when paths are set to point to both versions of each' do + context "when paths are set to point to both versions of each" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config["#{object_name}_path".to_sym] = [ @@ -281,16 +281,16 @@ EOM File.join(Chef::Config.chef_repo_path, "#{object_name}s2"), ] end - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2') + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "chef_repo2") end - context 'when there is a directory in clients1 and file in clients2 with the same name' do + context "when there is a directory in clients1 and file in clients2 with the same name" do before do - directory 'clients/blah.json' - file 'clients2/blah.json', {} + directory "clients/blah.json" + file "clients2/blah.json", {} end - it 'knife show /clients/blah.json succeeds' do - knife('show --local /clients/blah.json').should_succeed <<EOM + it "knife show /clients/blah.json succeeds" do + knife("show --local /clients/blah.json").should_succeed <<EOM /clients/blah.json: { @@ -299,13 +299,13 @@ EOM end end - context 'when there is a file in cookbooks1 and directory in cookbooks2 with the same name' do + context "when there is a file in cookbooks1 and directory in cookbooks2 with the same name" do before do - file 'cookbooks/blah', '' - file 'cookbooks2/blah/metadata.rb', '' + file "cookbooks/blah", "" + file "cookbooks2/blah/metadata.rb", "" end - it 'knife list -Rfp cookbooks shows files in blah' do - knife('list --local -Rfp /cookbooks').should_succeed <<EOM + it "knife list -Rfp cookbooks shows files in blah" do + knife("list --local -Rfp /cookbooks").should_succeed <<EOM /cookbooks/blah/ /cookbooks/blah/metadata.rb /cookbooks/cookbook1/ @@ -316,13 +316,13 @@ EOM end end - context 'when there is an empty directory in cookbooks1 and a real cookbook in cookbooks2 with the same name' do + context "when there is an empty directory in cookbooks1 and a real cookbook in cookbooks2 with the same name" do before do - directory 'cookbooks/blah' - file 'cookbooks2/blah/metadata.rb', '' + directory "cookbooks/blah" + file "cookbooks2/blah/metadata.rb", "" end - it 'knife list -Rfp cookbooks shows files in blah' do - knife('list --local -Rfp /cookbooks').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'blah' is empty or entirely chefignored at #{Chef::Config.cookbook_path[0]}/blah\n") + it "knife list -Rfp cookbooks shows files in blah" do + knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'blah' is empty or entirely chefignored at #{Chef::Config.cookbook_path[0]}/blah\n") /cookbooks/blah/ /cookbooks/blah/metadata.rb /cookbooks/cookbook1/ @@ -333,13 +333,13 @@ EOM end end - context 'when there is a cookbook in cookbooks1 and a cookbook in cookbooks2 with the same name' do + context "when there is a cookbook in cookbooks1 and a cookbook in cookbooks2 with the same name" do before do - file 'cookbooks/blah/metadata.json', {} - file 'cookbooks2/blah/metadata.rb', '' + file "cookbooks/blah/metadata.json", {} + file "cookbooks2/blah/metadata.rb", "" end - it 'knife list -Rfp cookbooks shows files in the first cookbook and not the second' do - knife('list --local -Rfp /cookbooks').should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.cookbook_path[0]}/blah and #{Chef::Config.cookbook_path[1]}/blah\n") + it "knife list -Rfp cookbooks shows files in the first cookbook and not the second" do + knife("list --local -Rfp /cookbooks").should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.cookbook_path[0]}/blah and #{Chef::Config.cookbook_path[1]}/blah\n") /cookbooks/blah/ /cookbooks/blah/metadata.json /cookbooks/cookbook1/ @@ -350,13 +350,13 @@ EOM end end - context 'when there is a file in data_bags1 and a directory in data_bags2 with the same name' do + context "when there is a file in data_bags1 and a directory in data_bags2 with the same name" do before do - file 'data_bags/blah', '' - file 'data_bags2/blah/item.json', '' + file "data_bags/blah", "" + file "data_bags2/blah/item.json", "" end - it 'knife list -Rfp data_bags shows files in blah' do - knife('list --local -Rfp /data_bags').should_succeed <<EOM + it "knife list -Rfp data_bags shows files in blah" do + knife("list --local -Rfp /data_bags").should_succeed <<EOM /data_bags/bag/ /data_bags/bag/item.json /data_bags/bag2/ @@ -367,13 +367,13 @@ EOM end end - context 'when there is a data bag in data_bags1 and a data bag in data_bags2 with the same name' do + context "when there is a data bag in data_bags1 and a data bag in data_bags2 with the same name" do before do - file 'data_bags/blah/item1.json', '' - file 'data_bags2/blah/item2.json', '' + file "data_bags/blah/item1.json", "" + file "data_bags2/blah/item2.json", "" end - it 'knife list -Rfp data_bags shows only items in data_bags1' do - knife('list --local -Rfp /data_bags').should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.data_bag_path[0]}/blah and #{Chef::Config.data_bag_path[1]}/blah\n") + it "knife list -Rfp data_bags shows only items in data_bags1" do + knife("list --local -Rfp /data_bags").should_succeed(<<EOM, :stderr => "WARN: Child with name 'blah' found in multiple directories: #{Chef::Config.data_bag_path[0]}/blah and #{Chef::Config.data_bag_path[1]}/blah\n") /data_bags/bag/ /data_bags/bag/item.json /data_bags/bag2/ @@ -384,13 +384,13 @@ EOM end end - context 'when there is a directory in environments1 and file in environments2 with the same name' do + context "when there is a directory in environments1 and file in environments2 with the same name" do before do - directory 'environments/blah.json' - file 'environments2/blah.json', {} + directory "environments/blah.json" + file "environments2/blah.json", {} end - it 'knife show /environments/blah.json succeeds' do - knife('show --local /environments/blah.json').should_succeed <<EOM + it "knife show /environments/blah.json succeeds" do + knife("show --local /environments/blah.json").should_succeed <<EOM /environments/blah.json: { @@ -399,13 +399,13 @@ EOM end end - context 'when there is a directory in nodes1 and file in nodes2 with the same name' do + context "when there is a directory in nodes1 and file in nodes2 with the same name" do before do - directory 'nodes/blah.json' - file 'nodes2/blah.json', {} + directory "nodes/blah.json" + file "nodes2/blah.json", {} end - it 'knife show /nodes/blah.json succeeds' do - knife('show --local /nodes/blah.json').should_succeed <<EOM + it "knife show /nodes/blah.json succeeds" do + knife("show --local /nodes/blah.json").should_succeed <<EOM /nodes/blah.json: { @@ -414,13 +414,13 @@ EOM end end - context 'when there is a directory in roles1 and file in roles2 with the same name' do + context "when there is a directory in roles1 and file in roles2 with the same name" do before do - directory 'roles/blah.json' - file 'roles2/blah.json', {} + directory "roles/blah.json" + file "roles2/blah.json", {} end - it 'knife show /roles/blah.json succeeds' do - knife('show --local /roles/blah.json').should_succeed <<EOM + it "knife show /roles/blah.json succeeds" do + knife("show --local /roles/blah.json").should_succeed <<EOM /roles/blah.json: { @@ -429,13 +429,13 @@ EOM end end - context 'when there is a directory in users1 and file in users2 with the same name' do + context "when there is a directory in users1 and file in users2 with the same name" do before do - directory 'users/blah.json' - file 'users2/blah.json', {} + directory "users/blah.json" + file "users2/blah.json", {} end - it 'knife show /users/blah.json succeeds' do - knife('show --local /users/blah.json').should_succeed <<EOM + it "knife show /users/blah.json succeeds" do + knife("show --local /users/blah.json").should_succeed <<EOM /users/blah.json: { @@ -444,17 +444,17 @@ EOM end end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag2/ @@ -463,10 +463,10 @@ EOM end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client2.json @@ -496,10 +496,10 @@ EOM end end - context 'when cwd is inside data_bags2' do - before { cwd 'data_bags2' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside data_bags2" do + before { cwd "data_bags2" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag2/ @@ -509,21 +509,21 @@ EOM end end - context 'when when chef_repo_path is set to both places and no other _path is set' do + context "when when chef_repo_path is set to both places and no other _path is set" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end Chef::Config.chef_repo_path = [ Chef::Config.chef_repo_path, - File.join(Chef::Config.chef_repo_path, 'chef_repo2'), + File.join(Chef::Config.chef_repo_path, "chef_repo2"), ] end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client3.json @@ -553,10 +553,10 @@ EOM end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag3/ @@ -565,10 +565,10 @@ EOM end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client3.json @@ -598,10 +598,10 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag3/ @@ -611,33 +611,33 @@ EOM end end - context 'when cookbook_path is set and nothing else' do + context "when cookbook_path is set and nothing else" do before :each do %w(client data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end Chef::Config.delete(:chef_repo_path) - Chef::Config.cookbook_path = File.join(@repository_dir, 'chef_repo2', 'cookbooks') + Chef::Config.cookbook_path = File.join(@repository_dir, "chef_repo2", "cookbooks") end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client3.json cookbooks/ @@ -658,10 +658,10 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag3/ bag3/item3.json EOM @@ -669,22 +669,22 @@ EOM end end - context 'when cookbook_path is set to multiple places and nothing else is set' do + context "when cookbook_path is set to multiple places and nothing else is set" do before :each do %w(client data_bag environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end Chef::Config.delete(:chef_repo_path) Chef::Config.cookbook_path = [ - File.join(@repository_dir, 'cookbooks'), - File.join(@repository_dir, 'chef_repo2', 'cookbooks'), + File.join(@repository_dir, "cookbooks"), + File.join(@repository_dir, "chef_repo2", "cookbooks"), ] end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client3.json @@ -714,10 +714,10 @@ EOM end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag3/ @@ -726,10 +726,10 @@ EOM end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client1.json clients/client3.json @@ -759,10 +759,10 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json bag3/ @@ -772,36 +772,36 @@ EOM end end - context 'when data_bag_path and chef_repo_path are set, and nothing else' do + context "when data_bag_path and chef_repo_path are set, and nothing else" do before :each do %w(client cookbook environment node role user).each do |object_name| Chef::Config.delete("#{object_name}_path".to_sym) end - Chef::Config.data_bag_path = File.join(Chef::Config.chef_repo_path, 'data_bags') - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'chef_repo2') + Chef::Config.data_bag_path = File.join(Chef::Config.chef_repo_path, "data_bags") + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "chef_repo2") end - context 'when cwd is at the top level' do - before { cwd '.' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is at the top level" do + before { cwd "." } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json EOM end end - context 'when cwd is inside chef_repo2' do - before { cwd 'chef_repo2' } - it 'knife list --local -Rfp lists everything' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside chef_repo2" do + before { cwd "chef_repo2" } + it "knife list --local -Rfp lists everything" do + knife("list --local -Rfp").should_succeed <<EOM clients/ clients/client3.json cookbooks/ @@ -822,15 +822,15 @@ EOM end end - context 'when cwd is inside chef_repo2/data_bags' do - before { cwd 'chef_repo2/data_bags' } - it 'knife list --local -Rfp fails' do - knife('list --local -Rfp').should_fail(error_rel_path_outside_repo) + context "when cwd is inside chef_repo2/data_bags" do + before { cwd "chef_repo2/data_bags" } + it "knife list --local -Rfp fails" do + knife("list --local -Rfp").should_fail(error_rel_path_outside_repo) end end end - context 'when data_bag_path is set and nothing else' do + context "when data_bag_path is set and nothing else" do include_context "default config options" before :each do @@ -838,28 +838,28 @@ EOM Chef::Config.delete("#{object_name}_path".to_sym) end Chef::Config.delete(:chef_repo_path) - Chef::Config.data_bag_path = File.join(@repository_dir, 'data_bags') + Chef::Config.data_bag_path = File.join(@repository_dir, "data_bags") end - it 'knife list --local -Rfp / lists data bags' do - knife('list --local -Rfp /').should_succeed <<EOM + it "knife list --local -Rfp / lists data bags" do + knife("list --local -Rfp /").should_succeed <<EOM /data_bags/ /data_bags/bag/ /data_bags/bag/item.json EOM end - it 'knife list --local -Rfp /data_bags lists data bags' do - knife('list --local -Rfp /data_bags').should_succeed <<EOM + it "knife list --local -Rfp /data_bags lists data bags" do + knife("list --local -Rfp /data_bags").should_succeed <<EOM /data_bags/bag/ /data_bags/bag/item.json EOM end - context 'when cwd is inside the data_bags directory' do - before { cwd 'data_bags' } - it 'knife list --local -Rfp lists data bags' do - knife('list --local -Rfp').should_succeed <<EOM + context "when cwd is inside the data_bags directory" do + before { cwd "data_bags" } + it "knife list --local -Rfp lists data bags" do + knife("list --local -Rfp").should_succeed <<EOM bag/ bag/item.json EOM @@ -868,21 +868,21 @@ EOM end end - when_the_repository 'is empty' do - context 'when the repository _paths point to places that do not exist' do + when_the_repository "is empty" do + context "when the repository _paths point to places that do not exist" do before :each do %w(client cookbook data_bag environment node role user).each do |object_name| - Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, 'nowhere', object_name) + Chef::Config["#{object_name}_path".to_sym] = File.join(Chef::Config.chef_repo_path, "nowhere", object_name) end - Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, 'nowhere') + Chef::Config.chef_repo_path = File.join(Chef::Config.chef_repo_path, "nowhere") end - it 'knife list --local -Rfp / fails' do - knife('list --local -Rfp /').should_succeed '' + it "knife list --local -Rfp / fails" do + knife("list --local -Rfp /").should_succeed "" end - it 'knife list --local -Rfp /data_bags fails' do - knife('list --local -Rfp /data_bags').should_fail("ERROR: /data_bags: No such file or directory\n") + it "knife list --local -Rfp /data_bags fails" do + knife("list --local -Rfp /data_bags").should_fail("ERROR: /data_bags: No such file or directory\n") end end end diff --git a/spec/integration/knife/chef_repository_file_system_spec.rb b/spec/integration/knife/chef_repository_file_system_spec.rb index 34afd228f3..dc33d299e1 100644 --- a/spec/integration/knife/chef_repository_file_system_spec.rb +++ b/spec/integration/knife/chef_repository_file_system_spec.rb @@ -15,15 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/list' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "chef/knife/list" +require "chef/knife/show" -describe 'General chef_repo file system checks', :workstation do +describe "General chef_repo file system checks", :workstation do include IntegrationSupport include KnifeSupport - context 'directories and files that should/should not be ignored' do + context "directories and files that should/should not be ignored" do when_the_repository "has empty roles, environments and data bag item directories" do before do directory "roles" @@ -32,7 +32,7 @@ describe 'General chef_repo file system checks', :workstation do end it "knife list --local -Rfp / returns them" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /data_bags/ /data_bags/bag1/ /environments/ @@ -45,25 +45,25 @@ EOM before { directory "data_bags" } it "knife list --local / returns it" do - knife('list --local /').should_succeed "/data_bags\n" + knife("list --local /").should_succeed "/data_bags\n" end end when_the_repository "has an empty cookbook directory" do - before { directory 'cookbooks/cookbook1' } + before { directory "cookbooks/cookbook1" } it "knife list --local -Rfp / does not return it" do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end end when_the_repository "has only empty cookbook subdirectories" do - before { directory 'cookbooks/cookbook1/recipes' } + before { directory "cookbooks/cookbook1/recipes" } it "knife list --local -Rfp / does not return it" do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -71,12 +71,12 @@ EOM when_the_repository "has empty and non-empty cookbook subdirectories" do before do - directory 'cookbooks/cookbook1/recipes' - file 'cookbooks/cookbook1/templates/default/x.txt', '' + directory "cookbooks/cookbook1/recipes" + file "cookbooks/cookbook1/templates/default/x.txt", "" end it "knife list --local -Rfp / does not return the empty ones" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/templates/ @@ -87,10 +87,10 @@ EOM end when_the_repository "has only empty cookbook sub-sub-directories" do - before { directory 'cookbooks/cookbook1/templates/default' } + before { directory "cookbooks/cookbook1/templates/default" } it "knife list --local -Rfp / does not return it" do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -98,13 +98,13 @@ EOM when_the_repository "has empty cookbook sub-sub-directories alongside non-empty ones" do before do - file 'cookbooks/cookbook1/templates/default/x.txt', '' - directory 'cookbooks/cookbook1/templates/rhel' - directory 'cookbooks/cookbook1/files/default' + file "cookbooks/cookbook1/templates/default/x.txt", "" + directory "cookbooks/cookbook1/templates/rhel" + directory "cookbooks/cookbook1/files/default" end it "knife list --local -Rfp / does not return the empty ones" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/templates/ @@ -122,7 +122,7 @@ EOM end it "knife list --local -Rfp / should NOT return it" do - knife('list --local -Rfp /').should_succeed "" + knife("list --local -Rfp /").should_succeed "" end end @@ -146,7 +146,7 @@ EOM end it "knife list --local -Rfp / should NOT return them" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /data_bags/ /data_bags/bag1/ /data_bags/bag1/item1.json @@ -160,62 +160,62 @@ EOM when_the_repository "has extraneous subdirectories and files under a cookbook" do before do - directory 'cookbooks/cookbook1' do - file 'a.rb', '' - file 'blarghle/blah.rb', '' - directory 'attributes' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "cookbooks/cookbook1" do + file "a.rb", "" + file "blarghle/blah.rb", "" + directory "attributes" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'definitions' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "definitions" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'recipes' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "recipes" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'libraries' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "libraries" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'templates' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "templates" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'files' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "files" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'resources' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "resources" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end - directory 'providers' do - file 'a.rb', '' - file 'b.json', {} - file 'c/d.rb', '' - file 'c/e.json', {} + directory "providers" do + file "a.rb", "" + file "b.json", {} + file "c/d.rb", "" + file "c/e.json", {} end end end it "knife list --local -Rfp / should NOT return them" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/a.rb @@ -252,41 +252,41 @@ EOM end when_the_repository "has a file in cookbooks/" do - before { file 'cookbooks/file', '' } - it 'does not show up in list -Rfp' do - knife('list --local -Rfp /').should_succeed <<EOM + before { file "cookbooks/file", "" } + it "does not show up in list -Rfp" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ EOM end end when_the_repository "has a file in data_bags/" do - before { file 'data_bags/file', '' } - it 'does not show up in list -Rfp' do - knife('list --local -Rfp /').should_succeed <<EOM + before { file "data_bags/file", "" } + it "does not show up in list -Rfp" do + knife("list --local -Rfp /").should_succeed <<EOM /data_bags/ EOM end end end - when_the_repository 'has a cookbook starting with .' do + when_the_repository "has a cookbook starting with ." do before do - file 'cookbooks/.svn/metadata.rb', '' - file 'cookbooks/a.b/metadata.rb', '' + file "cookbooks/.svn/metadata.rb", "" + file "cookbooks/a.b/metadata.rb", "" end - it 'knife list does not show it' do - knife('list --local -fp /cookbooks').should_succeed "/cookbooks/a.b/\n" + it "knife list does not show it" do + knife("list --local -fp /cookbooks").should_succeed "/cookbooks/a.b/\n" end end - when_the_repository 'has a data bag starting with .' do + when_the_repository "has a data bag starting with ." do before do - file 'data_bags/.svn/x.json', {} - file 'data_bags/a.b/x.json', {} + file "data_bags/.svn/x.json", {} + file "data_bags/a.b/x.json", {} end - it 'knife list does not show it' do - knife('list --local -fp /data_bags').should_succeed "/data_bags/a.b/\n" + it "knife list does not show it" do + knife("list --local -fp /data_bags").should_succeed "/data_bags/a.b/\n" end end end diff --git a/spec/integration/knife/chefignore_spec.rb b/spec/integration/knife/chefignore_spec.rb index 10cfbbf557..3ffd0453e8 100644 --- a/spec/integration/knife/chefignore_spec.rb +++ b/spec/integration/knife/chefignore_spec.rb @@ -15,37 +15,37 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/list' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "chef/knife/list" +require "chef/knife/show" -describe 'chefignore tests', :workstation do +describe "chefignore tests", :workstation do include IntegrationSupport include KnifeSupport when_the_repository "has lots of stuff in it" do before do - file 'roles/x.json', {} - file 'environments/x.json', {} - file 'data_bags/bag1/x.json', {} - file 'cookbooks/cookbook1/x.json', {} + file "roles/x.json", {} + file "environments/x.json", {} + file "data_bags/bag1/x.json", {} + file "cookbooks/cookbook1/x.json", {} end context "and has a chefignore everywhere except cookbooks" do before do chefignore = "x.json\nroles/x.json\nenvironments/x.json\ndata_bags/bag1/x.json\nbag1/x.json\ncookbooks/cookbook1/x.json\ncookbook1/x.json\n" - file 'chefignore', chefignore - file 'roles/chefignore', chefignore - file 'environments/chefignore', chefignore - file 'data_bags/chefignore', chefignore - file 'data_bags/bag1/chefignore', chefignore - file 'cookbooks/cookbook1/chefignore', chefignore + file "chefignore", chefignore + file "roles/chefignore", chefignore + file "environments/chefignore", chefignore + file "data_bags/chefignore", chefignore + file "data_bags/bag1/chefignore", chefignore + file "cookbooks/cookbook1/chefignore", chefignore end - it 'matching files and directories get ignored' do + it "matching files and directories get ignored" do # NOTE: many of the "chefignore" files should probably not show up # themselves, but we have other tests that talk about that - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/chefignore @@ -61,15 +61,15 @@ EOM end end - when_the_repository 'has a cookbook with only chefignored files' do + when_the_repository "has a cookbook with only chefignored files" do before do - file 'cookbooks/cookbook1/templates/default/x.rb', '' - file 'cookbooks/cookbook1/libraries/x.rb', '' - file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n" + file "cookbooks/cookbook1/templates/default/x.rb", "" + file "cookbooks/cookbook1/libraries/x.rb", "" + file "cookbooks/chefignore", "libraries/x.rb\ntemplates/default/x.rb\n" end - it 'the cookbook is not listed' do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") + it "the cookbook is not listed" do + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Cookbook 'cookbook1' is empty or entirely chefignored at #{Chef::Config.chef_repo_path}/cookbooks/cookbook1\n") /cookbooks/ EOM end @@ -77,17 +77,17 @@ EOM when_the_repository "has multiple cookbooks" do before do - file 'cookbooks/cookbook1/x.json', {} - file 'cookbooks/cookbook1/y.json', {} - file 'cookbooks/cookbook2/x.json', {} - file 'cookbooks/cookbook2/y.json', {} + file "cookbooks/cookbook1/x.json", {} + file "cookbooks/cookbook1/y.json", {} + file "cookbooks/cookbook2/x.json", {} + file "cookbooks/cookbook2/y.json", {} end - context 'and has a chefignore with filenames' do - before { file 'cookbooks/chefignore', "x.json\n" } + context "and has a chefignore with filenames" do + before { file "cookbooks/chefignore", "x.json\n" } - it 'matching files and directories get ignored in all cookbooks' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching files and directories get ignored in all cookbooks" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/y.json @@ -99,12 +99,12 @@ EOM context "and has a chefignore with wildcards" do before do - file 'cookbooks/chefignore', "x.*\n" - file 'cookbooks/cookbook1/x.rb', '' + file "cookbooks/chefignore", "x.*\n" + file "cookbooks/cookbook1/x.rb", "" end - it 'matching files and directories get ignored in all cookbooks' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching files and directories get ignored in all cookbooks" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/y.json @@ -116,13 +116,13 @@ EOM context "and has a chefignore with relative paths" do before do - file 'cookbooks/cookbook1/recipes/x.rb', '' - file 'cookbooks/cookbook2/recipes/y.rb', '' - file 'cookbooks/chefignore', "recipes/x.rb\n" + file "cookbooks/cookbook1/recipes/x.rb", "" + file "cookbooks/cookbook2/recipes/y.rb", "" + file "cookbooks/chefignore", "recipes/x.rb\n" end - it 'matching directories get ignored' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching directories get ignored" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/x.json @@ -138,12 +138,12 @@ EOM context "and has a chefignore with subdirectories" do before do - file 'cookbooks/cookbook1/recipes/y.rb', '' - file 'cookbooks/chefignore', "recipes\nrecipes/\n" + file "cookbooks/cookbook1/recipes/y.rb", "" + file "cookbooks/chefignore", "recipes\nrecipes/\n" end - it 'matching directories do NOT get ignored' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching directories do NOT get ignored" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/recipes/ @@ -159,13 +159,13 @@ EOM context "and has a chefignore that ignores all files in a subdirectory" do before do - file 'cookbooks/cookbook1/templates/default/x.rb', '' - file 'cookbooks/cookbook1/libraries/x.rb', '' - file 'cookbooks/chefignore', "libraries/x.rb\ntemplates/default/x.rb\n" + file "cookbooks/cookbook1/templates/default/x.rb", "" + file "cookbooks/cookbook1/libraries/x.rb", "" + file "cookbooks/chefignore", "libraries/x.rb\ntemplates/default/x.rb\n" end - it 'ignores the subdirectory entirely' do - knife('list --local -Rfp /').should_succeed <<EOM + it "ignores the subdirectory entirely" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/x.json @@ -179,11 +179,11 @@ EOM context "and has an empty chefignore" do before do - file 'cookbooks/chefignore', "\n" + file "cookbooks/chefignore", "\n" end - it 'nothing is ignored' do - knife('list --local -Rfp /').should_succeed <<EOM + it "nothing is ignored" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/x.json @@ -197,11 +197,11 @@ EOM context "and has a chefignore with comments and empty lines" do before do - file 'cookbooks/chefignore', "\n\n # blah\n#\nx.json\n\n" + file "cookbooks/chefignore", "\n\n # blah\n#\nx.json\n\n" end - it 'matching files and directories get ignored in all cookbooks' do - knife('list --local -Rfp /').should_succeed <<EOM + it "matching files and directories get ignored in all cookbooks" do + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/cookbook1/ /cookbooks/cookbook1/y.json @@ -215,25 +215,25 @@ EOM when_the_repository "has multiple cookbook paths" do before :each do Chef::Config.cookbook_path = [ - File.join(Chef::Config.chef_repo_path, 'cookbooks1'), - File.join(Chef::Config.chef_repo_path, 'cookbooks2'), + File.join(Chef::Config.chef_repo_path, "cookbooks1"), + File.join(Chef::Config.chef_repo_path, "cookbooks2"), ] end before do - file 'cookbooks1/mycookbook/metadata.rb', '' - file 'cookbooks1/mycookbook/x.json', {} - file 'cookbooks2/yourcookbook/metadata.rb', '' - file 'cookbooks2/yourcookbook/x.json', '' + file "cookbooks1/mycookbook/metadata.rb", "" + file "cookbooks1/mycookbook/x.json", {} + file "cookbooks2/yourcookbook/metadata.rb", "" + file "cookbooks2/yourcookbook/x.json", "" end context "and multiple chefignores" do before do - file 'cookbooks1/chefignore', "metadata.rb\n" - file 'cookbooks2/chefignore', "x.json\n" + file "cookbooks1/chefignore", "metadata.rb\n" + file "cookbooks2/chefignore", "x.json\n" end it "chefignores apply only to the directories they are in" do - knife('list --local -Rfp /').should_succeed <<EOM + knife("list --local -Rfp /").should_succeed <<EOM /cookbooks/ /cookbooks/mycookbook/ /cookbooks/mycookbook/x.json @@ -244,14 +244,14 @@ EOM context "and conflicting cookbooks" do before do - file 'cookbooks1/yourcookbook/metadata.rb', '' - file 'cookbooks1/yourcookbook/x.json', '' - file 'cookbooks1/yourcookbook/onlyincookbooks1.rb', '' - file 'cookbooks2/yourcookbook/onlyincookbooks2.rb', '' + file "cookbooks1/yourcookbook/metadata.rb", "" + file "cookbooks1/yourcookbook/x.json", "" + file "cookbooks1/yourcookbook/onlyincookbooks1.rb", "" + file "cookbooks2/yourcookbook/onlyincookbooks2.rb", "" end it "chefignores apply only to the winning cookbook" do - knife('list --local -Rfp /').should_succeed(<<EOM, :stderr => "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n") + knife("list --local -Rfp /").should_succeed(<<EOM, :stderr => "WARN: Child with name 'yourcookbook' found in multiple directories: #{Chef::Config.chef_repo_path}/cookbooks1/yourcookbook and #{Chef::Config.chef_repo_path}/cookbooks2/yourcookbook\n") /cookbooks/ /cookbooks/mycookbook/ /cookbooks/mycookbook/x.json @@ -264,32 +264,32 @@ EOM end end - when_the_repository 'has a cookbook named chefignore' do + when_the_repository "has a cookbook named chefignore" do before do - file 'cookbooks/chefignore/metadata.rb', {} + file "cookbooks/chefignore/metadata.rb", {} end - it 'knife list -Rfp /cookbooks shows it' do - knife('list --local -Rfp /cookbooks').should_succeed <<EOM + it "knife list -Rfp /cookbooks shows it" do + knife("list --local -Rfp /cookbooks").should_succeed <<EOM /cookbooks/chefignore/ /cookbooks/chefignore/metadata.rb EOM end end - when_the_repository 'has multiple cookbook paths, one with a chefignore file and the other with a cookbook named chefignore' do + when_the_repository "has multiple cookbook paths, one with a chefignore file and the other with a cookbook named chefignore" do before do - file 'cookbooks1/chefignore', '' - file 'cookbooks1/blah/metadata.rb', '' - file 'cookbooks2/chefignore/metadata.rb', '' + file "cookbooks1/chefignore", "" + file "cookbooks1/blah/metadata.rb", "" + file "cookbooks2/chefignore/metadata.rb", "" end before :each do Chef::Config.cookbook_path = [ - File.join(Chef::Config.chef_repo_path, 'cookbooks1'), - File.join(Chef::Config.chef_repo_path, 'cookbooks2'), + File.join(Chef::Config.chef_repo_path, "cookbooks1"), + File.join(Chef::Config.chef_repo_path, "cookbooks2"), ] end - it 'knife list -Rfp /cookbooks shows the chefignore cookbook' do - knife('list --local -Rfp /cookbooks').should_succeed <<EOM + it "knife list -Rfp /cookbooks shows the chefignore cookbook" do + knife("list --local -Rfp /cookbooks").should_succeed <<EOM /cookbooks/blah/ /cookbooks/blah/metadata.rb /cookbooks/chefignore/ diff --git a/spec/integration/knife/common_options_spec.rb b/spec/integration/knife/common_options_spec.rb index b2e2e3fc2a..0c287580db 100644 --- a/spec/integration/knife/common_options_spec.rb +++ b/spec/integration/knife/common_options_spec.rb @@ -15,46 +15,46 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/raw' +require "support/shared/integration/integration_helper" +require "chef/knife/raw" -describe 'knife common options', :workstation do +describe "knife common options", :workstation do include IntegrationSupport include KnifeSupport when_the_repository "has a node" do - before { file 'nodes/x.json', {} } + before { file "nodes/x.json", {} } - context 'When chef_zero.enabled is true' do + context "When chef_zero.enabled is true" do before(:each) do Chef::Config.chef_zero.enabled = true end - it 'knife raw /nodes/x should retrieve the node' do - knife('raw /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw /nodes/x should retrieve the node" do + knife("raw /nodes/x").should_succeed( /"name": "x"/ ) end - context 'And chef_zero.port is 9999' do + context "And chef_zero.port is 9999" do before(:each) { Chef::Config.chef_zero.port = 9999 } - it 'knife raw /nodes/x should retrieve the node' do - knife('raw /nodes/x').should_succeed( /"name": "x"/ ) - expect(Chef::Config.chef_server_url).to eq('chefzero://localhost:9999') + it "knife raw /nodes/x should retrieve the node" do + knife("raw /nodes/x").should_succeed( /"name": "x"/ ) + expect(Chef::Config.chef_server_url).to eq("chefzero://localhost:9999") end end # 0.0.0.0 is not a valid address to bind to on windows. - context 'And chef_zero.host is 0.0.0.0', :unix_only do - before(:each) { Chef::Config.chef_zero.host = '0.0.0.0' } + context "And chef_zero.host is 0.0.0.0", :unix_only do + before(:each) { Chef::Config.chef_zero.host = "0.0.0.0" } - it 'knife raw /nodes/x should retrieve the role' do - knife('raw /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw /nodes/x should retrieve the role" do + knife("raw /nodes/x").should_succeed( /"name": "x"/ ) end end - context 'and there is a private key' do + context "and there is a private key" do before do - file 'mykey.pem', <<EOM + file "mykey.pem", <<EOM -----BEGIN RSA PRIVATE KEY----- MIIEogIBAAKCAQEApubutqtYYQ5UiA9QhWP7UvSmsfHsAoPKEVVPdVW/e8Svwpyf 0Xef6OFWVmBE+W442ZjLOe2y6p2nSnaq4y7dg99NFz6X+16mcKiCbj0RCiGqCvCk @@ -85,29 +85,29 @@ syHLXYFNy0OxMtH/bBAXBGNHd9gf5uOnqh0pYcbe/uRAxumC7Rl0cL509eURiA2T EOM end - it 'knife raw /nodes/x should retrieve the node' do - knife('raw /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw /nodes/x should retrieve the node" do + knife("raw /nodes/x").should_succeed( /"name": "x"/ ) end end end - it 'knife raw -z /nodes/x retrieves the node' do - knife('raw -z /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw -z /nodes/x retrieves the node" do + knife("raw -z /nodes/x").should_succeed( /"name": "x"/ ) end - it 'knife raw --local-mode /nodes/x retrieves the node' do - knife('raw --local-mode /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw --local-mode /nodes/x retrieves the node" do + knife("raw --local-mode /nodes/x").should_succeed( /"name": "x"/ ) end - it 'knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node' do - knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed( /"name": "x"/ ) - expect(Chef::Config.chef_server_url).to eq('chefzero://localhost:9999') + it "knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node" do + knife("raw -z --chef-zero-port=9999 /nodes/x").should_succeed( /"name": "x"/ ) + expect(Chef::Config.chef_server_url).to eq("chefzero://localhost:9999") end - context 'when the default port (8889) is already bound' do + context "when the default port (8889) is already bound" do before :each do begin - @server = ChefZero::Server.new(:host => 'localhost', :port => 8889) + @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. @@ -117,16 +117,16 @@ EOM @server.stop if @server end - it 'knife raw -z /nodes/x retrieves the node' do - knife('raw -z /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw -z /nodes/x retrieves the node" do + knife("raw -z /nodes/x").should_succeed( /"name": "x"/ ) expect(URI(Chef::Config.chef_server_url).port).to be > 8889 end end - context 'when port 9999 is already bound' do + context "when port 9999 is already bound" do before :each do begin - @server = ChefZero::Server.new(:host => 'localhost', :port => 9999) + @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. @@ -136,20 +136,20 @@ EOM @server.stop if @server end - it 'knife raw -z --chef-zero-port=9999-20000 /nodes/x' do - knife('raw -z --chef-zero-port=9999-20000 /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw -z --chef-zero-port=9999-20000 /nodes/x" do + knife("raw -z --chef-zero-port=9999-20000 /nodes/x").should_succeed( /"name": "x"/ ) expect(URI(Chef::Config.chef_server_url).port).to be > 9999 end - it 'knife raw -z --chef-zero-port=9999-9999,19423' do - knife('raw -z --chef-zero-port=9999-9999,19423 /nodes/x').should_succeed( /"name": "x"/ ) + it "knife raw -z --chef-zero-port=9999-9999,19423" do + knife("raw -z --chef-zero-port=9999-9999,19423 /nodes/x").should_succeed( /"name": "x"/ ) expect(URI(Chef::Config.chef_server_url).port).to be == 19423 end end - it 'knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node' do - knife('raw -z --chef-zero-port=9999 /nodes/x').should_succeed( /"name": "x"/ ) - expect(Chef::Config.chef_server_url).to eq('chefzero://localhost:9999') + it "knife raw -z --chef-zero-port=9999 /nodes/x retrieves the node" do + knife("raw -z --chef-zero-port=9999 /nodes/x").should_succeed( /"name": "x"/ ) + expect(Chef::Config.chef_server_url).to eq("chefzero://localhost:9999") end end end diff --git a/spec/integration/knife/cookbook_api_ipv6_spec.rb b/spec/integration/knife/cookbook_api_ipv6_spec.rb index 4b44c87fc1..3033c4cf4a 100644 --- a/spec/integration/knife/cookbook_api_ipv6_spec.rb +++ b/spec/integration/knife/cookbook_api_ipv6_spec.rb @@ -15,8 +15,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/mixin/shell_out' +require "support/shared/integration/integration_helper" +require "chef/mixin/shell_out" describe "Knife cookbook API integration with IPv6", :workstation, :not_supported_on_gce do include IntegrationSupport @@ -84,8 +84,8 @@ END_CLIENT_RB end before do - file 'config/knife.rb', knife_rb_content - file 'config/knifeuser.pem', client_key + file "config/knife.rb", knife_rb_content + file "config/knifeuser.pem", client_key end it "successfully uploads a cookbook" do diff --git a/spec/integration/knife/delete_spec.rb b/spec/integration/knife/delete_spec.rb index 384f06cf83..3a1a93fb51 100644 --- a/spec/integration/knife/delete_spec.rb +++ b/spec/integration/knife/delete_spec.rb @@ -15,12 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/delete' -require 'chef/knife/list' -require 'chef/knife/raw' +require "support/shared/integration/integration_helper" +require "chef/knife/delete" +require "chef/knife/list" +require "chef/knife/raw" -describe 'knife delete', :workstation do +describe "knife delete", :workstation do include IntegrationSupport include KnifeSupport @@ -100,39 +100,39 @@ EOM when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - when_the_repository 'also has one of each thing' do + when_the_repository "also has one of each thing" do before do - file 'clients/x.json', {} - file 'cookbooks/x/metadata.rb', '' - file 'data_bags/x/y.json', {} - file 'environments/_default.json', {} - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/x.json', {} - end - - it 'knife delete --both /cookbooks/x fails' do - knife('delete --both /cookbooks/x').should_fail <<EOM + file "clients/x.json", {} + file "cookbooks/x/metadata.rb", "" + file "data_bags/x/y.json", {} + file "environments/_default.json", {} + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/x.json", {} + end + + it "knife delete --both /cookbooks/x fails" do + knife("delete --both /cookbooks/x").should_fail <<EOM ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /cookbooks/x deletes x' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both -r /cookbooks/x deletes x" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -152,7 +152,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -171,10 +171,10 @@ EOM EOM end - it 'knife delete -r --local /cookbooks/x deletes x locally but not remotely' do - knife('delete -r --local /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete -r --local /cookbooks/x deletes x locally but not remotely" do + knife("delete -r --local /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -193,9 +193,9 @@ EOM EOM end - it 'knife delete -r /cookbooks/x deletes x remotely but not locally' do - knife('delete -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete -r /cookbooks/x deletes x remotely but not locally" do + knife("delete -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -215,22 +215,22 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed everything + knife("list -Rf --local /").should_succeed everything end # TODO delete empty data bag (particularly different on local side) - context 'with an empty data bag on both' do + context "with an empty data bag on both" do before do - data_bag 'empty', {} - directory 'data_bags/empty' + data_bag "empty", {} + directory "data_bags/empty" end - it 'knife delete --both /data_bags/empty fails but deletes local version' do - knife('delete --both /data_bags/empty').should_fail <<EOM + it "knife delete --both /data_bags/empty fails but deletes local version" do + knife("delete --both /data_bags/empty").should_fail <<EOM ERROR: /data_bags/empty (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /data_bags/empty (local) must be deleted recursively! Pass -r to knife delete. EOM - knife('list -Rf /').should_succeed <<EOM + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -253,7 +253,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -276,18 +276,18 @@ EOM end end - it 'knife delete --both /data_bags/x fails' do - knife('delete --both /data_bags/x').should_fail <<EOM + it "knife delete --both /data_bags/x fails" do + knife("delete --both /data_bags/x").should_fail <<EOM ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete. ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /data_bags/x deletes x' do - knife('delete --both -r /data_bags/x').should_succeed "Deleted /data_bags/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both -r /data_bags/x deletes x" do + knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -307,7 +307,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -326,9 +326,9 @@ EOM EOM end - it 'knife delete --both /environments/x.json deletes x' do - knife('delete --both /environments/x.json').should_succeed "Deleted /environments/x.json\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both /environments/x.json deletes x" do + knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -349,7 +349,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -369,9 +369,9 @@ EOM EOM end - it 'knife delete --both /roles/x.json deletes x' do - knife('delete --both /roles/x.json').should_succeed "Deleted /roles/x.json\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both /roles/x.json deletes x" do + knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -392,7 +392,7 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -412,10 +412,10 @@ EOM EOM end - it 'knife delete --both /environments/_default.json fails but still deletes the local copy' do - knife('delete --both /environments/_default.json').should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both /environments/_default.json fails but still deletes the local copy" do + knife("delete --both /environments/_default.json").should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -435,23 +435,23 @@ EOM EOM end - it 'knife delete --both /environments/nonexistent.json fails' do - knife('delete --both /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + it "knife delete --both /environments/nonexistent.json fails" do + knife("delete --both /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both / fails' do - knife('delete --both /').should_fail <<EOM + it "knife delete --both / fails" do + knife("delete --both /").should_fail <<EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /* fails' do - knife('delete --both -r /*').should_fail <<EOM + it "knife delete --both -r /* fails" do + knife("delete --both -r /*").should_fail <<EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. ERROR: /clients (remote) cannot be deleted. @@ -469,31 +469,31 @@ ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed everything end end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife delete --both /cookbooks/x fails' do - knife('delete --both /cookbooks/x').should_fail "ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete.\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both /cookbooks/x fails" do + knife("delete --both /cookbooks/x").should_fail "ERROR: /cookbooks/x (remote) must be deleted recursively! Pass -r to knife delete.\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both -r /cookbooks/x deletes x' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both -r /cookbooks/x deletes x" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -513,18 +513,18 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /data_bags/x fails' do - knife('delete --both /data_bags/x').should_fail "ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete.\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both /data_bags/x fails" do + knife("delete --both /data_bags/x").should_fail "ERROR: /data_bags/x (remote) must be deleted recursively! Pass -r to knife delete.\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both -r /data_bags/x deletes x' do - knife('delete --both -r /data_bags/x').should_succeed "Deleted /data_bags/x\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both -r /data_bags/x deletes x" do + knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -544,12 +544,12 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /environments/x.json deletes x' do - knife('delete --both /environments/x.json').should_succeed "Deleted /environments/x.json\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both /environments/x.json deletes x" do + knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -570,12 +570,12 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /roles/x.json deletes x' do - knife('delete --both /roles/x.json').should_succeed "Deleted /roles/x.json\n" - knife('list -Rf /').should_succeed <<EOM + it "knife delete --both /roles/x.json deletes x" do + knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n" + knife("list -Rf /").should_succeed <<EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -596,23 +596,23 @@ EOM /users/admin.json /users/x.json EOM - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /environments/_default.json fails' do - knife('delete --both /environments/_default.json').should_fail "", :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both /environments/_default.json fails" do + knife("delete --both /environments/_default.json").should_fail "", :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both / fails' do - knife('delete --both /').should_fail "ERROR: / (remote) cannot be deleted.\nERROR: / (local) cannot be deleted.\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both / fails" do + knife("delete --both /").should_fail "ERROR: / (remote) cannot be deleted.\nERROR: / (local) cannot be deleted.\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both -r /* fails' do - knife('delete --both -r /*').should_fail <<EOM + it "knife delete --both -r /* fails" do + knife("delete --both -r /*").should_fail <<EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. ERROR: /clients (remote) cannot be deleted. @@ -630,21 +630,21 @@ ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. EOM - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - it 'knife delete --both /environments/nonexistent.json fails' do - knife('delete --both /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" - knife('list -Rf /').should_succeed server_everything - knife('list -Rf --local /').should_succeed nothing + it "knife delete --both /environments/nonexistent.json fails" do + knife("delete --both /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + knife("list -Rf /").should_succeed server_everything + knife("list -Rf --local /").should_succeed nothing end - context 'and cwd is at the top level' do - before { cwd '.' } - it 'knife delete fails' do - knife('delete').should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/ - knife('list -Rf /').should_succeed <<EOM + context "and cwd is at the top level" do + before { cwd "." } + it "knife delete fails" do + knife("delete").should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/ + knife("list -Rf /").should_succeed <<EOM clients clients/chef-validator.json clients/chef-webui.json @@ -666,7 +666,7 @@ users users/admin.json users/x.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM clients cookbooks data_bags @@ -680,29 +680,29 @@ EOM end end - when_the_chef_server 'is empty' do - when_the_repository 'has one of each thing' do + when_the_chef_server "is empty" do + when_the_repository "has one of each thing" do before do - file 'clients/x.json', {} - file 'cookbooks/x/metadata.rb', '' - file 'data_bags/x/y.json', {} - file 'environments/_default.json', {} - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/x.json', {} - end - - it 'knife delete --both /cookbooks/x fails' do - knife('delete --both /cookbooks/x').should_fail "ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete.\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything - end - - it 'knife delete --both -r /cookbooks/x deletes x' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + file "clients/x.json", {} + file "cookbooks/x/metadata.rb", "" + file "data_bags/x/y.json", {} + file "environments/_default.json", {} + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/x.json", {} + end + + it "knife delete --both /cookbooks/x fails" do + knife("delete --both /cookbooks/x").should_fail "ERROR: /cookbooks/x (local) must be deleted recursively! Pass -r to knife delete.\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything + end + + it "knife delete --both -r /cookbooks/x deletes x" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -721,16 +721,16 @@ EOM EOM end - it 'knife delete --both /data_bags/x fails' do - knife('delete --both /data_bags/x').should_fail "ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete.\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything + it "knife delete --both /data_bags/x fails" do + knife("delete --both /data_bags/x").should_fail "ERROR: /data_bags/x (local) must be deleted recursively! Pass -r to knife delete.\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /data_bags/x deletes x' do - knife('delete --both -r /data_bags/x').should_succeed "Deleted /data_bags/x\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both -r /data_bags/x deletes x" do + knife("delete --both -r /data_bags/x").should_succeed "Deleted /data_bags/x\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -749,10 +749,10 @@ EOM EOM end - it 'knife delete --both /environments/x.json deletes x' do - knife('delete --both /environments/x.json').should_succeed "Deleted /environments/x.json\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both /environments/x.json deletes x" do + knife("delete --both /environments/x.json").should_succeed "Deleted /environments/x.json\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -772,10 +772,10 @@ EOM EOM end - it 'knife delete --both /roles/x.json deletes x' do - knife('delete --both /roles/x.json').should_succeed "Deleted /roles/x.json\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both /roles/x.json deletes x" do + knife("delete --both /roles/x.json").should_succeed "Deleted /roles/x.json\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -795,10 +795,10 @@ EOM EOM end - it 'knife delete --both /environments/_default.json fails but still deletes the local copy' do - knife('delete --both /environments/_default.json').should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed <<EOM + it "knife delete --both /environments/_default.json fails but still deletes the local copy" do + knife("delete --both /environments/_default.json").should_fail :stderr => "ERROR: /environments/_default.json (remote) cannot be deleted (default environment cannot be modified).\n", :stdout => "Deleted /environments/_default.json\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed <<EOM /clients /clients/x.json /cookbooks @@ -818,14 +818,14 @@ EOM EOM end - it 'knife delete --both / fails' do - knife('delete --both /').should_fail "ERROR: / (remote) cannot be deleted.\nERROR: / (local) cannot be deleted.\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything + it "knife delete --both / fails" do + knife("delete --both /").should_fail "ERROR: / (remote) cannot be deleted.\nERROR: / (local) cannot be deleted.\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both -r /* fails' do - knife('delete --both -r /*').should_fail <<EOM + it "knife delete --both -r /* fails" do + knife("delete --both -r /*").should_fail <<EOM ERROR: / (remote) cannot be deleted. ERROR: / (local) cannot be deleted. ERROR: /clients (remote) cannot be deleted. @@ -843,21 +843,21 @@ ERROR: /roles (local) cannot be deleted. ERROR: /users (remote) cannot be deleted. ERROR: /users (local) cannot be deleted. EOM - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything end - it 'knife delete --both /environments/nonexistent.json fails' do - knife('delete --both /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" - knife('list -Rf /').should_succeed server_nothing - knife('list -Rf --local /').should_succeed everything + it "knife delete --both /environments/nonexistent.json fails" do + knife("delete --both /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + knife("list -Rf /").should_succeed server_nothing + knife("list -Rf --local /").should_succeed everything end - context 'and cwd is at the top level' do - before { cwd '.' } - it 'knife delete fails' do - knife('delete').should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/ - knife('list -Rf /').should_succeed <<EOM + context "and cwd is at the top level" do + before { cwd "." } + it "knife delete fails" do + knife("delete").should_fail "FATAL: Must specify at least one argument. If you want to delete everything in this directory, type \"knife delete --recurse .\"\n", :stdout => /USAGE/ + knife("list -Rf /").should_succeed <<EOM clients clients/chef-validator.json clients/chef-webui.json @@ -870,7 +870,7 @@ roles users users/admin.json EOM - knife('list -Rf --local /').should_succeed <<EOM + knife("list -Rf --local /").should_succeed <<EOM clients clients/x.json cookbooks @@ -894,124 +894,124 @@ EOM end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', 'version "1.0.0"' - file 'cookbooks/x/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x/metadata.rb", 'version "1.0.0"' + file "cookbooks/x/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end # TODO this seems wrong - it 'knife delete --both -r /cookbooks/x deletes the latest version on the server and the local version' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_succeed(/1.0.0/) - knife('list --local /cookbooks').should_succeed '' + it "knife delete --both -r /cookbooks/x deletes the latest version on the server and the local version" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_succeed(/1.0.0/) + knife("list --local /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife delete --both /cookbooks/x deletes the latest version on the server and the local version' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_succeed(/0.9.9/) - knife('list --local /cookbooks').should_succeed '' + it "knife delete --both /cookbooks/x deletes the latest version on the server and the local version" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_succeed(/0.9.9/) + knife("list --local /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do - before { cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } } + when_the_chef_server "has a later version for the cookbook, and no current version" do + before { cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } } - it 'knife delete --both /cookbooks/x deletes the server and client version of the cookbook' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_fail(/404/) - knife('list --local /cookbooks').should_succeed '' + it "knife delete --both /cookbooks/x deletes the server and client version of the cookbook" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_fail(/404/) + knife("list --local /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do - before { cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } } + when_the_chef_server "has an earlier version for the cookbook, and no current version" do + before { cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } } - it 'knife delete --both /cookbooks/x deletes the server and client version of the cookbook' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_fail(/404/) - knife('list --local /cookbooks').should_succeed '' + it "knife delete --both /cookbooks/x deletes the server and client version of the cookbook" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_fail(/404/) + knife("list --local /cookbooks").should_succeed "" end end end - when_the_repository 'is empty' do - when_the_chef_server 'has two versions of a cookbook' do + when_the_repository "is empty" do + when_the_chef_server "has two versions of a cookbook" do before do - cookbook 'x', '2.0.11' - cookbook 'x', '11.0.0' + cookbook "x", "2.0.11" + cookbook "x", "11.0.0" end - it 'knife delete deletes the latest version' do - knife('delete --both -r /cookbooks/x').should_succeed "Deleted /cookbooks/x\n" - knife('raw /cookbooks/x').should_succeed( /2.0.11/ ) + it "knife delete deletes the latest version" do + knife("delete --both -r /cookbooks/x").should_succeed "Deleted /cookbooks/x\n" + knife("raw /cookbooks/x").should_succeed( /2.0.11/ ) end end end when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do before do - organization 'foo' do - container 'x', {} - group 'x', {} - policy 'x', '1.2.3', {} - policy_group 'x', { 'policies' => { 'x' => { 'revision_id' => '1.2.3' } } } + organization "foo" do + container "x", {} + group "x", {} + policy "x", "1.2.3", {} + policy_group "x", { "policies" => { "x" => { "revision_id" => "1.2.3" } } } end end before :each do - Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo') + Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo") end - it 'knife delete /acls/containers/environments.json fails with a reasonable error' do - knife('delete /acls/containers/environments.json').should_fail "ERROR: /acls/containers/environments.json (remote) ACLs cannot be deleted.\n" + it "knife delete /acls/containers/environments.json fails with a reasonable error" do + knife("delete /acls/containers/environments.json").should_fail "ERROR: /acls/containers/environments.json (remote) ACLs cannot be deleted.\n" end - it 'knife delete /containers/x.json succeeds' do - knife('delete /containers/x.json').should_succeed "Deleted /containers/x.json\n" - knife('raw /containers/x.json').should_fail(/404/) + it "knife delete /containers/x.json succeeds" do + knife("delete /containers/x.json").should_succeed "Deleted /containers/x.json\n" + knife("raw /containers/x.json").should_fail(/404/) end - it 'knife delete /groups/x.json succeeds' do - knife('delete /groups/x.json').should_succeed "Deleted /groups/x.json\n" - knife('raw /groups/x.json').should_fail(/404/) + it "knife delete /groups/x.json succeeds" do + knife("delete /groups/x.json").should_succeed "Deleted /groups/x.json\n" + knife("raw /groups/x.json").should_fail(/404/) end - it 'knife delete /policies/x-1.2.3.json succeeds' do - knife('raw /policies/x/revisions/1.2.3').should_succeed "{\n \"name\": \"x\",\n \"revision_id\": \"1.2.3\",\n \"run_list\": [\n\n ],\n \"cookbook_locks\": {\n\n }\n}\n" - knife('delete /policies/x-1.2.3.json').should_succeed "Deleted /policies/x-1.2.3.json\n" - knife('raw /policies/x/revisions/1.2.3').should_fail(/404/) + it "knife delete /policies/x-1.2.3.json succeeds" do + knife("raw /policies/x/revisions/1.2.3").should_succeed "{\n \"name\": \"x\",\n \"revision_id\": \"1.2.3\",\n \"run_list\": [\n\n ],\n \"cookbook_locks\": {\n\n }\n}\n" + knife("delete /policies/x-1.2.3.json").should_succeed "Deleted /policies/x-1.2.3.json\n" + knife("raw /policies/x/revisions/1.2.3").should_fail(/404/) end - it 'knife delete /policy_groups/x.json succeeds' do - knife('raw /policy_groups/x').should_succeed "{\n \"uri\": \"http://127.0.0.1:8900/organizations/foo/policy_groups/x\",\n \"policies\": {\n \"x\": {\n \"revision_id\": \"1.2.3\"\n }\n }\n}\n" - knife('delete /policy_groups/x.json').should_succeed "Deleted /policy_groups/x.json\n" - knife('raw /policy_groups/x').should_fail(/404/) + it "knife delete /policy_groups/x.json succeeds" do + knife("raw /policy_groups/x").should_succeed "{\n \"uri\": \"http://127.0.0.1:8900/organizations/foo/policy_groups/x\",\n \"policies\": {\n \"x\": {\n \"revision_id\": \"1.2.3\"\n }\n }\n}\n" + knife("delete /policy_groups/x.json").should_succeed "Deleted /policy_groups/x.json\n" + knife("raw /policy_groups/x").should_fail(/404/) end - it 'knife delete /org.json fails with a reasonable error' do - knife('delete /org.json').should_fail "ERROR: /org.json (remote) cannot be deleted.\n" + it "knife delete /org.json fails with a reasonable error" do + knife("delete /org.json").should_fail "ERROR: /org.json (remote) cannot be deleted.\n" end - it 'knife delete /invitations.json fails with a reasonable error' do - knife('delete /invitations.json').should_fail "ERROR: /invitations.json (remote) cannot be deleted.\n" + it "knife delete /invitations.json fails with a reasonable error" do + knife("delete /invitations.json").should_fail "ERROR: /invitations.json (remote) cannot be deleted.\n" end - it 'knife delete /members.json fails with a reasonable error' do - knife('delete /members.json').should_fail "ERROR: /members.json (remote) cannot be deleted.\n" + it "knife delete /members.json fails with a reasonable error" do + knife("delete /members.json").should_fail "ERROR: /members.json (remote) cannot be deleted.\n" end end end diff --git a/spec/integration/knife/deps_spec.rb b/spec/integration/knife/deps_spec.rb index 6861913d59..8348c601aa 100644 --- a/spec/integration/knife/deps_spec.rb +++ b/spec/integration/knife/deps_spec.rb @@ -15,33 +15,33 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/deps' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/deps" -describe 'knife deps', :workstation do +describe "knife deps", :workstation do include IntegrationSupport include KnifeSupport - context 'local' do - when_the_repository 'has a role with no run_list' do - before { file 'roles/starring.json', {} } - it 'knife deps reports no dependencies' do - knife('deps /roles/starring.json').should_succeed "/roles/starring.json\n" + context "local" do + when_the_repository "has a role with no run_list" do + before { file "roles/starring.json", {} } + it "knife deps reports no dependencies" do + knife("deps /roles/starring.json").should_succeed "/roles/starring.json\n" end end - when_the_repository 'has a role with a default run_list' do + when_the_repository "has a role with a default run_list" do before do - file 'roles/starring.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - file 'roles/minor.json', {} - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' - file 'cookbooks/soup/metadata.rb', 'name "soup"' - file 'cookbooks/soup/recipes/chicken.rb', '' - end - it 'knife deps reports all dependencies' do - knife('deps /roles/starring.json').should_succeed <<EOM + file "roles/starring.json", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + file "roles/minor.json", {} + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" + file "cookbooks/soup/metadata.rb", 'name "soup"' + file "cookbooks/soup/recipes/chicken.rb", "" + end + it "knife deps reports all dependencies" do + knife("deps /roles/starring.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -50,17 +50,17 @@ EOM end end - when_the_repository 'has a role with an env_run_list' do + when_the_repository "has a role with an env_run_list" do before do - file 'roles/starring.json', { 'env_run_lists' => { 'desert' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } } - file 'roles/minor.json', {} - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' - file 'cookbooks/soup/metadata.rb', 'name "soup"' - file 'cookbooks/soup/recipes/chicken.rb', '' - end - it 'knife deps reports all dependencies' do - knife('deps /roles/starring.json').should_succeed <<EOM + file "roles/starring.json", { "env_run_lists" => { "desert" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } } + file "roles/minor.json", {} + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" + file "cookbooks/soup/metadata.rb", 'name "soup"' + file "cookbooks/soup/recipes/chicken.rb", "" + end + it "knife deps reports all dependencies" do + knife("deps /roles/starring.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -69,32 +69,32 @@ EOM end end - when_the_repository 'has a node with no environment or run_list' do - before { file 'nodes/mort.json', {} } - it 'knife deps reports just the node' do - knife('deps /nodes/mort.json').should_succeed "/nodes/mort.json\n" + when_the_repository "has a node with no environment or run_list" do + before { file "nodes/mort.json", {} } + it "knife deps reports just the node" do + knife("deps /nodes/mort.json").should_succeed "/nodes/mort.json\n" end end - when_the_repository 'has a node with an environment' do + when_the_repository "has a node with an environment" do before do - file 'environments/desert.json', {} - file 'nodes/mort.json', { 'chef_environment' => 'desert' } + file "environments/desert.json", {} + file "nodes/mort.json", { "chef_environment" => "desert" } end - it 'knife deps reports just the node' do - knife('deps /nodes/mort.json').should_succeed "/environments/desert.json\n/nodes/mort.json\n" + it "knife deps reports just the node" do + knife("deps /nodes/mort.json").should_succeed "/environments/desert.json\n/nodes/mort.json\n" end end - when_the_repository 'has a node with roles and recipes in its run_list' do + when_the_repository "has a node with roles and recipes in its run_list" do before do - file 'roles/minor.json', {} - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' - file 'cookbooks/soup/metadata.rb', 'name "soup"' - file 'cookbooks/soup/recipes/chicken.rb', '' - file 'nodes/mort.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - end - it 'knife deps reports just the node' do - knife('deps /nodes/mort.json').should_succeed <<EOM + file "roles/minor.json", {} + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" + file "cookbooks/soup/metadata.rb", 'name "soup"' + file "cookbooks/soup/recipes/chicken.rb", "" + file "nodes/mort.json", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + end + it "knife deps reports just the node" do + knife("deps /nodes/mort.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -102,53 +102,53 @@ EOM EOM end end - when_the_repository 'has a cookbook with no dependencies' do + when_the_repository "has a cookbook with no dependencies" do before do - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" end - it 'knife deps reports just the cookbook' do - knife('deps /cookbooks/quiche').should_succeed "/cookbooks/quiche\n" + it "knife deps reports just the cookbook" do + knife("deps /cookbooks/quiche").should_succeed "/cookbooks/quiche\n" end end - when_the_repository 'has a cookbook with dependencies' do + when_the_repository "has a cookbook with dependencies" do before do - file 'cookbooks/kettle/metadata.rb', 'name "kettle"' - file 'cookbooks/quiche/metadata.rb', 'name "quiche" + file "cookbooks/kettle/metadata.rb", 'name "kettle"' + file "cookbooks/quiche/metadata.rb", 'name "quiche" depends "kettle"' - file 'cookbooks/quiche/recipes/default.rb', '' + file "cookbooks/quiche/recipes/default.rb", "" end - it 'knife deps reports just the cookbook' do - knife('deps /cookbooks/quiche').should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n" + it "knife deps reports just the cookbook" do + knife("deps /cookbooks/quiche").should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n" end end - when_the_repository 'has a data bag' do - before { file 'data_bags/bag/item.json', {} } - it 'knife deps reports just the data bag' do - knife('deps /data_bags/bag/item.json').should_succeed "/data_bags/bag/item.json\n" + when_the_repository "has a data bag" do + before { file "data_bags/bag/item.json", {} } + it "knife deps reports just the data bag" do + knife("deps /data_bags/bag/item.json").should_succeed "/data_bags/bag/item.json\n" end end - when_the_repository 'has an environment' do - before { file 'environments/desert.json', {} } - it 'knife deps reports just the environment' do - knife('deps /environments/desert.json').should_succeed "/environments/desert.json\n" + when_the_repository "has an environment" do + before { file "environments/desert.json", {} } + it "knife deps reports just the environment" do + knife("deps /environments/desert.json").should_succeed "/environments/desert.json\n" end end - when_the_repository 'has a deep dependency tree' do + when_the_repository "has a deep dependency tree" do before do - file 'roles/starring.json', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - file 'roles/minor.json', {} - file 'cookbooks/quiche/metadata.rb', 'name "quiche"' - file 'cookbooks/quiche/recipes/default.rb', '' - file 'cookbooks/soup/metadata.rb', 'name "soup"' - file 'cookbooks/soup/recipes/chicken.rb', '' - file 'environments/desert.json', {} - file 'nodes/mort.json', { 'chef_environment' => 'desert', 'run_list' => [ 'role[starring]' ] } - file 'nodes/bart.json', { 'run_list' => [ 'role[minor]' ] } + file "roles/starring.json", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + file "roles/minor.json", {} + file "cookbooks/quiche/metadata.rb", 'name "quiche"' + file "cookbooks/quiche/recipes/default.rb", "" + file "cookbooks/soup/metadata.rb", 'name "soup"' + file "cookbooks/soup/recipes/chicken.rb", "" + file "environments/desert.json", {} + file "nodes/mort.json", { "chef_environment" => "desert", "run_list" => [ "role[starring]" ] } + file "nodes/bart.json", { "run_list" => [ "role[minor]" ] } end - it 'knife deps reports all dependencies' do - knife('deps /nodes/mort.json').should_succeed <<EOM + it "knife deps reports all dependencies" do + knife("deps /nodes/mort.json").should_succeed <<EOM /environments/desert.json /roles/minor.json /cookbooks/quiche @@ -157,8 +157,8 @@ depends "kettle"' /nodes/mort.json EOM end - it 'knife deps * reports all dependencies of all things' do - knife('deps /nodes/*').should_succeed <<EOM + it "knife deps * reports all dependencies of all things" do + knife("deps /nodes/*").should_succeed <<EOM /roles/minor.json /nodes/bart.json /environments/desert.json @@ -168,8 +168,8 @@ EOM /nodes/mort.json EOM end - it 'knife deps a b reports all dependencies of a and b' do - knife('deps /nodes/bart.json /nodes/mort.json').should_succeed <<EOM + it "knife deps a b reports all dependencies of a and b" do + knife("deps /nodes/bart.json /nodes/mort.json").should_succeed <<EOM /roles/minor.json /nodes/bart.json /environments/desert.json @@ -179,8 +179,8 @@ EOM /nodes/mort.json EOM end - it 'knife deps --tree /* shows dependencies in a tree' do - knife('deps --tree /nodes/*').should_succeed <<EOM + it "knife deps --tree /* shows dependencies in a tree" do + knife("deps --tree /nodes/*").should_succeed <<EOM /nodes/bart.json /roles/minor.json /nodes/mort.json @@ -191,8 +191,8 @@ EOM /cookbooks/soup EOM end - it 'knife deps --tree --no-recurse shows only the first level of dependencies' do - knife('deps --tree --no-recurse /nodes/*').should_succeed <<EOM + it "knife deps --tree --no-recurse shows only the first level of dependencies" do + knife("deps --tree --no-recurse /nodes/*").should_succeed <<EOM /nodes/bart.json /roles/minor.json /nodes/mort.json @@ -202,49 +202,49 @@ EOM end end - context 'circular dependencies' do - when_the_repository 'has cookbooks with circular dependencies' do + context "circular dependencies" do + when_the_repository "has cookbooks with circular dependencies" do before do - file 'cookbooks/foo/metadata.rb', 'name "foo" + file "cookbooks/foo/metadata.rb", 'name "foo" depends "bar"' - file 'cookbooks/bar/metadata.rb', 'name "bar" + file "cookbooks/bar/metadata.rb", 'name "bar" depends "baz"' - file 'cookbooks/baz/metadata.rb', 'name "baz" + file "cookbooks/baz/metadata.rb", 'name "baz" depends "foo"' - file 'cookbooks/self/metadata.rb', 'name "self" + file "cookbooks/self/metadata.rb", 'name "self" depends "self"' end - it 'knife deps prints each once' do - knife('deps /cookbooks/foo /cookbooks/self').should_succeed( + it "knife deps prints each once" do + knife("deps /cookbooks/foo /cookbooks/self").should_succeed( stdout: "/cookbooks/baz\n/cookbooks/bar\n/cookbooks/foo\n/cookbooks/self\n", stderr: "WARN: Ignoring self-dependency in cookbook self, please remove it (in the future this will be fatal).\n", ) end - it 'knife deps --tree prints each once' do - knife('deps --tree /cookbooks/foo /cookbooks/self').should_succeed( + it "knife deps --tree prints each once" do + knife("deps --tree /cookbooks/foo /cookbooks/self").should_succeed( stdout: "/cookbooks/foo\n /cookbooks/bar\n /cookbooks/baz\n /cookbooks/foo\n/cookbooks/self\n", stderr: "WARN: Ignoring self-dependency in cookbook self, please remove it (in the future this will be fatal).\n", ) end end - when_the_repository 'has roles with circular dependencies' do + when_the_repository "has roles with circular dependencies" do before do - file 'roles/foo.json', { 'run_list' => [ 'role[bar]' ] } - file 'roles/bar.json', { 'run_list' => [ 'role[baz]' ] } - file 'roles/baz.json', { 'run_list' => [ 'role[foo]' ] } - file 'roles/self.json', { 'run_list' => [ 'role[self]' ] } + file "roles/foo.json", { "run_list" => [ "role[bar]" ] } + file "roles/bar.json", { "run_list" => [ "role[baz]" ] } + file "roles/baz.json", { "run_list" => [ "role[foo]" ] } + file "roles/self.json", { "run_list" => [ "role[self]" ] } end - it 'knife deps prints each once' do - knife('deps /roles/foo.json /roles/self.json').should_succeed <<EOM + it "knife deps prints each once" do + knife("deps /roles/foo.json /roles/self.json").should_succeed <<EOM /roles/baz.json /roles/bar.json /roles/foo.json /roles/self.json EOM end - it 'knife deps --tree prints each once' do - knife('deps --tree /roles/foo.json /roles/self.json') do + it "knife deps --tree prints each once" do + knife("deps --tree /roles/foo.json /roles/self.json") do expect(stdout).to eq("/roles/foo.json\n /roles/bar.json\n /roles/baz.json\n /roles/foo.json\n/roles/self.json\n /roles/self.json\n") expect(stderr).to eq("WARNING: No knife configuration file found\n") end @@ -252,81 +252,81 @@ EOM end end - context 'missing objects' do - when_the_repository 'is empty' do - it 'knife deps /blah reports an error' do - knife('deps /blah').should_fail( + context "missing objects" do + when_the_repository "is empty" do + it "knife deps /blah reports an error" do + knife("deps /blah").should_fail( :exit_code => 2, :stdout => "/blah\n", :stderr => "ERROR: /blah: No such file or directory\n", ) end - it 'knife deps /roles/x.json reports an error' do - knife('deps /roles/x.json').should_fail( + it "knife deps /roles/x.json reports an error" do + knife("deps /roles/x.json").should_fail( :exit_code => 2, :stdout => "/roles/x.json\n", :stderr => "ERROR: /roles/x.json: No such file or directory\n", ) end - it 'knife deps /nodes/x.json reports an error' do - knife('deps /nodes/x.json').should_fail( + it "knife deps /nodes/x.json reports an error" do + knife("deps /nodes/x.json").should_fail( :exit_code => 2, :stdout => "/nodes/x.json\n", :stderr => "ERROR: /nodes/x.json: No such file or directory\n", ) end - it 'knife deps /environments/x.json reports an error' do - knife('deps /environments/x.json').should_fail( + it "knife deps /environments/x.json reports an error" do + knife("deps /environments/x.json").should_fail( :exit_code => 2, :stdout => "/environments/x.json\n", :stderr => "ERROR: /environments/x.json: No such file or directory\n", ) end - it 'knife deps /cookbooks/x reports an error' do - knife('deps /cookbooks/x').should_fail( + it "knife deps /cookbooks/x reports an error" do + knife("deps /cookbooks/x").should_fail( :exit_code => 2, :stdout => "/cookbooks/x\n", :stderr => "ERROR: /cookbooks/x: No such file or directory\n", ) end - it 'knife deps /data_bags/bag/item reports an error' do - knife('deps /data_bags/bag/item').should_fail( + it "knife deps /data_bags/bag/item reports an error" do + knife("deps /data_bags/bag/item").should_fail( :exit_code => 2, :stdout => "/data_bags/bag/item\n", :stderr => "ERROR: /data_bags/bag/item: No such file or directory\n", ) end end - when_the_repository 'is missing a dependent cookbook' do + when_the_repository "is missing a dependent cookbook" do before do - file 'roles/starring.json', { 'run_list' => [ 'recipe[quiche]'] } + file "roles/starring.json", { "run_list" => [ "recipe[quiche]"] } end - it 'knife deps reports the cookbook, along with an error' do - knife('deps /roles/starring.json').should_fail( + it "knife deps reports the cookbook, along with an error" do + knife("deps /roles/starring.json").should_fail( :exit_code => 2, :stdout => "/cookbooks/quiche\n/roles/starring.json\n", :stderr => "ERROR: /cookbooks/quiche: No such file or directory\n", ) end end - when_the_repository 'is missing a dependent environment' do + when_the_repository "is missing a dependent environment" do before do - file 'nodes/mort.json', { 'chef_environment' => 'desert' } + file "nodes/mort.json", { "chef_environment" => "desert" } end - it 'knife deps reports the environment, along with an error' do - knife('deps /nodes/mort.json').should_fail( + it "knife deps reports the environment, along with an error" do + knife("deps /nodes/mort.json").should_fail( :exit_code => 2, :stdout => "/environments/desert.json\n/nodes/mort.json\n", :stderr => "ERROR: /environments/desert.json: No such file or directory\n", ) end end - when_the_repository 'is missing a dependent role' do + when_the_repository "is missing a dependent role" do before do - file 'roles/starring.json', { 'run_list' => [ 'role[minor]'] } + file "roles/starring.json", { "run_list" => [ "role[minor]"] } end - it 'knife deps reports the role, along with an error' do - knife('deps /roles/starring.json').should_fail( + it "knife deps reports the role, along with an error" do + knife("deps /roles/starring.json").should_fail( :exit_code => 2, :stdout => "/roles/minor.json\n/roles/starring.json\n", :stderr => "ERROR: /roles/minor.json: No such file or directory\n", @@ -334,29 +334,29 @@ EOM end end end - context 'invalid objects' do - when_the_repository 'is empty' do - it 'knife deps / reports itself only' do - knife('deps /').should_succeed("/\n") + context "invalid objects" do + when_the_repository "is empty" do + it "knife deps / reports itself only" do + knife("deps /").should_succeed("/\n") end - it 'knife deps /roles reports an error' do - knife('deps /roles').should_fail( + it "knife deps /roles reports an error" do + knife("deps /roles").should_fail( :exit_code => 2, :stderr => "ERROR: /roles: No such file or directory\n", :stdout => "/roles\n", ) end end - when_the_repository 'has a data bag' do - before { file 'data_bags/bag/item.json', '' } - it 'knife deps /data_bags/bag shows no dependencies' do - knife('deps /data_bags/bag').should_succeed("/data_bags/bag\n") + when_the_repository "has a data bag" do + before { file "data_bags/bag/item.json", "" } + it "knife deps /data_bags/bag shows no dependencies" do + knife("deps /data_bags/bag").should_succeed("/data_bags/bag\n") end end - when_the_repository 'has a cookbook' do - before { file 'cookbooks/blah/metadata.rb', 'name "blah"' } - it 'knife deps on a cookbook file shows no dependencies' do - knife('deps /cookbooks/blah/metadata.rb').should_succeed( + when_the_repository "has a cookbook" do + before { file "cookbooks/blah/metadata.rb", 'name "blah"' } + it "knife deps on a cookbook file shows no dependencies" do + knife("deps /cookbooks/blah/metadata.rb").should_succeed( "/cookbooks/blah/metadata.rb\n" ) end @@ -364,25 +364,25 @@ EOM end end - context 'remote' do + context "remote" do include_context "default config options" - when_the_chef_server 'has a role with no run_list' do - before { role 'starring', {} } - it 'knife deps reports no dependencies' do - knife('deps --remote /roles/starring.json').should_succeed "/roles/starring.json\n" + when_the_chef_server "has a role with no run_list" do + before { role "starring", {} } + it "knife deps reports no dependencies" do + knife("deps --remote /roles/starring.json").should_succeed "/roles/starring.json\n" end end - when_the_chef_server 'has a role with a default run_list' do + when_the_chef_server "has a role with a default run_list" do before do - role 'starring', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - role 'minor', {} - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } - cookbook 'soup', '1.0.0', { 'metadata.rb' => %Q{name "soup"\nversion "1.0.0"\n}, 'recipes' => { 'chicken.rb' => '' } } + role "starring", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + role "minor", {} + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } + cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } } end - it 'knife deps reports all dependencies' do - knife('deps --remote /roles/starring.json').should_succeed <<EOM + it "knife deps reports all dependencies" do + knife("deps --remote /roles/starring.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -391,15 +391,15 @@ EOM end end - when_the_chef_server 'has a role with an env_run_list' do + when_the_chef_server "has a role with an env_run_list" do before do - role 'starring', { 'env_run_lists' => { 'desert' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } } - role 'minor', {} - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } - cookbook 'soup', '1.0.0', { 'metadata.rb' => %Q{name "soup"\nversion "1.0.0"\n}, 'recipes' => { 'chicken.rb' => '' } } + role "starring", { "env_run_lists" => { "desert" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } } + role "minor", {} + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } + cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } } end - it 'knife deps reports all dependencies' do - knife('deps --remote /roles/starring.json').should_succeed <<EOM + it "knife deps reports all dependencies" do + knife("deps --remote /roles/starring.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -408,30 +408,30 @@ EOM end end - when_the_chef_server 'has a node with no environment or run_list' do - before { node 'mort', {} } - it 'knife deps reports just the node' do - knife('deps --remote /nodes/mort.json').should_succeed "/nodes/mort.json\n" + when_the_chef_server "has a node with no environment or run_list" do + before { node "mort", {} } + it "knife deps reports just the node" do + knife("deps --remote /nodes/mort.json").should_succeed "/nodes/mort.json\n" end end - when_the_chef_server 'has a node with an environment' do + when_the_chef_server "has a node with an environment" do before do - environment 'desert', {} - node 'mort', { 'chef_environment' => 'desert' } + environment "desert", {} + node "mort", { "chef_environment" => "desert" } end - it 'knife deps reports just the node' do - knife('deps --remote /nodes/mort.json').should_succeed "/environments/desert.json\n/nodes/mort.json\n" + it "knife deps reports just the node" do + knife("deps --remote /nodes/mort.json").should_succeed "/environments/desert.json\n/nodes/mort.json\n" end end - when_the_chef_server 'has a node with roles and recipes in its run_list' do + when_the_chef_server "has a node with roles and recipes in its run_list" do before do - role 'minor', {} - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } - cookbook 'soup', '1.0.0', { 'metadata.rb' => %Q{name "soup"\nversion "1.0.0"\n}, 'recipes' => { 'chicken.rb' => '' } } - node 'mort', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + role "minor", {} + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } + cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } } + node "mort", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } end - it 'knife deps reports just the node' do - knife('deps --remote /nodes/mort.json').should_succeed <<EOM + it "knife deps reports just the node" do + knife("deps --remote /nodes/mort.json").should_succeed <<EOM /roles/minor.json /cookbooks/quiche /cookbooks/soup @@ -439,49 +439,49 @@ EOM EOM end end - when_the_chef_server 'has a cookbook with no dependencies' do + when_the_chef_server "has a cookbook with no dependencies" do before do - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } end - it 'knife deps reports just the cookbook' do - knife('deps --remote /cookbooks/quiche').should_succeed "/cookbooks/quiche\n" + it "knife deps reports just the cookbook" do + knife("deps --remote /cookbooks/quiche").should_succeed "/cookbooks/quiche\n" end end - when_the_chef_server 'has a cookbook with dependencies' do + when_the_chef_server "has a cookbook with dependencies" do before do - cookbook 'kettle', '1.0.0', { 'metadata.rb' => %Q{name "kettle"\nversion "1.0.0"\n} } - cookbook 'quiche', '1.0.0', { 'metadata.rb' => 'name "quiche" -depends "kettle"', 'recipes' => { 'default.rb' => '' } } + cookbook "kettle", "1.0.0", { "metadata.rb" => %Q{name "kettle"\nversion "1.0.0"\n} } + cookbook "quiche", "1.0.0", { "metadata.rb" => 'name "quiche" +depends "kettle"', "recipes" => { "default.rb" => "" } } end - it 'knife deps reports the cookbook and its dependencies' do - knife('deps --remote /cookbooks/quiche').should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n" + it "knife deps reports the cookbook and its dependencies" do + knife("deps --remote /cookbooks/quiche").should_succeed "/cookbooks/kettle\n/cookbooks/quiche\n" end end - when_the_chef_server 'has a data bag' do - before { data_bag 'bag', { 'item' => {} } } - it 'knife deps reports just the data bag' do - knife('deps --remote /data_bags/bag/item.json').should_succeed "/data_bags/bag/item.json\n" + when_the_chef_server "has a data bag" do + before { data_bag "bag", { "item" => {} } } + it "knife deps reports just the data bag" do + knife("deps --remote /data_bags/bag/item.json").should_succeed "/data_bags/bag/item.json\n" end end - when_the_chef_server 'has an environment' do - before { environment 'desert', {} } - it 'knife deps reports just the environment' do - knife('deps --remote /environments/desert.json').should_succeed "/environments/desert.json\n" + when_the_chef_server "has an environment" do + before { environment "desert", {} } + it "knife deps reports just the environment" do + knife("deps --remote /environments/desert.json").should_succeed "/environments/desert.json\n" end end - when_the_chef_server 'has a deep dependency tree' do + when_the_chef_server "has a deep dependency tree" do before do - role 'starring', { 'run_list' => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } - role 'minor', {} - cookbook 'quiche', '1.0.0', { 'metadata.rb' => %Q{name "quiche"\nversion "1.0.0"\n}, 'recipes' => { 'default.rb' => '' } } - cookbook 'soup', '1.0.0', { 'metadata.rb' => %Q{name "soup"\nversion "1.0.0"\n}, 'recipes' => { 'chicken.rb' => '' } } - environment 'desert', {} - node 'mort', { 'chef_environment' => 'desert', 'run_list' => [ 'role[starring]' ] } - node 'bart', { 'run_list' => [ 'role[minor]' ] } + role "starring", { "run_list" => %w(role[minor] recipe[quiche] recipe[soup::chicken]) } + role "minor", {} + cookbook "quiche", "1.0.0", { "metadata.rb" => %Q{name "quiche"\nversion "1.0.0"\n}, "recipes" => { "default.rb" => "" } } + cookbook "soup", "1.0.0", { "metadata.rb" => %Q{name "soup"\nversion "1.0.0"\n}, "recipes" => { "chicken.rb" => "" } } + environment "desert", {} + node "mort", { "chef_environment" => "desert", "run_list" => [ "role[starring]" ] } + node "bart", { "run_list" => [ "role[minor]" ] } end - it 'knife deps reports all dependencies' do - knife('deps --remote /nodes/mort.json').should_succeed <<EOM + it "knife deps reports all dependencies" do + knife("deps --remote /nodes/mort.json").should_succeed <<EOM /environments/desert.json /roles/minor.json /cookbooks/quiche @@ -490,8 +490,8 @@ depends "kettle"', 'recipes' => { 'default.rb' => '' } } /nodes/mort.json EOM end - it 'knife deps * reports all dependencies of all things' do - knife('deps --remote /nodes/*').should_succeed <<EOM + it "knife deps * reports all dependencies of all things" do + knife("deps --remote /nodes/*").should_succeed <<EOM /roles/minor.json /nodes/bart.json /environments/desert.json @@ -501,8 +501,8 @@ EOM /nodes/mort.json EOM end - it 'knife deps a b reports all dependencies of a and b' do - knife('deps --remote /nodes/bart.json /nodes/mort.json').should_succeed <<EOM + it "knife deps a b reports all dependencies of a and b" do + knife("deps --remote /nodes/bart.json /nodes/mort.json").should_succeed <<EOM /roles/minor.json /nodes/bart.json /environments/desert.json @@ -512,8 +512,8 @@ EOM /nodes/mort.json EOM end - it 'knife deps --tree /* shows dependencies in a tree' do - knife('deps --remote --tree /nodes/*').should_succeed <<EOM + it "knife deps --tree /* shows dependencies in a tree" do + knife("deps --remote --tree /nodes/*").should_succeed <<EOM /nodes/bart.json /roles/minor.json /nodes/mort.json @@ -524,8 +524,8 @@ EOM /cookbooks/soup EOM end - it 'knife deps --tree --no-recurse shows only the first level of dependencies' do - knife('deps --remote --tree --no-recurse /nodes/*').should_succeed <<EOM + it "knife deps --tree --no-recurse shows only the first level of dependencies" do + knife("deps --remote --tree --no-recurse /nodes/*").should_succeed <<EOM /nodes/bart.json /roles/minor.json /nodes/mort.json @@ -535,28 +535,28 @@ EOM end end - context 'circular dependencies' do - when_the_chef_server 'has cookbooks with circular dependencies' do + context "circular dependencies" do + when_the_chef_server "has cookbooks with circular dependencies" do before do - cookbook 'foo', '1.0.0', { 'metadata.rb' => 'name "foo" + cookbook "foo", "1.0.0", { "metadata.rb" => 'name "foo" depends "bar"' } - cookbook 'bar', '1.0.0', { 'metadata.rb' => 'name "bar" + cookbook "bar", "1.0.0", { "metadata.rb" => 'name "bar" depends "baz"' } - cookbook 'baz', '1.0.0', { 'metadata.rb' => 'name "baz" + cookbook "baz", "1.0.0", { "metadata.rb" => 'name "baz" depends "foo"' } - cookbook 'self', '1.0.0', { 'metadata.rb' => 'name "self" + cookbook "self", "1.0.0", { "metadata.rb" => 'name "self" depends "self"' } end - it 'knife deps prints each once' do - knife('deps --remote /cookbooks/foo /cookbooks/self').should_succeed <<EOM + it "knife deps prints each once" do + knife("deps --remote /cookbooks/foo /cookbooks/self").should_succeed <<EOM /cookbooks/baz /cookbooks/bar /cookbooks/foo /cookbooks/self EOM end - it 'knife deps --tree prints each once' do - knife('deps --remote --tree /cookbooks/foo /cookbooks/self').should_succeed <<EOM + it "knife deps --tree prints each once" do + knife("deps --remote --tree /cookbooks/foo /cookbooks/self").should_succeed <<EOM /cookbooks/foo /cookbooks/bar /cookbooks/baz @@ -566,23 +566,23 @@ EOM EOM end end - when_the_chef_server 'has roles with circular dependencies' do + when_the_chef_server "has roles with circular dependencies" do before do - role 'foo', { 'run_list' => [ 'role[bar]' ] } - role 'bar', { 'run_list' => [ 'role[baz]' ] } - role 'baz', { 'run_list' => [ 'role[foo]' ] } - role 'self', { 'run_list' => [ 'role[self]' ] } + role "foo", { "run_list" => [ "role[bar]" ] } + role "bar", { "run_list" => [ "role[baz]" ] } + role "baz", { "run_list" => [ "role[foo]" ] } + role "self", { "run_list" => [ "role[self]" ] } end - it 'knife deps prints each once' do - knife('deps --remote /roles/foo.json /roles/self.json').should_succeed <<EOM + it "knife deps prints each once" do + knife("deps --remote /roles/foo.json /roles/self.json").should_succeed <<EOM /roles/baz.json /roles/bar.json /roles/foo.json /roles/self.json EOM end - it 'knife deps --tree prints each once' do - knife('deps --remote --tree /roles/foo.json /roles/self.json') do + it "knife deps --tree prints each once" do + knife("deps --remote --tree /roles/foo.json /roles/self.json") do expect(stdout).to eq("/roles/foo.json\n /roles/bar.json\n /roles/baz.json\n /roles/foo.json\n/roles/self.json\n /roles/self.json\n") expect(stderr).to eq("WARNING: No knife configuration file found\n") end @@ -590,81 +590,81 @@ EOM end end - context 'missing objects' do - when_the_chef_server 'is empty' do - it 'knife deps /blah reports an error' do - knife('deps --remote /blah').should_fail( + context "missing objects" do + when_the_chef_server "is empty" do + it "knife deps /blah reports an error" do + knife("deps --remote /blah").should_fail( :exit_code => 2, :stdout => "/blah\n", :stderr => "ERROR: /blah: No such file or directory\n", ) end - it 'knife deps /roles/x.json reports an error' do - knife('deps --remote /roles/x.json').should_fail( + it "knife deps /roles/x.json reports an error" do + knife("deps --remote /roles/x.json").should_fail( :exit_code => 2, :stdout => "/roles/x.json\n", :stderr => "ERROR: /roles/x.json: No such file or directory\n", ) end - it 'knife deps /nodes/x.json reports an error' do - knife('deps --remote /nodes/x.json').should_fail( + it "knife deps /nodes/x.json reports an error" do + knife("deps --remote /nodes/x.json").should_fail( :exit_code => 2, :stdout => "/nodes/x.json\n", :stderr => "ERROR: /nodes/x.json: No such file or directory\n", ) end - it 'knife deps /environments/x.json reports an error' do - knife('deps --remote /environments/x.json').should_fail( + it "knife deps /environments/x.json reports an error" do + knife("deps --remote /environments/x.json").should_fail( :exit_code => 2, :stdout => "/environments/x.json\n", :stderr => "ERROR: /environments/x.json: No such file or directory\n", ) end - it 'knife deps /cookbooks/x reports an error' do - knife('deps --remote /cookbooks/x').should_fail( + it "knife deps /cookbooks/x reports an error" do + knife("deps --remote /cookbooks/x").should_fail( :exit_code => 2, :stdout => "/cookbooks/x\n", :stderr => "ERROR: /cookbooks/x: No such file or directory\n", ) end - it 'knife deps /data_bags/bag/item reports an error' do - knife('deps --remote /data_bags/bag/item').should_fail( + it "knife deps /data_bags/bag/item reports an error" do + knife("deps --remote /data_bags/bag/item").should_fail( :exit_code => 2, :stdout => "/data_bags/bag/item\n", :stderr => "ERROR: /data_bags/bag/item: No such file or directory\n", ) end end - when_the_chef_server 'is missing a dependent cookbook' do + when_the_chef_server "is missing a dependent cookbook" do before do - role 'starring', { 'run_list' => [ 'recipe[quiche]'] } + role "starring", { "run_list" => [ "recipe[quiche]"] } end - it 'knife deps reports the cookbook, along with an error' do - knife('deps --remote /roles/starring.json').should_fail( + it "knife deps reports the cookbook, along with an error" do + knife("deps --remote /roles/starring.json").should_fail( :exit_code => 2, :stdout => "/cookbooks/quiche\n/roles/starring.json\n", :stderr => "ERROR: /cookbooks/quiche: No such file or directory\n", ) end end - when_the_chef_server 'is missing a dependent environment' do + when_the_chef_server "is missing a dependent environment" do before do - node 'mort', { 'chef_environment' => 'desert' } + node "mort", { "chef_environment" => "desert" } end - it 'knife deps reports the environment, along with an error' do - knife('deps --remote /nodes/mort.json').should_fail( + it "knife deps reports the environment, along with an error" do + knife("deps --remote /nodes/mort.json").should_fail( :exit_code => 2, :stdout => "/environments/desert.json\n/nodes/mort.json\n", :stderr => "ERROR: /environments/desert.json: No such file or directory\n", ) end end - when_the_chef_server 'is missing a dependent role' do + when_the_chef_server "is missing a dependent role" do before do - role 'starring', { 'run_list' => [ 'role[minor]'] } + role "starring", { "run_list" => [ "role[minor]"] } end - it 'knife deps reports the role, along with an error' do - knife('deps --remote /roles/starring.json').should_fail( + it "knife deps reports the role, along with an error" do + knife("deps --remote /roles/starring.json").should_fail( :exit_code => 2, :stdout => "/roles/minor.json\n/roles/starring.json\n", :stderr => "ERROR: /roles/minor.json: No such file or directory\n", @@ -672,27 +672,27 @@ EOM end end end - context 'invalid objects' do - when_the_chef_server 'is empty' do - it 'knife deps / reports an error' do - knife('deps --remote /').should_succeed("/\n") + context "invalid objects" do + when_the_chef_server "is empty" do + it "knife deps / reports an error" do + knife("deps --remote /").should_succeed("/\n") end - it 'knife deps /roles reports an error' do - knife('deps --remote /roles').should_succeed("/roles\n") + it "knife deps /roles reports an error" do + knife("deps --remote /roles").should_succeed("/roles\n") end end - when_the_chef_server 'has a data bag' do - before { data_bag 'bag', { 'item' => {} } } - it 'knife deps /data_bags/bag shows no dependencies' do - knife('deps --remote /data_bags/bag').should_succeed("/data_bags/bag\n") + when_the_chef_server "has a data bag" do + before { data_bag "bag", { "item" => {} } } + it "knife deps /data_bags/bag shows no dependencies" do + knife("deps --remote /data_bags/bag").should_succeed("/data_bags/bag\n") end end - when_the_chef_server 'has a cookbook' do + when_the_chef_server "has a cookbook" do before do - cookbook 'blah', '1.0.0', { 'metadata.rb' => 'name "blah"' } + cookbook "blah", "1.0.0", { "metadata.rb" => 'name "blah"' } end - it 'knife deps on a cookbook file shows no dependencies' do - knife('deps --remote /cookbooks/blah/metadata.rb').should_succeed( + it "knife deps on a cookbook file shows no dependencies" do + knife("deps --remote /cookbooks/blah/metadata.rb").should_succeed( "/cookbooks/blah/metadata.rb\n" ) end @@ -700,7 +700,7 @@ EOM end end - it 'knife deps --no-recurse reports an error' do - knife('deps --no-recurse /').should_fail("ERROR: --no-recurse requires --tree\n") + it "knife deps --no-recurse reports an error" do + knife("deps --no-recurse /").should_fail("ERROR: --no-recurse requires --tree\n") end end diff --git a/spec/integration/knife/diff_spec.rb b/spec/integration/knife/diff_spec.rb index b32a4580a1..822b07d9e1 100644 --- a/spec/integration/knife/diff_spec.rb +++ b/spec/integration/knife/diff_spec.rb @@ -15,38 +15,38 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/diff' +require "support/shared/integration/integration_helper" +require "chef/knife/diff" -describe 'knife diff', :workstation do +describe "knife diff", :workstation do include IntegrationSupport include KnifeSupport - context 'without versioned cookbooks' do + context "without versioned cookbooks" do when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife diff reports everything as deleted' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports everything as deleted" do + knife("diff --name-status /").should_succeed <<EOM D\t/clients/chef-validator.json D\t/clients/chef-webui.json D\t/clients/x.json @@ -62,65 +62,65 @@ EOM end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife diff reports no differences' do - knife('diff /').should_succeed '' + it "knife diff reports no differences" do + knife("diff /").should_succeed "" end - it 'knife diff /environments/nonexistent.json reports an error' do - knife('diff /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n" + it "knife diff /environments/nonexistent.json reports an error" do + knife("diff /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n" end - it 'knife diff /environments/*.txt reports an error' do - knife('diff /environments/*.txt').should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n" + it "knife diff /environments/*.txt reports an error" do + knife("diff /environments/*.txt").should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "foo": "bar" } EOM end - it 'knife diff reports the role as different' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports the role as different" do + knife("diff --name-status /").should_succeed <<EOM M\t/roles/x.json EOM end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/blah.rb', '' - file 'cookbooks/y/metadata.rb', cb_metadata("y", "1.0.0") - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/blah.rb", "" + file "cookbooks/y/metadata.rb", cb_metadata("y", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife diff reports the new files as added' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports the new files as added" do + knife("diff --name-status /").should_succeed <<EOM A\t/clients/y.json A\t/cookbooks/x/blah.rb A\t/cookbooks/y @@ -133,16 +133,16 @@ A\t/users/y.json EOM end - context 'when cwd is the data_bags directory' do - before { cwd 'data_bags' } - it 'knife diff reports different data bags' do - knife('diff --name-status').should_succeed <<EOM + context "when cwd is the data_bags directory" do + before { cwd "data_bags" } + it "knife diff reports different data bags" do + knife("diff --name-status").should_succeed <<EOM A\tx/z.json A\ty EOM end - it 'knife diff * reports different data bags' do - knife('diff --name-status *').should_succeed <<EOM + it "knife diff * reports different data bags" do + knife("diff --name-status *").should_succeed <<EOM A\tx/z.json A\ty EOM @@ -151,9 +151,9 @@ EOM end end - when_the_repository 'is empty' do - it 'knife diff reports everything as deleted' do - knife('diff --name-status /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife diff reports everything as deleted" do + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -166,51 +166,51 @@ EOM end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x/onlyin1.0.0.rb', '' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/onlyin1.0.0.rb", "" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" } end - it 'knife diff /cookbooks/x shows differences' do - knife('diff --name-status /cookbooks/x').should_succeed <<EOM + it "knife diff /cookbooks/x shows differences" do + knife("diff --name-status /cookbooks/x").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb EOM end - it 'knife diff --diff-filter=MAT does not show deleted files' do - knife('diff --diff-filter=MAT --name-status /cookbooks/x').should_succeed <<EOM + it "knife diff --diff-filter=MAT does not show deleted files" do + knife("diff --diff-filter=MAT --name-status /cookbooks/x").should_succeed <<EOM M\t/cookbooks/x/metadata.rb A\t/cookbooks/x/onlyin1.0.0.rb EOM end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "" } end - it 'knife diff /cookbooks/x shows no differences' do - knife('diff --name-status /cookbooks/x').should_succeed '' + it "knife diff /cookbooks/x shows no differences" do + knife("diff --name-status /cookbooks/x").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" } end - it 'knife diff /cookbooks/x shows the differences' do - knife('diff --name-status /cookbooks/x').should_succeed <<EOM + it "knife diff /cookbooks/x shows the differences" do + knife("diff --name-status /cookbooks/x").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb @@ -218,13 +218,13 @@ EOM end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "" } end - it 'knife diff /cookbooks/x shows the differences' do - knife('diff --name-status /cookbooks/x').should_succeed <<EOM + it "knife diff /cookbooks/x shows the differences" do + knife("diff --name-status /cookbooks/x").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin0.9.9.rb A\t/cookbooks/x/onlyin1.0.0.rb @@ -233,22 +233,22 @@ EOM end end - context 'json diff tests' do - when_the_repository 'has an empty environment file' do + context "json diff tests" do + when_the_repository "has an empty environment file" do before do - file 'environments/x.json', {} + file "environments/x.json", {} end - when_the_chef_server 'has an empty environment' do - before { environment 'x', {} } - it 'knife diff returns no differences' do - knife('diff /environments/x.json').should_succeed '' + when_the_chef_server "has an empty environment" do + before { environment "x", {} } + it "knife diff returns no differences" do + knife("diff /environments/x.json").should_succeed "" end end - when_the_chef_server 'has an environment with a different value' do - before { environment 'x', { 'description' => 'hi' } } - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + when_the_chef_server "has an environment with a different value" do + before { environment "x", { "description" => "hi" } } + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { - "name": "x", - "description": "hi" @@ -259,26 +259,26 @@ EOM end end - when_the_repository 'has an environment file with a value in it' do + when_the_repository "has an environment file with a value in it" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - when_the_chef_server 'has an environment with the same value' do + when_the_chef_server "has an environment with the same value" do before do - environment 'x', { 'description' => 'hi' } + environment "x", { "description" => "hi" } end - it 'knife diff returns no differences' do - knife('diff /environments/x.json').should_succeed '' + it "knife diff returns no differences" do + knife("diff /environments/x.json").should_succeed "" end end - when_the_chef_server 'has an environment with no value' do + when_the_chef_server "has an environment with no value" do before do - environment 'x', {} + environment "x", {} end - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { - "name": "x" \+ "name": "x", @@ -287,12 +287,12 @@ EOM /) end end - when_the_chef_server 'has an environment with a different value' do + when_the_chef_server "has an environment with a different value" do before do - environment 'x', { 'description' => 'lo' } + environment "x", { "description" => "lo" } end - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { "name": "x", - "description": "lo" @@ -304,14 +304,14 @@ EOM end end - when_the_chef_server 'has an environment' do - before { environment 'x', {} } - when_the_repository 'has an environment with bad JSON' do - before { file 'environments/x.json', '{' } - it 'knife diff reports an error and does a textual diff' do + when_the_chef_server "has an environment" do + before { environment "x", {} } + when_the_repository "has an environment with bad JSON" do + before { file "environments/x.json", "{" } + it "knife diff reports an error and does a textual diff" do error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" error_match = Regexp.new(Regexp.escape(error_text)) - knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => error_match) + knife("diff /environments/x.json").should_succeed(/- "name": "x"/, :stderr => error_match) end end end @@ -320,28 +320,28 @@ EOM with_versioned_cookbooks do when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife diff reports everything as deleted' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports everything as deleted" do + knife("diff --name-status /").should_succeed <<EOM D\t/clients/chef-validator.json D\t/clients/chef-webui.json D\t/clients/x.json @@ -357,65 +357,65 @@ EOM end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife diff reports no differences' do - knife('diff /').should_succeed '' + it "knife diff reports no differences" do + knife("diff /").should_succeed "" end - it 'knife diff /environments/nonexistent.json reports an error' do - knife('diff /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n" + it "knife diff /environments/nonexistent.json reports an error" do + knife("diff /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory on remote or local\n" end - it 'knife diff /environments/*.txt reports an error' do - knife('diff /environments/*.txt').should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n" + it "knife diff /environments/*.txt reports an error" do + knife("diff /environments/*.txt").should_fail "ERROR: /environments/*.txt: No such file or directory on remote or local\n" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "foo": "bar" } EOM end - it 'knife diff reports the role as different' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports the role as different" do + knife("diff --name-status /").should_succeed <<EOM M\t/roles/x.json EOM end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', {} - file 'cookbooks/x-1.0.0/blah.rb', '' - file 'cookbooks/x-2.0.0/metadata.rb', cb_metadata("x", "2.0.0") - file 'cookbooks/y-1.0.0/metadata.rb', cb_metadata("y", "1.0.0") - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', {} + file "clients/y.json", {} + file "cookbooks/x-1.0.0/blah.rb", "" + file "cookbooks/x-2.0.0/metadata.rb", cb_metadata("x", "2.0.0") + file "cookbooks/y-1.0.0/metadata.rb", cb_metadata("y", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", {} end - it 'knife diff reports the new files as added' do - knife('diff --name-status /').should_succeed <<EOM + it "knife diff reports the new files as added" do + knife("diff --name-status /").should_succeed <<EOM A\t/clients/y.json A\t/cookbooks/x-1.0.0/blah.rb A\t/cookbooks/x-2.0.0 @@ -429,16 +429,16 @@ A\t/users/y.json EOM end - context 'when cwd is the data_bags directory' do - before { cwd 'data_bags' } - it 'knife diff reports different data bags' do - knife('diff --name-status').should_succeed <<EOM + context "when cwd is the data_bags directory" do + before { cwd "data_bags" } + it "knife diff reports different data bags" do + knife("diff --name-status").should_succeed <<EOM A\tx/z.json A\ty EOM end - it 'knife diff * reports different data bags' do - knife('diff --name-status *').should_succeed <<EOM + it "knife diff * reports different data bags" do + knife("diff --name-status *").should_succeed <<EOM A\tx/z.json A\ty EOM @@ -447,9 +447,9 @@ EOM end end - when_the_repository 'is empty' do - it 'knife diff reports everything as deleted' do - knife('diff --name-status /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife diff reports everything as deleted" do + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -462,59 +462,59 @@ EOM end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', '' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x-1.0.0/onlyin1.0.0.rb", "" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" } end - it 'knife diff /cookbooks shows differences' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife diff /cookbooks shows differences" do + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-1.0.1 EOM end - it 'knife diff --diff-filter=MAT does not show deleted files' do - knife('diff --diff-filter=MAT --name-status /cookbooks').should_succeed '' + it "knife diff --diff-filter=MAT does not show deleted files" do + knife("diff --diff-filter=MAT --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "" } end - it 'knife diff /cookbooks shows the differences' do - knife('diff --name-status /cookbooks').should_succeed "D\t/cookbooks/x-0.9.9\n" + it "knife diff /cookbooks shows the differences" do + knife("diff --name-status /cookbooks").should_succeed "D\t/cookbooks/x-0.9.9\n" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => '' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "" } end - it 'knife diff /cookbooks shows the differences' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife diff /cookbooks shows the differences" do + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-1.0.1 A\t/cookbooks/x-1.0.0 EOM end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => '' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "" } end - it 'knife diff /cookbooks shows the differences' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife diff /cookbooks shows the differences" do + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-0.9.9 A\t/cookbooks/x-1.0.0 EOM @@ -522,19 +522,19 @@ EOM end end - context 'json diff tests' do - when_the_repository 'has an empty environment file' do - before { file 'environments/x.json', {} } - when_the_chef_server 'has an empty environment' do - before { environment 'x', {} } - it 'knife diff returns no differences' do - knife('diff /environments/x.json').should_succeed '' + context "json diff tests" do + when_the_repository "has an empty environment file" do + before { file "environments/x.json", {} } + when_the_chef_server "has an empty environment" do + before { environment "x", {} } + it "knife diff returns no differences" do + knife("diff /environments/x.json").should_succeed "" end end - when_the_chef_server 'has an environment with a different value' do - before { environment 'x', { 'description' => 'hi' } } - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + when_the_chef_server "has an environment with a different value" do + before { environment "x", { "description" => "hi" } } + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { - "name": "x", - "description": "hi" @@ -545,23 +545,23 @@ EOM end end - when_the_repository 'has an environment file with a value in it' do + when_the_repository "has an environment file with a value in it" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - when_the_chef_server 'has an environment with the same value' do + when_the_chef_server "has an environment with the same value" do before do - environment 'x', { 'description' => 'hi' } + environment "x", { "description" => "hi" } end - it 'knife diff returns no differences' do - knife('diff /environments/x.json').should_succeed '' + it "knife diff returns no differences" do + knife("diff /environments/x.json").should_succeed "" end end - when_the_chef_server 'has an environment with no value' do - before { environment 'x', {} } - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + when_the_chef_server "has an environment with no value" do + before { environment "x", {} } + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { - "name": "x" \+ "name": "x", @@ -570,12 +570,12 @@ EOM /) end end - when_the_chef_server 'has an environment with a different value' do + when_the_chef_server "has an environment with a different value" do before do - environment 'x', { 'description' => 'lo' } + environment "x", { "description" => "lo" } end - it 'knife diff reports the difference', :skip => (RUBY_VERSION < "1.9") do - knife('diff /environments/x.json').should_succeed(/ + it "knife diff reports the difference", :skip => (RUBY_VERSION < "1.9") do + knife("diff /environments/x.json").should_succeed(/ { "name": "x", - "description": "lo" @@ -587,14 +587,14 @@ EOM end end - when_the_chef_server 'has an environment' do - before { environment 'x', {} } - when_the_repository 'has an environment with bad JSON' do - before { file 'environments/x.json', '{' } - it 'knife diff reports an error and does a textual diff' do + when_the_chef_server "has an environment" do + before { environment "x", {} } + when_the_repository "has an environment with bad JSON" do + before { file "environments/x.json", "{" } + it "knife diff reports an error and does a textual diff" do error_text = "WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF" error_match = Regexp.new(Regexp.escape(error_text)) - knife('diff /environments/x.json').should_succeed(/- "name": "x"/, :stderr => error_match) + knife("diff /environments/x.json").should_succeed(/- "name": "x"/, :stderr => error_match) end end end diff --git a/spec/integration/knife/download_spec.rb b/spec/integration/knife/download_spec.rb index 24618ebcae..faa640f83b 100644 --- a/spec/integration/knife/download_spec.rb +++ b/spec/integration/knife/download_spec.rb @@ -15,40 +15,40 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/download' -require 'chef/knife/diff' +require "support/shared/integration/integration_helper" +require "chef/knife/download" +require "chef/knife/diff" -describe 'knife download', :workstation do +describe "knife download", :workstation do include IntegrationSupport include KnifeSupport - context 'without versioned cookbooks' do + context "without versioned cookbooks" do when_the_chef_server "has one of each thing" do before do - client 'x', {} - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => {} } - environment 'x', {} - node 'x', {} - role 'x', {} - user 'x', {} + client "x", {} + cookbook "x", "1.0.0" + data_bag "x", { "y" => {} } + environment "x", {} + node "x", {} + role "x", {} + user "x", {} end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife download downloads everything' do - knife('download /').should_succeed <<EOM + it "knife download downloads everything" do + knife("download /").should_succeed <<EOM Created /clients/chef-validator.json Created /clients/chef-webui.json Created /clients/x.json @@ -63,38 +63,38 @@ Created /roles/x.json Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife download makes no changes' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download makes no changes" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - it 'knife download --purge makes no changes' do - knife('download --purge /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download --purge makes no changes" do + knife("download --purge /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role", "default_attributes": { @@ -113,20 +113,20 @@ EOM EOM end - it 'knife download changes the role' do - knife('download /').should_succeed "Updated /roles/x.json\n" - knife('diff --name-status /').should_succeed '' + it "knife download changes the role" do + knife("download /").should_succeed "Updated /roles/x.json\n" + knife("diff --name-status /").should_succeed "" end - it 'knife download --no-diff does not change the role' do - knife('download --no-diff /').should_succeed '' - knife('diff --name-status /').should_succeed "M\t/roles/x.json\n" + it "knife download --no-diff does not change the role" do + knife("download --no-diff /").should_succeed "" + knife("diff --name-status /").should_succeed "M\t/roles/x.json\n" end end - context 'except the role file is textually different, but not ACTUALLY different' do + context "except the role file is textually different, but not ACTUALLY different" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role", "default_attributes": { @@ -145,28 +145,28 @@ EOM EOM end - it 'knife download / does not change anything' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download / does not change anything" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed "" end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/blah.rb', '' - file 'cookbooks/y/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/blah.rb", "" + file "cookbooks/y/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife download does nothing' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + it "knife download does nothing" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM A\t/clients/y.json A\t/cookbooks/x/blah.rb A\t/cookbooks/y @@ -179,8 +179,8 @@ A\t/users/y.json EOM end - it 'knife download --purge deletes the extra files' do - knife('download --purge /').should_succeed <<EOM + it "knife download --purge deletes the extra files" do + knife("download --purge /").should_succeed <<EOM Deleted extra entry /clients/y.json (purge is on) Deleted extra entry /cookbooks/x/blah.rb (purge is on) Deleted extra entry /cookbooks/y (purge is on) @@ -191,14 +191,14 @@ Deleted extra entry /nodes/y.json (purge is on) Deleted extra entry /roles/y.json (purge is on) Deleted extra entry /users/y.json (purge is on) EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end - when_the_repository 'is empty' do - it 'knife download creates the extra files' do - knife('download /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife download creates the extra files" do + knife("download /").should_succeed <<EOM Created /clients Created /clients/chef-validator.json Created /clients/chef-webui.json @@ -220,11 +220,11 @@ Created /users Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end - it 'knife download --no-diff creates the extra files' do - knife('download --no-diff /').should_succeed <<EOM + it "knife download --no-diff creates the extra files" do + knife("download --no-diff /").should_succeed <<EOM Created /clients Created /clients/chef-validator.json Created /clients/chef-webui.json @@ -246,41 +246,41 @@ Created /users Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end - context 'when current directory is top level' do + context "when current directory is top level" do before do - cwd '.' + cwd "." end - it 'knife download with no parameters reports an error' do - knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ + it "knife download with no parameters reports an error" do + knife("download").should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ end end end end # Test download of an item when the other end doesn't even have the container - when_the_repository 'is empty' do - when_the_chef_server 'has two data bag items' do + when_the_repository "is empty" do + when_the_chef_server "has two data bag items" do before do - data_bag 'x', { 'y' => {}, 'z' => {} } + data_bag "x", { "y" => {}, "z" => {} } end - it 'knife download of one data bag item itself succeeds' do - knife('download /data_bags/x/y.json').should_succeed <<EOM + it "knife download of one data bag item itself succeeds" do + knife("download /data_bags/x/y.json").should_succeed <<EOM Created /data_bags Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/z.json EOM end - it 'knife download /data_bags/x /data_bags/x/y.json downloads x once' do - knife('download /data_bags/x /data_bags/x/y.json').should_succeed <<EOM + it "knife download /data_bags/x /data_bags/x/y.json downloads x once" do + knife("download /data_bags/x /data_bags/x/y.json").should_succeed <<EOM Created /data_bags Created /data_bags/x Created /data_bags/x/y.json @@ -290,285 +290,285 @@ EOM end end - when_the_repository 'has three data bag items' do + when_the_repository "has three data bag items" do before do - file 'data_bags/x/deleted.json', <<EOM + file "data_bags/x/deleted.json", <<EOM { "id": "deleted" } EOM - file 'data_bags/x/modified.json', <<EOM + file "data_bags/x/modified.json", <<EOM { "id": "modified" } EOM - file 'data_bags/x/unmodified.json', <<EOM + file "data_bags/x/unmodified.json", <<EOM { "id": "unmodified" } EOM end - when_the_chef_server 'has a modified, unmodified, added and deleted data bag item' do + when_the_chef_server "has a modified, unmodified, added and deleted data bag item" do before do - data_bag 'x', { - 'added' => {}, - 'modified' => { 'foo' => 'bar' }, - 'unmodified' => {}, + data_bag "x", { + "added" => {}, + "modified" => { "foo" => "bar" }, + "unmodified" => {}, } end - it 'knife download of the modified file succeeds' do - knife('download /data_bags/x/modified.json').should_succeed <<EOM + it "knife download of the modified file succeeds" do + knife("download /data_bags/x/modified.json").should_succeed <<EOM Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the unmodified file does nothing' do - knife('download /data_bags/x/unmodified.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife download of the unmodified file does nothing" do + knife("download /data_bags/x/unmodified.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the added file succeeds' do - knife('download /data_bags/x/added.json').should_succeed <<EOM + it "knife download of the added file succeeds" do + knife("download /data_bags/x/added.json").should_succeed <<EOM Created /data_bags/x/added.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the deleted file does nothing' do - knife('download /data_bags/x/deleted.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife download of the deleted file does nothing" do + knife("download /data_bags/x/deleted.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download --purge of the deleted file deletes it' do - knife('download --purge /data_bags/x/deleted.json').should_succeed <<EOM + it "knife download --purge of the deleted file deletes it" do + knife("download --purge /data_bags/x/deleted.json").should_succeed <<EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json EOM end - it 'knife download of the entire data bag downloads everything' do - knife('download /data_bags/x').should_succeed <<EOM + it "knife download of the entire data bag downloads everything" do + knife("download /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM A\t/data_bags/x/deleted.json EOM end - it 'knife download --purge of the entire data bag downloads everything' do - knife('download --purge /data_bags/x').should_succeed <<EOM + it "knife download --purge of the entire data bag downloads everything" do + knife("download --purge /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - context 'when cwd is the /data_bags directory' do + context "when cwd is the /data_bags directory" do before do - cwd 'data_bags' + cwd "data_bags" end - it 'knife download fails' do - knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ + it "knife download fails" do + knife("download").should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ end - it 'knife download --purge . downloads everything' do - knife('download --purge .').should_succeed <<EOM + it "knife download --purge . downloads everything" do + knife("download --purge .").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - it 'knife download --purge * downloads everything' do - knife('download --purge *').should_succeed <<EOM + it "knife download --purge * downloads everything" do + knife("download --purge *").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x/z.rb', '' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/z.rb", "" end - when_the_chef_server 'has a modified, added and deleted file for the cookbook' do + when_the_chef_server "has a modified, added and deleted file for the cookbook" do before do - cookbook 'x', '1.0.0', { 'metadata.rb' => cb_metadata("x", "1.0.0", "#extra content"), 'y.rb' => 'hi' } + cookbook "x", "1.0.0", { "metadata.rb" => cb_metadata("x", "1.0.0", "#extra content"), "y.rb" => "hi" } end - it 'knife download of a modified file succeeds' do - knife('download /cookbooks/x/metadata.rb').should_succeed "Updated /cookbooks/x/metadata.rb\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of a modified file succeeds" do + knife("download /cookbooks/x/metadata.rb").should_succeed "Updated /cookbooks/x/metadata.rb\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x/y.rb A\t/cookbooks/x/z.rb EOM end - it 'knife download of a deleted file does nothing' do - knife('download /cookbooks/x/z.rb').should_succeed '' - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of a deleted file does nothing" do + knife("download /cookbooks/x/z.rb").should_succeed "" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/y.rb A\t/cookbooks/x/z.rb EOM end - it 'knife download --purge of a deleted file succeeds' do - knife('download --purge /cookbooks/x/z.rb').should_succeed "Deleted extra entry /cookbooks/x/z.rb (purge is on)\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download --purge of a deleted file succeeds" do + knife("download --purge /cookbooks/x/z.rb").should_succeed "Deleted extra entry /cookbooks/x/z.rb (purge is on)\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/y.rb EOM end - it 'knife download of an added file succeeds' do - knife('download /cookbooks/x/y.rb').should_succeed "Created /cookbooks/x/y.rb\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of an added file succeeds" do + knife("download /cookbooks/x/y.rb").should_succeed "Created /cookbooks/x/y.rb\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb A\t/cookbooks/x/z.rb EOM end - it 'knife download of the cookbook itself succeeds' do - knife('download /cookbooks/x').should_succeed <<EOM + it "knife download of the cookbook itself succeeds" do + knife("download /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/y.rb EOM - knife('diff --name-status /cookbooks').should_succeed <<EOM + knife("diff --name-status /cookbooks").should_succeed <<EOM A\t/cookbooks/x/z.rb EOM end - it 'knife download --purge of the cookbook itself succeeds' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download --purge of the cookbook itself succeeds" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/y.rb Deleted extra entry /cookbooks/x/z.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the latest version' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download /cookbooks/x downloads the latest version" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin1.0.1.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the updated file' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download /cookbooks/x downloads the updated file" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/onlyin1.0.0.rb EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the latest version' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download /cookbooks/x downloads the latest version" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin1.0.1.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the old version' do - knife('download --purge /cookbooks/x').should_succeed <<EOM + it "knife download /cookbooks/x downloads the old version" do + knife("download --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x/metadata.rb Created /cookbooks/x/onlyin0.9.9.rb Deleted extra entry /cookbooks/x/onlyin1.0.0.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_chef_server 'has an environment' do + when_the_chef_server "has an environment" do before do - environment 'x', {} + environment "x", {} end - when_the_repository 'has an environment with bad JSON' do + when_the_repository "has an environment with bad JSON" do before do - file 'environments/x.json', '{' + file "environments/x.json", "{" end - it 'knife download succeeds' do + it "knife download succeeds" do warning = <<-EOH WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF { (right here) ------^ EOH - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n", :stderr => warning - knife('diff --name-status /environments/x.json').should_succeed '' + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n", :stderr => warning + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has the same environment with the wrong name in the file' do + when_the_repository "has the same environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife download succeeds" do + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has the same environment with no name in the file' do + when_the_repository "has the same environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife download succeeds" do + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end end @@ -577,28 +577,28 @@ EOH with_versioned_cookbooks do when_the_chef_server "has one of each thing" do before do - client 'x', {} - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => {} } - environment 'x', {} - node 'x', {} - role 'x', {} - user 'x', {} + client "x", {} + cookbook "x", "1.0.0" + data_bag "x", { "y" => {} } + environment "x", {} + node "x", {} + role "x", {} + user "x", {} end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" end - it 'knife download downloads everything' do - knife('download /').should_succeed <<EOM + it "knife download downloads everything" do + knife("download /").should_succeed <<EOM Created /clients/chef-validator.json Created /clients/chef-webui.json Created /clients/x.json @@ -613,49 +613,49 @@ Created /roles/x.json Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife download makes no changes' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download makes no changes" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - it 'knife download --purge makes no changes' do - knife('download --purge /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download --purge makes no changes" do + knife("download --purge /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', { "description" => "blarghle" } + file "roles/x.json", { "description" => "blarghle" } end - it 'knife download changes the role' do - knife('download /').should_succeed "Updated /roles/x.json\n" - knife('diff --name-status /').should_succeed '' + it "knife download changes the role" do + knife("download /").should_succeed "Updated /roles/x.json\n" + knife("diff --name-status /").should_succeed "" end end - context 'except the role file is textually different, but not ACTUALLY different' do + context "except the role file is textually different, but not ACTUALLY different" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role" , "default_attributes": { @@ -674,29 +674,29 @@ EOM EOM end - it 'knife download / does not change anything' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife download / does not change anything" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed "" end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/blah.rb', '' - file 'cookbooks/x-2.0.0/metadata.rb', 'version "2.0.0"' - file 'cookbooks/y-1.0.0/metadata.rb', 'version "1.0.0"' - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/blah.rb", "" + file "cookbooks/x-2.0.0/metadata.rb", 'version "2.0.0"' + file "cookbooks/y-1.0.0/metadata.rb", 'version "1.0.0"' + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife download does nothing' do - knife('download /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + it "knife download does nothing" do + knife("download /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM A\t/clients/y.json A\t/cookbooks/x-1.0.0/blah.rb A\t/cookbooks/x-2.0.0 @@ -710,8 +710,8 @@ A\t/users/y.json EOM end - it 'knife download --purge deletes the extra files' do - knife('download --purge /').should_succeed <<EOM + it "knife download --purge deletes the extra files" do + knife("download --purge /").should_succeed <<EOM Deleted extra entry /clients/y.json (purge is on) Deleted extra entry /cookbooks/x-1.0.0/blah.rb (purge is on) Deleted extra entry /cookbooks/x-2.0.0 (purge is on) @@ -723,14 +723,14 @@ Deleted extra entry /nodes/y.json (purge is on) Deleted extra entry /roles/y.json (purge is on) Deleted extra entry /users/y.json (purge is on) EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end - when_the_repository 'is empty' do - it 'knife download creates the extra files' do - knife('download /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife download creates the extra files" do + knife("download /").should_succeed <<EOM Created /clients Created /clients/chef-validator.json Created /clients/chef-webui.json @@ -752,324 +752,324 @@ Created /users Created /users/admin.json Created /users/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end - context 'when current directory is top level' do + context "when current directory is top level" do before do - cwd '.' + cwd "." end - it 'knife download with no parameters reports an error' do - knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ + it "knife download with no parameters reports an error" do + knife("download").should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ end end end end # Test download of an item when the other end doesn't even have the container - when_the_repository 'is empty' do - when_the_chef_server 'has two data bag items' do + when_the_repository "is empty" do + when_the_chef_server "has two data bag items" do before do - data_bag 'x', { 'y' => {}, 'z' => {} } + data_bag "x", { "y" => {}, "z" => {} } end - it 'knife download of one data bag item itself succeeds' do - knife('download /data_bags/x/y.json').should_succeed <<EOM + it "knife download of one data bag item itself succeeds" do + knife("download /data_bags/x/y.json").should_succeed <<EOM Created /data_bags Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/z.json EOM end end end - when_the_repository 'has three data bag items' do + when_the_repository "has three data bag items" do before do - file 'data_bags/x/deleted.json', <<EOM + file "data_bags/x/deleted.json", <<EOM { "id": "deleted" } EOM - file 'data_bags/x/modified.json', <<EOM + file "data_bags/x/modified.json", <<EOM { "id": "modified" } EOM - file 'data_bags/x/unmodified.json', <<EOM + file "data_bags/x/unmodified.json", <<EOM { "id": "unmodified" } EOM end - when_the_chef_server 'has a modified, unmodified, added and deleted data bag item' do + when_the_chef_server "has a modified, unmodified, added and deleted data bag item" do before do - data_bag 'x', { - 'added' => {}, - 'modified' => { 'foo' => 'bar' }, - 'unmodified' => {}, + data_bag "x", { + "added" => {}, + "modified" => { "foo" => "bar" }, + "unmodified" => {}, } end - it 'knife download of the modified file succeeds' do - knife('download /data_bags/x/modified.json').should_succeed <<EOM + it "knife download of the modified file succeeds" do + knife("download /data_bags/x/modified.json").should_succeed <<EOM Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the unmodified file does nothing' do - knife('download /data_bags/x/unmodified.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife download of the unmodified file does nothing" do + knife("download /data_bags/x/unmodified.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the added file succeeds' do - knife('download /data_bags/x/added.json').should_succeed <<EOM + it "knife download of the added file succeeds" do + knife("download /data_bags/x/added.json").should_succeed <<EOM Created /data_bags/x/added.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download of the deleted file does nothing' do - knife('download /data_bags/x/deleted.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife download of the deleted file does nothing" do + knife("download /data_bags/x/deleted.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json A\t/data_bags/x/deleted.json EOM end - it 'knife download --purge of the deleted file deletes it' do - knife('download --purge /data_bags/x/deleted.json').should_succeed <<EOM + it "knife download --purge of the deleted file deletes it" do + knife("download --purge /data_bags/x/deleted.json").should_succeed <<EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/added.json M\t/data_bags/x/modified.json EOM end - it 'knife download of the entire data bag downloads everything' do - knife('download /data_bags/x').should_succeed <<EOM + it "knife download of the entire data bag downloads everything" do + knife("download /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM A\t/data_bags/x/deleted.json EOM end - it 'knife download --purge of the entire data bag downloads everything' do - knife('download --purge /data_bags/x').should_succeed <<EOM + it "knife download --purge of the entire data bag downloads everything" do + knife("download --purge /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - context 'when cwd is the /data_bags directory' do + context "when cwd is the /data_bags directory" do before do - cwd 'data_bags' + cwd "data_bags" end - it 'knife download fails' do - knife('download').should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ + it "knife download fails" do + knife("download").should_fail "FATAL: Must specify at least one argument. If you want to download everything in this directory, type \"knife download .\"\n", :stdout => /USAGE/ end - it 'knife download --purge . downloads everything' do - knife('download --purge .').should_succeed <<EOM + it "knife download --purge . downloads everything" do + knife("download --purge .").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - it 'knife download --purge * downloads everything' do - knife('download --purge *').should_succeed <<EOM + it "knife download --purge * downloads everything" do + knife("download --purge *").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', 'name "x"; version "1.0.0"#unmodified' - file 'cookbooks/x-1.0.0/z.rb', '' + file "cookbooks/x-1.0.0/metadata.rb", 'name "x"; version "1.0.0"#unmodified' + file "cookbooks/x-1.0.0/z.rb", "" end - when_the_chef_server 'has a modified, added and deleted file for the cookbook' do + when_the_chef_server "has a modified, added and deleted file for the cookbook" do before do - cookbook 'x', '1.0.0', { 'y.rb' => 'hi' } + cookbook "x", "1.0.0", { "y.rb" => "hi" } end - it 'knife download of a modified file succeeds' do - knife('download /cookbooks/x-1.0.0/metadata.rb').should_succeed "Updated /cookbooks/x-1.0.0/metadata.rb\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of a modified file succeeds" do + knife("download /cookbooks/x-1.0.0/metadata.rb").should_succeed "Updated /cookbooks/x-1.0.0/metadata.rb\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-1.0.0/y.rb A\t/cookbooks/x-1.0.0/z.rb EOM end - it 'knife download of a deleted file does nothing' do - knife('download /cookbooks/x-1.0.0/z.rb').should_succeed '' - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of a deleted file does nothing" do + knife("download /cookbooks/x-1.0.0/z.rb").should_succeed "" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x-1.0.0/metadata.rb D\t/cookbooks/x-1.0.0/y.rb A\t/cookbooks/x-1.0.0/z.rb EOM end - it 'knife download --purge of a deleted file succeeds' do - knife('download --purge /cookbooks/x-1.0.0/z.rb').should_succeed "Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on)\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download --purge of a deleted file succeeds" do + knife("download --purge /cookbooks/x-1.0.0/z.rb").should_succeed "Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on)\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x-1.0.0/metadata.rb D\t/cookbooks/x-1.0.0/y.rb EOM end - it 'knife download of an added file succeeds' do - knife('download /cookbooks/x-1.0.0/y.rb').should_succeed "Created /cookbooks/x-1.0.0/y.rb\n" - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife download of an added file succeeds" do + knife("download /cookbooks/x-1.0.0/y.rb").should_succeed "Created /cookbooks/x-1.0.0/y.rb\n" + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x-1.0.0/metadata.rb A\t/cookbooks/x-1.0.0/z.rb EOM end - it 'knife download of the cookbook itself succeeds' do - knife('download /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife download of the cookbook itself succeeds" do + knife("download /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0/metadata.rb Created /cookbooks/x-1.0.0/y.rb EOM - knife('diff --name-status /cookbooks').should_succeed <<EOM + knife("diff --name-status /cookbooks").should_succeed <<EOM A\t/cookbooks/x-1.0.0/z.rb EOM end - it 'knife download --purge of the cookbook itself succeeds' do - knife('download --purge /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife download --purge of the cookbook itself succeeds" do + knife("download --purge /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0/metadata.rb Created /cookbooks/x-1.0.0/y.rb Deleted extra entry /cookbooks/x-1.0.0/z.rb (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata("x", "1.0.0") - file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x-1.0.0/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the latest version' do - knife('download --purge /cookbooks').should_succeed <<EOM + it "knife download /cookbooks/x downloads the latest version" do + knife("download --purge /cookbooks").should_succeed <<EOM Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb Created /cookbooks/x-1.0.1 Created /cookbooks/x-1.0.1/metadata.rb Created /cookbooks/x-1.0.1/onlyin1.0.1.rb EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife download /cookbooks downloads the updated file' do - knife('download --purge /cookbooks').should_succeed <<EOM + it "knife download /cookbooks downloads the updated file" do + knife("download --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-0.9.9 Created /cookbooks/x-0.9.9/metadata.rb Created /cookbooks/x-0.9.9/onlyin0.9.9.rb Updated /cookbooks/x-1.0.0/onlyin1.0.0.rb EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife download /cookbooks/x downloads the latest version' do - knife('download --purge /cookbooks').should_succeed <<EOM + it "knife download /cookbooks/x downloads the latest version" do + knife("download --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-1.0.1 Created /cookbooks/x-1.0.1/metadata.rb Created /cookbooks/x-1.0.1/onlyin1.0.1.rb Deleted extra entry /cookbooks/x-1.0.0 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife download --purge /cookbooks downloads the old version and deletes the new version' do - knife('download --purge /cookbooks').should_succeed <<EOM + it "knife download --purge /cookbooks downloads the old version and deletes the new version" do + knife("download --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-0.9.9 Created /cookbooks/x-0.9.9/metadata.rb Created /cookbooks/x-0.9.9/onlyin0.9.9.rb Deleted extra entry /cookbooks/x-1.0.0 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_chef_server 'has an environment' do + when_the_chef_server "has an environment" do before do - environment 'x', {} + environment "x", {} end - when_the_repository 'has the same environment with the wrong name in the file' do + when_the_repository "has the same environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife download succeeds" do + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has the same environment with no name in the file' do + when_the_repository "has the same environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife download succeeds' do - knife('download /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife download succeeds" do + knife("download /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end end end # with versioned cookbooks - when_the_chef_server 'has a cookbook' do + when_the_chef_server "has a cookbook" do before do - cookbook 'x', '1.0.0' + cookbook "x", "1.0.0" end - when_the_repository 'is empty' do - it 'knife download /cookbooks/x signs all requests' do + when_the_repository "is empty" do + it "knife download /cookbooks/x signs all requests" do # Check that BasicClient.request() always gets called with X-OPS-USERID original_new = Chef::HTTP::BasicClient.method(:new) @@ -1077,13 +1077,13 @@ EOM new_result = original_new.call(*args) original_request = new_result.method(:request) expect(new_result).to receive(:request) { |method, url, body, headers, &response_handler| - expect(headers['X-OPS-USERID']).not_to be_nil + expect(headers["X-OPS-USERID"]).not_to be_nil original_request.call(method, url, body, headers, &response_handler) }.at_least(:once) new_result }.at_least(:once) - knife('download /cookbooks/x').should_succeed <<EOM + knife("download /cookbooks/x").should_succeed <<EOM Created /cookbooks Created /cookbooks/x Created /cookbooks/x/metadata.rb @@ -1094,19 +1094,19 @@ EOM when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do before do - user 'foo', {} - user 'bar', {} - user 'foobar', {} - organization 'foo', { 'full_name' => 'Something' } + user "foo", {} + user "bar", {} + user "foobar", {} + organization "foo", { "full_name" => "Something" } end before :each do - Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo') + Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo") end when_the_repository "has all the default stuff" do before do - knife('download /').should_succeed <<EOM + knife("download /").should_succeed <<EOM Created /acls Created /acls/clients Created /acls/clients/foo-validator.json @@ -1167,31 +1167,31 @@ Created /roles EOM end - context 'and the server has one of each thing' do + context "and the server has one of each thing" do before do # acl_for %w(organizations foo groups blah) - client 'x', {} - cookbook 'x', '1.0.0' - container 'x', {} - data_bag 'x', { 'y' => {} } - environment 'x', {} - group 'x', {} - org_invite 'foo' - org_member 'bar' - node 'x', {} - policy 'x', '1.0.0', {} - policy 'blah', '1.0.0', {} - policy_group 'x', { - 'policies' => { - 'x' => { 'revision_id' => '1.0.0' }, - 'blah' => { 'revision_id' => '1.0.0' }, + client "x", {} + cookbook "x", "1.0.0" + container "x", {} + data_bag "x", { "y" => {} } + environment "x", {} + group "x", {} + org_invite "foo" + org_member "bar" + node "x", {} + policy "x", "1.0.0", {} + policy "blah", "1.0.0", {} + policy_group "x", { + "policies" => { + "x" => { "revision_id" => "1.0.0" }, + "blah" => { "revision_id" => "1.0.0" }, } } - role 'x', {} + role "x", {} end before do - knife('download /acls /groups/clients.json /groups/users.json').should_succeed <<-EOM + knife("download /acls /groups/clients.json /groups/users.json").should_succeed <<-EOM Created /acls/clients/x.json Created /acls/containers/x.json Created /acls/cookbooks/x.json @@ -1205,8 +1205,8 @@ Updated /groups/users.json EOM end - it 'knife download / downloads everything' do - knife('download /').should_succeed <<EOM + it "knife download / downloads everything" do + knife("download /").should_succeed <<EOM Created /clients/x.json Created /containers/x.json Created /cookbooks/x @@ -1223,58 +1223,58 @@ Created /policies/x-1.0.0.json Created /policy_groups/x.json Created /roles/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end context "and the repository has an identical copy of each thing" do before do # TODO We have to upload acls for an existing group due to a lack of # dependency detection during upload. Fix that! - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'containers/x.json', {} - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/x.json', {} - file 'groups/x.json', {} - file 'invitations.json', [ 'foo' ] - file 'members.json', [ 'bar' ] - file 'nodes/x.json', {} - file 'org.json', { 'full_name' => 'Something' } - file 'policies/x-1.0.0.json', { } - file 'policies/blah-1.0.0.json', { } - file 'policy_groups/x.json', { 'policies' => { 'x' => { 'revision_id' => '1.0.0' }, 'blah' => { 'revision_id' => '1.0.0' } } } - file 'roles/x.json', {} + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "containers/x.json", {} + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/x.json", {} + file "groups/x.json", {} + file "invitations.json", [ "foo" ] + file "members.json", [ "bar" ] + file "nodes/x.json", {} + file "org.json", { "full_name" => "Something" } + file "policies/x-1.0.0.json", { } + file "policies/blah-1.0.0.json", { } + file "policy_groups/x.json", { "policies" => { "x" => { "revision_id" => "1.0.0" }, "blah" => { "revision_id" => "1.0.0" } } } + file "roles/x.json", {} end - it 'knife download makes no changes' do - knife('download /').should_succeed '' + it "knife download makes no changes" do + knife("download /").should_succeed "" end end context "and the repository has a slightly different copy of each thing" do before do # acl_for %w(organizations foo groups blah) - file 'clients/x.json', { 'validator' => true } - file 'containers/x.json', {} - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.1") - file 'data_bags/x/y.json', { 'a' => 'b' } - file 'environments/x.json', { 'description' => 'foo' } - file 'groups/x.json', { 'description' => 'foo' } - file 'groups/x.json', { 'groups' => [ 'admin' ] } - file 'nodes/x.json', { 'run_list' => [ 'blah' ] } - file 'org.json', { 'full_name' => 'Something Else ' } - file 'policies/x-1.0.0.json', { 'run_list' => [ 'blah' ] } - file 'policy_groups/x.json', { - 'policies' => { - 'x' => { 'revision_id' => '1.0.1' }, - 'y' => { 'revision_id' => '1.0.0' }, + file "clients/x.json", { "validator" => true } + file "containers/x.json", {} + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.1") + file "data_bags/x/y.json", { "a" => "b" } + file "environments/x.json", { "description" => "foo" } + file "groups/x.json", { "description" => "foo" } + file "groups/x.json", { "groups" => [ "admin" ] } + file "nodes/x.json", { "run_list" => [ "blah" ] } + file "org.json", { "full_name" => "Something Else " } + file "policies/x-1.0.0.json", { "run_list" => [ "blah" ] } + file "policy_groups/x.json", { + "policies" => { + "x" => { "revision_id" => "1.0.1" }, + "y" => { "revision_id" => "1.0.0" }, } } - file 'roles/x.json', { 'run_list' => [ 'blah' ] } + file "roles/x.json", { "run_list" => [ "blah" ] } end - it 'knife download updates everything' do - knife('download /').should_succeed <<EOM + it "knife download updates everything" do + knife("download /").should_succeed <<EOM Updated /clients/x.json Updated /cookbooks/x/metadata.rb Updated /data_bags/x/y.json @@ -1289,7 +1289,7 @@ Updated /policies/x-1.0.0.json Updated /policy_groups/x.json Updated /roles/x.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end diff --git a/spec/integration/knife/list_spec.rb b/spec/integration/knife/list_spec.rb index eb2ed279e5..32f5bb43f8 100644 --- a/spec/integration/knife/list_spec.rb +++ b/spec/integration/knife/list_spec.rb @@ -15,11 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/list' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/list" -describe 'knife list', :workstation do +describe "knife list", :workstation do include IntegrationSupport include KnifeSupport @@ -27,7 +27,7 @@ describe 'knife list', :workstation do when_the_chef_server "is empty" do it "knife list / returns all top level directories" do - knife('list /').should_succeed <<-EOM + knife("list /").should_succeed <<-EOM /clients /cookbooks /data_bags @@ -39,7 +39,7 @@ EOM end it "knife list -R / returns everything" do - knife('list -R /').should_succeed <<-EOM + knife("list -R /").should_succeed <<-EOM /: clients cookbooks @@ -72,27 +72,27 @@ EOM when_the_chef_server "has plenty of stuff in it" do before do - client 'client1', {} - client 'client2', {} - cookbook 'cookbook1', '1.0.0' - cookbook 'cookbook2', '1.0.1', { 'recipes' => { 'default.rb' => '' } } - data_bag 'bag1', { 'item1' => {}, 'item2' => {} } - data_bag 'bag2', { 'item1' => {}, 'item2' => {} } - environment 'environment1', {} - environment 'environment2', {} - node 'node1', {} - node 'node2', {} - policy 'policy1', '1.2.3', {} - policy 'policy2', '1.2.3', {} - policy 'policy2', '1.3.5', {} - role 'role1', {} - role 'role2', {} - user 'user1', {} - user 'user2', {} + client "client1", {} + client "client2", {} + cookbook "cookbook1", "1.0.0" + cookbook "cookbook2", "1.0.1", { "recipes" => { "default.rb" => "" } } + data_bag "bag1", { "item1" => {}, "item2" => {} } + data_bag "bag2", { "item1" => {}, "item2" => {} } + environment "environment1", {} + environment "environment2", {} + node "node1", {} + node "node2", {} + policy "policy1", "1.2.3", {} + policy "policy2", "1.2.3", {} + policy "policy2", "1.3.5", {} + role "role1", {} + role "role2", {} + user "user1", {} + user "user2", {} end it "knife list / returns all top level directories" do - knife('list /').should_succeed <<-EOM + knife("list /").should_succeed <<-EOM /clients /cookbooks /data_bags @@ -104,7 +104,7 @@ EOM end it "knife list -R / returns everything" do - knife('list -R /').should_succeed <<-EOM + knife("list -R /").should_succeed <<-EOM /: clients cookbooks @@ -167,7 +167,7 @@ EOM end it "knife list -R --flat / returns everything" do - knife('list -R --flat /').should_succeed <<-EOM + knife("list -R --flat /").should_succeed <<-EOM /clients /clients/chef-validator.json /clients/chef-webui.json @@ -205,7 +205,7 @@ EOM end it "knife list -Rfp / returns everything" do - knife('list -Rfp /').should_succeed <<-EOM + knife("list -Rfp /").should_succeed <<-EOM /clients/ /clients/chef-validator.json /clients/chef-webui.json @@ -243,18 +243,18 @@ EOM end it "knife list /cookbooks returns the list of cookbooks" do - knife('list /cookbooks').should_succeed <<-EOM + knife("list /cookbooks").should_succeed <<-EOM /cookbooks/cookbook1 /cookbooks/cookbook2 EOM end it "knife list /cookbooks/*2/*/*.rb returns the one file" do - knife('list /cookbooks/*2/*/*.rb').should_succeed "/cookbooks/cookbook2/recipes/default.rb\n" + knife("list /cookbooks/*2/*/*.rb").should_succeed "/cookbooks/cookbook2/recipes/default.rb\n" end it "knife list /**.rb returns all ruby files" do - knife('list /**.rb').should_succeed <<-EOM + knife("list /**.rb").should_succeed <<-EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/metadata.rb /cookbooks/cookbook2/recipes/default.rb @@ -262,7 +262,7 @@ EOM end it "knife list /cookbooks/**.rb returns all ruby files" do - knife('list /cookbooks/**.rb').should_succeed <<-EOM + knife("list /cookbooks/**.rb").should_succeed <<-EOM /cookbooks/cookbook1/metadata.rb /cookbooks/cookbook2/metadata.rb /cookbooks/cookbook2/recipes/default.rb @@ -270,7 +270,7 @@ EOM end it "knife list /**.json returns all json files" do - knife('list /**.json').should_succeed <<-EOM + knife("list /**.json").should_succeed <<-EOM /clients/chef-validator.json /clients/chef-webui.json /clients/client1.json @@ -293,7 +293,7 @@ EOM end it "knife list /data**.json returns all data bag json files" do - knife('list /data**.json').should_succeed <<-EOM + knife("list /data**.json").should_succeed <<-EOM /data_bags/bag1/item1.json /data_bags/bag1/item2.json /data_bags/bag2/item1.json @@ -302,30 +302,30 @@ EOM end it "knife list /environments/missing_file.json reports missing file" do - knife('list /environments/missing_file.json').should_fail "ERROR: /environments/missing_file.json: No such file or directory\n" + knife("list /environments/missing_file.json").should_fail "ERROR: /environments/missing_file.json: No such file or directory\n" end context "missing file/directory exact match tests" do it "knife list /blarghle reports missing directory" do - knife('list /blarghle').should_fail "ERROR: /blarghle: No such file or directory\n" + knife("list /blarghle").should_fail "ERROR: /blarghle: No such file or directory\n" end it "knife list /roles/blarghle reports missing directory" do - knife('list /roles/blarghle').should_fail "ERROR: /roles/blarghle: No such file or directory\n" + knife("list /roles/blarghle").should_fail "ERROR: /roles/blarghle: No such file or directory\n" end it "knife list /roles/blarghle/blorghle reports missing directory" do - knife('list /roles/blarghle/blorghle').should_fail "ERROR: /roles/blarghle/blorghle: No such file or directory\n" + knife("list /roles/blarghle/blorghle").should_fail "ERROR: /roles/blarghle/blorghle: No such file or directory\n" end end - context 'symlink tests' do - when_the_repository 'is empty' do - context 'when cwd is at the top of the repository' do - before { cwd '.' } + context "symlink tests" do + when_the_repository "is empty" do + context "when cwd is at the top of the repository" do + before { cwd "." } it "knife list -Rfp returns everything" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM clients/ clients/chef-validator.json clients/chef-webui.json @@ -364,13 +364,13 @@ EOM end end - when_the_repository 'has a cookbooks directory' do - before { directory 'cookbooks' } - context 'when cwd is in cookbooks/' do - before { cwd 'cookbooks' } + when_the_repository "has a cookbooks directory" do + before { directory "cookbooks" } + context "when cwd is in cookbooks/" do + before { cwd "cookbooks" } it "knife list -Rfp / returns everything" do - knife('list -Rfp /').should_succeed <<-EOM + knife("list -Rfp /").should_succeed <<-EOM /clients/ /clients/chef-validator.json /clients/chef-webui.json @@ -408,7 +408,7 @@ EOM end it "knife list -Rfp .. returns everything" do - knife('list -Rfp ..').should_succeed <<-EOM + knife("list -Rfp ..").should_succeed <<-EOM /clients/ /clients/chef-validator.json /clients/chef-webui.json @@ -446,7 +446,7 @@ EOM end it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -458,14 +458,14 @@ EOM end end - when_the_repository 'has a cookbooks/cookbook2 directory' do - before { directory 'cookbooks/cookbook2' } + when_the_repository "has a cookbooks/cookbook2 directory" do + before { directory "cookbooks/cookbook2" } - context 'when cwd is in cookbooks/cookbook2' do - before { cwd 'cookbooks/cookbook2' } + context "when cwd is in cookbooks/cookbook2" do + before { cwd "cookbooks/cookbook2" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM metadata.rb recipes/ recipes/default.rb @@ -474,17 +474,17 @@ EOM end end - when_the_repository 'has a cookbooks directory and a symlinked cookbooks directory', :skip => (Chef::Platform.windows?) do + when_the_repository "has a cookbooks directory and a symlinked cookbooks directory", :skip => (Chef::Platform.windows?) do before do - directory 'cookbooks' - symlink 'symlinked', 'cookbooks' + directory "cookbooks" + symlink "symlinked", "cookbooks" end - context 'when cwd is in cookbooks/' do - before { cwd 'cookbooks' } + context "when cwd is in cookbooks/" do + before { cwd "cookbooks" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -495,11 +495,11 @@ EOM end end - context 'when cwd is in symlinked/' do - before { cwd 'symlinked' } + context "when cwd is in symlinked/" do + before { cwd "symlinked" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -511,17 +511,17 @@ EOM end end - when_the_repository 'has a real_cookbooks directory and a cookbooks symlink to it', :skip => (Chef::Platform.windows?) do + when_the_repository "has a real_cookbooks directory and a cookbooks symlink to it", :skip => (Chef::Platform.windows?) do before do - directory 'real_cookbooks' - symlink 'cookbooks', 'real_cookbooks' + directory "real_cookbooks" + symlink "cookbooks", "real_cookbooks" end - context 'when cwd is in real_cookbooks/' do - before { cwd 'real_cookbooks' } + context "when cwd is in real_cookbooks/" do + before { cwd "real_cookbooks" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -532,11 +532,11 @@ EOM end end - context 'when cwd is in cookbooks/' do - before { cwd 'cookbooks' } + context "when cwd is in cookbooks/" do + before { cwd "cookbooks" } it "knife list -Rfp returns cookbooks" do - knife('list -Rfp').should_succeed <<-EOM + knife("list -Rfp").should_succeed <<-EOM cookbook1/ cookbook1/metadata.rb cookbook2/ @@ -553,51 +553,51 @@ EOM context "--local" do when_the_repository "is empty" do it "knife list --local / returns nothing" do - knife('list --local /').should_succeed "" + knife("list --local /").should_succeed "" end it "knife list /roles returns nothing" do - knife('list --local /roles').should_fail "ERROR: /roles: No such file or directory\n" + knife("list --local /roles").should_fail "ERROR: /roles: No such file or directory\n" end end when_the_repository "has a bunch of stuff" do before do - file 'clients/client1.json', {} - file 'clients/client2.json', {} + file "clients/client1.json", {} + file "clients/client2.json", {} - directory 'cookbooks/cookbook1' do - file 'metadata.rb', cb_metadata("cookbook1", "1.0.0") + directory "cookbooks/cookbook1" do + file "metadata.rb", cb_metadata("cookbook1", "1.0.0") end - directory 'cookbooks/cookbook2' do - file 'metadata.rb', cb_metadata("cookbook2", "2.0.0") - file 'recipes/default.rb', '' + directory "cookbooks/cookbook2" do + file "metadata.rb", cb_metadata("cookbook2", "2.0.0") + file "recipes/default.rb", "" end - directory 'data_bags' do - directory 'bag1' do - file 'item1.json', {} - file 'item2.json', {} + directory "data_bags" do + directory "bag1" do + file "item1.json", {} + file "item2.json", {} end - directory 'bag2' do - file 'item1.json', {} - file 'item2.json', {} + directory "bag2" do + file "item1.json", {} + file "item2.json", {} end end - file 'environments/environment1.json', {} - file 'environments/environment2.json', {} - file 'nodes/node1.json', {} - file 'nodes/node2.json', {} + file "environments/environment1.json", {} + file "environments/environment2.json", {} + file "nodes/node1.json", {} + file "nodes/node2.json", {} - file 'roles/role1.json', {} - file 'roles/role2.json', {} - file 'users/user1.json', {} - file 'users/user2.json', {} + file "roles/role1.json", {} + file "roles/role2.json", {} + file "users/user1.json", {} + file "users/user2.json", {} end it "knife list -Rfp / returns everything" do - knife('list -Rp --local --flat /').should_succeed <<-EOM + knife("list -Rp --local --flat /").should_succeed <<-EOM /clients/ /clients/client1.json /clients/client2.json @@ -632,15 +632,15 @@ EOM context "missing file/directory tests" do it "knife list --local /blarghle reports missing directory" do - knife('list --local /blarghle').should_fail "ERROR: /blarghle: No such file or directory\n" + knife("list --local /blarghle").should_fail "ERROR: /blarghle: No such file or directory\n" end it "knife list /roles/blarghle reports missing directory" do - knife('list --local /roles/blarghle').should_fail "ERROR: /roles/blarghle: No such file or directory\n" + knife("list --local /roles/blarghle").should_fail "ERROR: /roles/blarghle: No such file or directory\n" end it "knife list /roles/blarghle/blorghle reports missing directory" do - knife('list --local /roles/blarghle/blorghle').should_fail "ERROR: /roles/blarghle/blorghle: No such file or directory\n" + knife("list --local /roles/blarghle/blorghle").should_fail "ERROR: /roles/blarghle/blorghle: No such file or directory\n" end end end @@ -648,16 +648,16 @@ EOM when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do before do - organization 'foo' + organization "foo" end before :each do - Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo') + Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo") end - context 'and is empty' do + context "and is empty" do it "knife list / returns all top level directories" do - knife('list /').should_succeed <<-EOM + knife("list /").should_succeed <<-EOM /acls /clients /containers @@ -676,7 +676,7 @@ EOM end it "knife list -R / returns everything" do - knife('list -R /').should_succeed <<-EOM + knife("list -R /").should_succeed <<-EOM /: acls clients @@ -777,8 +777,8 @@ EOM end end - it 'knife list -R / returns everything' do - knife('list -R /').should_succeed <<-EOM + it "knife list -R / returns everything" do + knife("list -R /").should_succeed <<-EOM /: acls clients @@ -880,35 +880,35 @@ EOM context "has plenty of stuff in it" do before do - client 'client1', {} - client 'client2', {} - container 'container1', {} - container 'container2', {} - cookbook 'cookbook1', '1.0.0' - cookbook 'cookbook2', '1.0.1', { 'recipes' => { 'default.rb' => '' } } - data_bag 'bag1', { 'item1' => {}, 'item2' => {} } - data_bag 'bag2', { 'item1' => {}, 'item2' => {} } - environment 'environment1', {} - environment 'environment2', {} - group 'group1', {} - group 'group2', {} - node 'node1', {} - node 'node2', {} - org_invite 'user1' - org_member 'user2' - policy 'policy1', '1.2.3', {} - policy 'policy2', '1.2.3', {} - policy 'policy2', '1.3.5', {} - policy_group 'policy_group1', { 'policies' => { 'policy1' => { 'revision_id' => '1.2.3' } } } - policy_group 'policy_group2', { 'policies' => { 'policy2' => { 'revision_id' => '1.3.5' } } } - role 'role1', {} - role 'role2', {} - user 'user1', {} - user 'user2', {} + client "client1", {} + client "client2", {} + container "container1", {} + container "container2", {} + cookbook "cookbook1", "1.0.0" + cookbook "cookbook2", "1.0.1", { "recipes" => { "default.rb" => "" } } + data_bag "bag1", { "item1" => {}, "item2" => {} } + data_bag "bag2", { "item1" => {}, "item2" => {} } + environment "environment1", {} + environment "environment2", {} + group "group1", {} + group "group2", {} + node "node1", {} + node "node2", {} + org_invite "user1" + org_member "user2" + policy "policy1", "1.2.3", {} + policy "policy2", "1.2.3", {} + policy "policy2", "1.3.5", {} + policy_group "policy_group1", { "policies" => { "policy1" => { "revision_id" => "1.2.3" } } } + policy_group "policy_group2", { "policies" => { "policy2" => { "revision_id" => "1.3.5" } } } + role "role1", {} + role "role2", {} + user "user1", {} + user "user2", {} end it "knife list -Rfp / returns everything" do - knife('list -Rfp /').should_succeed <<-EOM + knife("list -Rfp /").should_succeed <<-EOM /acls/ /acls/clients/ /acls/clients/client1.json diff --git a/spec/integration/knife/raw_spec.rb b/spec/integration/knife/raw_spec.rb index 75fc8fa55e..92b972b87b 100644 --- a/spec/integration/knife/raw_spec.rb +++ b/spec/integration/knife/raw_spec.rb @@ -15,12 +15,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/raw' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/raw" +require "chef/knife/show" -describe 'knife raw', :workstation do +describe "knife raw", :workstation do include IntegrationSupport include KnifeSupport include AppServerSupport @@ -29,17 +29,17 @@ describe 'knife raw', :workstation do when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - it 'knife raw /nodes/x returns the node', :skip => (RUBY_VERSION < "1.9") do - knife('raw /nodes/x').should_succeed <<EOM + it "knife raw /nodes/x returns the node", :skip => (RUBY_VERSION < "1.9") do + knife("raw /nodes/x").should_succeed <<EOM { "name": "x", "json_class": "Chef::Node", @@ -64,12 +64,12 @@ describe 'knife raw', :workstation do EOM end - it 'knife raw /blarghle returns 404' do - knife('raw /blarghle').should_fail(/ERROR: Server responded with error 404 "Not Found\s*"/) + it "knife raw /blarghle returns 404" do + knife("raw /blarghle").should_fail(/ERROR: Server responded with error 404 "Not Found\s*"/) end - it 'knife raw -m DELETE /roles/x succeeds', :skip => (RUBY_VERSION < "1.9") do - knife('raw -m DELETE /roles/x').should_succeed <<EOM + it "knife raw -m DELETE /roles/x succeeds", :skip => (RUBY_VERSION < "1.9") do + knife("raw -m DELETE /roles/x").should_succeed <<EOM { "name": "x", "description": "", @@ -89,11 +89,11 @@ EOM } } EOM - knife('show /roles/x.json').should_fail "ERROR: /roles/x.json: No such file or directory\n" + knife("show /roles/x.json").should_fail "ERROR: /roles/x.json: No such file or directory\n" end - it 'knife raw -m PUT -i blah.txt /roles/x succeeds', :skip => (RUBY_VERSION < "1.9") do - Tempfile.open('raw_put_input') do |file| + it "knife raw -m PUT -i blah.txt /roles/x succeeds", :skip => (RUBY_VERSION < "1.9") do + Tempfile.open("raw_put_input") do |file| file.write <<EOM { "name": "x", @@ -136,7 +136,7 @@ EOM } } EOM - knife('show /roles/x.json').should_succeed <<EOM + knife("show /roles/x.json").should_succeed <<EOM /roles/x.json: { "name": "x", @@ -146,8 +146,8 @@ EOM end end - it 'knife raw -m POST -i blah.txt /roles succeeds', :skip => (RUBY_VERSION < "1.9") do - Tempfile.open('raw_put_input') do |file| + it "knife raw -m POST -i blah.txt /roles succeeds", :skip => (RUBY_VERSION < "1.9") do + Tempfile.open("raw_put_input") do |file| file.write <<EOM { "name": "y", @@ -172,7 +172,7 @@ EOM "uri": "#{Chef::Config.chef_server_url}/roles/y" } EOM - knife('show /roles/y.json').should_succeed <<EOM + knife("show /roles/y.json").should_succeed <<EOM /roles/y.json: { "name": "y", @@ -182,11 +182,11 @@ EOM end end - context 'When a server returns raw json' do + context "When a server returns raw json" do before :each do Chef::Config.chef_server_url = "http://localhost:9018" app = lambda do |env| - [200, {'Content-Type' => 'application/json' }, ['{ "x": "y", "a": "b" }'] ] + [200, {"Content-Type" => "application/json" }, ['{ "x": "y", "a": "b" }'] ] end @raw_server, @raw_server_thread = start_app_server(app, 9018) end @@ -196,8 +196,8 @@ EOM @raw_server_thread.kill if @raw_server_thread end - it 'knife raw /blah returns the prettified json', :skip => (RUBY_VERSION < "1.9") do - knife('raw /blah').should_succeed <<EOM + it "knife raw /blah returns the prettified json", :skip => (RUBY_VERSION < "1.9") do + knife("raw /blah").should_succeed <<EOM { "x": "y", "a": "b" @@ -205,18 +205,18 @@ EOM EOM end - it 'knife raw --no-pretty /blah returns the raw json' do - knife('raw --no-pretty /blah').should_succeed <<EOM + it "knife raw --no-pretty /blah returns the raw json" do + knife("raw --no-pretty /blah").should_succeed <<EOM { "x": "y", "a": "b" } EOM end end - context 'When a server returns text' do + context "When a server returns text" do before :each do Chef::Config.chef_server_url = "http://localhost:9018" app = lambda do |env| - [200, {'Content-Type' => 'text' }, ['{ "x": "y", "a": "b" }'] ] + [200, {"Content-Type" => "text" }, ['{ "x": "y", "a": "b" }'] ] end @raw_server, @raw_server_thread = start_app_server(app, 9018) end @@ -226,14 +226,14 @@ EOM @raw_server_thread.kill if @raw_server_thread end - it 'knife raw /blah returns the raw text' do - knife('raw /blah').should_succeed(<<EOM) + it "knife raw /blah returns the raw text" do + knife("raw /blah").should_succeed(<<EOM) { "x": "y", "a": "b" } EOM end - it 'knife raw --no-pretty /blah returns the raw text' do - knife('raw --no-pretty /blah').should_succeed(<<EOM) + it "knife raw --no-pretty /blah returns the raw text" do + knife("raw --no-pretty /blah").should_succeed(<<EOM) { "x": "y", "a": "b" } EOM end diff --git a/spec/integration/knife/redirection_spec.rb b/spec/integration/knife/redirection_spec.rb index 77bda99453..ee12e85314 100644 --- a/spec/integration/knife/redirection_spec.rb +++ b/spec/integration/knife/redirection_spec.rb @@ -15,26 +15,26 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/list' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/list" -describe 'redirection', :workstation do +describe "redirection", :workstation do include IntegrationSupport include KnifeSupport include AppServerSupport include_context "default config options" - when_the_chef_server 'has a role' do - before { role 'x', {} } + when_the_chef_server "has a role" do + before { role "x", {} } - context 'and another server redirects to it with 302' do + context "and another server redirects to it with 302" do before :each do real_chef_server_url = Chef::Config.chef_server_url Chef::Config.chef_server_url = "http://localhost:9018" app = lambda do |env| - [302, {'Content-Type' => 'text','Location' => "#{real_chef_server_url}#{env['PATH_INFO']}" }, ['302 found'] ] + [302, {"Content-Type" => "text","Location" => "#{real_chef_server_url}#{env['PATH_INFO']}" }, ["302 found"] ] end @redirector_server, @redirector_server_thread = start_app_server(app, 9018) end @@ -44,8 +44,8 @@ describe 'redirection', :workstation do @redirector_thread.kill if @redirector_thread end - it 'knife list /roles returns the role' do - knife('list /roles').should_succeed "/roles/x.json\n" + it "knife list /roles returns the role" do + knife("list /roles").should_succeed "/roles/x.json\n" end end end diff --git a/spec/integration/knife/serve_spec.rb b/spec/integration/knife/serve_spec.rb index 7bf7d29b40..74b47c0fe3 100644 --- a/spec/integration/knife/serve_spec.rb +++ b/spec/integration/knife/serve_spec.rb @@ -15,34 +15,34 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/serve' -require 'chef/server_api' +require "support/shared/integration/integration_helper" +require "chef/knife/serve" +require "chef/server_api" -describe 'knife serve', :workstation do +describe "knife serve", :workstation do include IntegrationSupport include KnifeSupport include AppServerSupport - when_the_repository 'also has one of each thing' do - before { file 'nodes/x.json', { 'foo' => 'bar' } } + when_the_repository "also has one of each thing" do + before { file "nodes/x.json", { "foo" => "bar" } } - it 'knife serve serves up /nodes/x' do + it "knife serve serves up /nodes/x" do exception = nil t = Thread.new do begin - knife('serve --chef-zero-port=8890') + knife("serve --chef-zero-port=8890") rescue exception = $! end end begin Chef::Config.log_level = :debug - Chef::Config.chef_server_url = 'http://localhost:8890' + Chef::Config.chef_server_url = "http://localhost:8890" Chef::Config.node_name = nil Chef::Config.client_key = nil api = Chef::ServerAPI.new - expect(api.get('nodes/x')['name']).to eq('x') + expect(api.get("nodes/x")["name"]).to eq("x") rescue if exception raise exception diff --git a/spec/integration/knife/show_spec.rb b/spec/integration/knife/show_spec.rb index fad5126f66..06183243ee 100644 --- a/spec/integration/knife/show_spec.rb +++ b/spec/integration/knife/show_spec.rb @@ -15,11 +15,11 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'support/shared/context/config' -require 'chef/knife/show' +require "support/shared/integration/integration_helper" +require "support/shared/context/config" +require "chef/knife/show" -describe 'knife show', :workstation do +describe "knife show", :workstation do include IntegrationSupport include KnifeSupport @@ -27,81 +27,81 @@ describe 'knife show', :workstation do when_the_chef_server "has one of each thing" do before do - client 'x', '{}' - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => '{}' } - environment 'x', '{}' - node 'x', '{}' - role 'x', '{}' - user 'x', '{}' + client "x", "{}" + cookbook "x", "1.0.0" + data_bag "x", { "y" => "{}" } + environment "x", "{}" + node "x", "{}" + role "x", "{}" + user "x", "{}" end - when_the_repository 'also has one of each thing' do + when_the_repository "also has one of each thing" do before do - file 'clients/x.json', { 'foo' => 'bar' } - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') - file 'data_bags/x/y.json', { 'foo' => 'bar' } - file 'environments/_default.json', { 'foo' => 'bar' } - file 'environments/x.json', { 'foo' => 'bar' } - file 'nodes/x.json', { 'foo' => 'bar' } - file 'roles/x.json', { 'foo' => 'bar' } - file 'users/x.json', { 'foo' => 'bar' } + file "clients/x.json", { "foo" => "bar" } + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", { "foo" => "bar" } + file "environments/_default.json", { "foo" => "bar" } + file "environments/x.json", { "foo" => "bar" } + file "nodes/x.json", { "foo" => "bar" } + file "roles/x.json", { "foo" => "bar" } + file "users/x.json", { "foo" => "bar" } end - it 'knife show /cookbooks/x/metadata.rb shows the remote version' do - knife('show /cookbooks/x/metadata.rb').should_succeed <<EOM + it "knife show /cookbooks/x/metadata.rb shows the remote version" do + knife("show /cookbooks/x/metadata.rb").should_succeed <<EOM /cookbooks/x/metadata.rb: name "x"; version "1.0.0" EOM end - it 'knife show --local /cookbooks/x/metadata.rb shows the local version' do - knife('show --local /cookbooks/x/metadata.rb').should_succeed <<EOM + it "knife show --local /cookbooks/x/metadata.rb shows the local version" do + knife("show --local /cookbooks/x/metadata.rb").should_succeed <<EOM /cookbooks/x/metadata.rb: name "x"; version "1.0.0" EOM end - it 'knife show /data_bags/x/y.json shows the remote version' do - knife('show /data_bags/x/y.json').should_succeed <<EOM + it "knife show /data_bags/x/y.json shows the remote version" do + knife("show /data_bags/x/y.json").should_succeed <<EOM /data_bags/x/y.json: { "id": "y" } EOM end - it 'knife show --local /data_bags/x/y.json shows the local version' do - knife('show --local /data_bags/x/y.json').should_succeed <<EOM + it "knife show --local /data_bags/x/y.json shows the local version" do + knife("show --local /data_bags/x/y.json").should_succeed <<EOM /data_bags/x/y.json: { "foo": "bar" } EOM end - it 'knife show /environments/x.json shows the remote version', :skip => (RUBY_VERSION < "1.9") do - knife('show /environments/x.json').should_succeed <<EOM + it "knife show /environments/x.json shows the remote version", :skip => (RUBY_VERSION < "1.9") do + knife("show /environments/x.json").should_succeed <<EOM /environments/x.json: { "name": "x" } EOM end - it 'knife show --local /environments/x.json shows the local version' do - knife('show --local /environments/x.json').should_succeed <<EOM + it "knife show --local /environments/x.json shows the local version" do + knife("show --local /environments/x.json").should_succeed <<EOM /environments/x.json: { "foo": "bar" } EOM end - it 'knife show /roles/x.json shows the remote version', :skip => (RUBY_VERSION < "1.9") do - knife('show /roles/x.json').should_succeed <<EOM + it "knife show /roles/x.json shows the remote version", :skip => (RUBY_VERSION < "1.9") do + knife("show /roles/x.json").should_succeed <<EOM /roles/x.json: { "name": "x" } EOM end - it 'knife show --local /roles/x.json shows the local version' do - knife('show --local /roles/x.json').should_succeed <<EOM + it "knife show --local /roles/x.json shows the local version" do + knife("show --local /roles/x.json").should_succeed <<EOM /roles/x.json: { "foo": "bar" @@ -109,34 +109,34 @@ EOM EOM end # show directory - it 'knife show /data_bags/x fails' do - knife('show /data_bags/x').should_fail "ERROR: /data_bags/x: is a directory\n" + it "knife show /data_bags/x fails" do + knife("show /data_bags/x").should_fail "ERROR: /data_bags/x: is a directory\n" end - it 'knife show --local /data_bags/x fails' do - knife('show --local /data_bags/x').should_fail "ERROR: /data_bags/x: is a directory\n" + it "knife show --local /data_bags/x fails" do + knife("show --local /data_bags/x").should_fail "ERROR: /data_bags/x: is a directory\n" end # show nonexistent file - it 'knife show /environments/nonexistent.json fails' do - knife('show /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + it "knife show /environments/nonexistent.json fails" do + knife("show /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" end - it 'knife show --local /environments/nonexistent.json fails' do - knife('show --local /environments/nonexistent.json').should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" + it "knife show --local /environments/nonexistent.json fails" do + knife("show --local /environments/nonexistent.json").should_fail "ERROR: /environments/nonexistent.json: No such file or directory\n" end end end - when_the_chef_server 'has a hash with multiple keys' do + when_the_chef_server "has a hash with multiple keys" do before do - environment 'x', { - 'default_attributes' => { 'foo' => 'bar' }, - 'cookbook_versions' => { 'blah' => '= 1.0.0'}, - 'override_attributes' => { 'x' => 'y' }, - 'description' => 'woo', - 'name' => 'x', + environment "x", { + "default_attributes" => { "foo" => "bar" }, + "cookbook_versions" => { "blah" => "= 1.0.0"}, + "override_attributes" => { "x" => "y" }, + "description" => "woo", + "name" => "x", } end - it 'knife show shows the attributes in a predetermined order', :skip => (RUBY_VERSION < "1.9") do - knife('show /environments/x.json').should_succeed <<EOM + it "knife show shows the attributes in a predetermined order", :skip => (RUBY_VERSION < "1.9") do + knife("show /environments/x.json").should_succeed <<EOM /environments/x.json: { "name": "x", @@ -155,10 +155,10 @@ EOM end end - when_the_repository 'has an environment with bad JSON' do - before { file 'environments/x.json', '{' } - it 'knife show succeeds' do - knife('show --local /environments/x.json').should_succeed <<EOM + when_the_repository "has an environment with bad JSON" do + before { file "environments/x.json", "{" } + it "knife show succeeds" do + knife("show --local /environments/x.json").should_succeed <<EOM /environments/x.json: { EOM diff --git a/spec/integration/knife/upload_spec.rb b/spec/integration/knife/upload_spec.rb index 6b7679de44..79dae99acf 100644 --- a/spec/integration/knife/upload_spec.rb +++ b/spec/integration/knife/upload_spec.rb @@ -15,44 +15,44 @@ # See the License for the specific language governing permissions and # limitations under the License. -require 'support/shared/integration/integration_helper' -require 'chef/knife/upload' -require 'chef/knife/diff' -require 'chef/knife/raw' -require 'chef/json_compat' +require "support/shared/integration/integration_helper" +require "chef/knife/upload" +require "chef/knife/diff" +require "chef/knife/raw" +require "chef/json_compat" -describe 'knife upload', :workstation do +describe "knife upload", :workstation do include IntegrationSupport include KnifeSupport - context 'without versioned cookbooks' do + context "without versioned cookbooks" do when_the_chef_server "has one of each thing" do before do - client 'x', {} - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => {} } - environment 'x', {} - node 'x', {} - role 'x', {} - user 'x', {} + client "x", {} + cookbook "x", "1.0.0" + data_bag "x", { "y" => {} } + environment "x", {} + node "x", {} + role "x", {} + user "x", {} end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' - end - - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" + end + + it "knife upload does nothing" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM D\t/clients/chef-validator.json D\t/clients/chef-webui.json D\t/clients/x.json @@ -67,8 +67,8 @@ D\t/users/x.json EOM end - it 'knife upload --purge deletes everything' do - knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") + it "knife upload --purge deletes everything" do + knife("upload --purge /").should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") Deleted extra entry /clients/chef-validator.json (purge is on) Deleted extra entry /clients/chef-webui.json (purge is on) Deleted extra entry /clients/x.json (purge is on) @@ -80,56 +80,56 @@ Deleted extra entry /roles/x.json (purge is on) Deleted extra entry /users/admin.json (purge is on) Deleted extra entry /users/x.json (purge is on) EOM - knife('diff --name-status /').should_succeed <<EOM + knife("diff --name-status /").should_succeed <<EOM D\t/environments/_default.json EOM end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { "description" => "The default Chef environment" } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife upload makes no changes' do - knife('upload /cookbooks/x').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload makes no changes" do + knife("upload /cookbooks/x").should_succeed "" + knife("diff --name-status /").should_succeed "" end - it 'knife upload --purge makes no changes' do - knife('upload --purge /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload --purge makes no changes" do + knife("upload --purge /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', { 'description' => 'blarghle' } + file "roles/x.json", { "description" => "blarghle" } end - it 'knife upload changes the role' do - knife('upload /').should_succeed "Updated /roles/x.json\n" - knife('diff --name-status /').should_succeed '' + it "knife upload changes the role" do + knife("upload /").should_succeed "Updated /roles/x.json\n" + knife("diff --name-status /").should_succeed "" end - it 'knife upload --no-diff does not change the role' do - knife('upload --no-diff /').should_succeed '' - knife('diff --name-status /').should_succeed "M\t/roles/x.json\n" + it "knife upload --no-diff does not change the role" do + knife("upload --no-diff /").should_succeed "" + knife("diff --name-status /").should_succeed "M\t/roles/x.json\n" end end - context 'except the role file is textually different, but not ACTUALLY different' do + context "except the role file is textually different, but not ACTUALLY different" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role", "default_attributes": { @@ -148,45 +148,45 @@ EOM EOM end - it 'knife upload / does not change anything' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload / does not change anything" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed "" end end - context 'when cookbook metadata has a self-dependency' do + context "when cookbook metadata has a self-dependency" do before do - file 'cookbooks/x/metadata.rb', "name 'x'; version '1.0.0'; depends 'x'" + file "cookbooks/x/metadata.rb", "name 'x'; version '1.0.0'; depends 'x'" end it "should warn", :chef_lt_13_only do - knife('upload /cookbooks').should_succeed( + knife("upload /cookbooks").should_succeed( stdout: "Updated /cookbooks/x\n", stderr: "WARN: Ignoring self-dependency in cookbook x, please remove it (in the future this will be fatal).\n", ) - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end it "should fail in Chef 13", :chef_gte_13_only do - knife('upload /cookbooks').should_fail '' + knife("upload /cookbooks").should_fail "" # FIXME: include the error message here end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x/blah.rb', '' - file 'cookbooks/y/metadata.rb', cb_metadata("y", "1.0.0") - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x/blah.rb", "" + file "cookbooks/y/metadata.rb", cb_metadata("y", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife upload adds the new files' do - knife('upload /').should_succeed <<EOM + it "knife upload adds the new files" do + knife("upload /").should_succeed <<EOM Created /clients/y.json Updated /cookbooks/x Created /cookbooks/y @@ -198,11 +198,11 @@ Created /nodes/y.json Created /roles/y.json Created /users/y.json EOM - knife('diff /').should_succeed '' + knife("diff /").should_succeed "" end - it 'knife upload --no-diff adds the new files' do - knife('upload --no-diff /').should_succeed <<EOM + it "knife upload --no-diff adds the new files" do + knife("upload --no-diff /").should_succeed <<EOM Created /clients/y.json Updated /cookbooks/x Created /cookbooks/y @@ -214,15 +214,15 @@ Created /nodes/y.json Created /roles/y.json Created /users/y.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end - when_the_repository 'is empty' do - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife upload does nothing" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -233,8 +233,8 @@ D\t/users EOM end - it 'knife upload --purge deletes nothing' do - knife('upload --purge /').should_fail <<EOM + it "knife upload --purge deletes nothing" do + knife("upload --purge /").should_fail <<EOM ERROR: /clients cannot be deleted. ERROR: /cookbooks cannot be deleted. ERROR: /data_bags cannot be deleted. @@ -243,7 +243,7 @@ ERROR: /nodes cannot be deleted. ERROR: /roles cannot be deleted. ERROR: /users cannot be deleted. EOM - knife('diff --name-status /').should_succeed <<EOM + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -254,178 +254,178 @@ D\t/users EOM end - context 'when current directory is top level' do + context "when current directory is top level" do before do - cwd '.' + cwd "." end - it 'knife upload with no parameters reports an error' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + it "knife upload with no parameters reports an error" do + knife("upload").should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end end end end - when_the_chef_server 'is empty' do - when_the_repository 'has a data bag item' do + when_the_chef_server "is empty" do + when_the_repository "has a data bag item" do before do - file 'data_bags/x/y.json', { 'foo' => 'bar' } + file "data_bags/x/y.json", { "foo" => "bar" } end - it 'knife upload of the data bag uploads only the values in the data bag item and no other' do - knife('upload /data_bags/x/y.json').should_succeed <<EOM + it "knife upload of the data bag uploads only the values in the data bag item and no other" do + knife("upload /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM EOM - expect(Chef::JSONCompat.parse(knife('raw /data/x/y').stdout, :create_additions => false).keys.sort).to eq([ 'foo', 'id' ]) + expect(Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, :create_additions => false).keys.sort).to eq([ "foo", "id" ]) end - it 'knife upload /data_bags/x /data_bags/x/y.json uploads x once' do - knife('upload /data_bags/x /data_bags/x/y.json').should_succeed <<EOM + it "knife upload /data_bags/x /data_bags/x/y.json uploads x once" do + knife("upload /data_bags/x /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM end end - when_the_repository 'has a data bag item with keys chef_type and data_bag' do + when_the_repository "has a data bag item with keys chef_type and data_bag" do before do - file 'data_bags/x/y.json', { 'chef_type' => 'aaa', 'data_bag' => 'bbb' } + file "data_bags/x/y.json", { "chef_type" => "aaa", "data_bag" => "bbb" } end - it 'upload preserves chef_type and data_bag' do - knife('upload /data_bags/x/y.json').should_succeed <<EOM + it "upload preserves chef_type and data_bag" do + knife("upload /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed '' - result = Chef::JSONCompat.parse(knife('raw /data/x/y').stdout, :create_additions => false) - expect(result.keys.sort).to eq([ 'chef_type', 'data_bag', 'id' ]) - expect(result['chef_type']).to eq('aaa') - expect(result['data_bag']).to eq('bbb') + knife("diff --name-status /data_bags").should_succeed "" + result = Chef::JSONCompat.parse(knife("raw /data/x/y").stdout, :create_additions => false) + expect(result.keys.sort).to eq([ "chef_type", "data_bag", "id" ]) + expect(result["chef_type"]).to eq("aaa") + expect(result["data_bag"]).to eq("bbb") end end # Test upload of an item when the other end doesn't even have the container - when_the_repository 'has two data bag items' do + when_the_repository "has two data bag items" do before do - file 'data_bags/x/y.json', {} - file 'data_bags/x/z.json', {} + file "data_bags/x/y.json", {} + file "data_bags/x/z.json", {} end - it 'knife upload of one data bag item itself succeeds' do - knife('upload /data_bags/x/y.json').should_succeed <<EOM + it "knife upload of one data bag item itself succeeds" do + knife("upload /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM A\t/data_bags/x/z.json EOM end end end - when_the_chef_server 'has three data bag items' do + when_the_chef_server "has three data bag items" do before do - data_bag 'x', { 'deleted' => {}, 'modified' => {}, 'unmodified' => {} } + data_bag "x", { "deleted" => {}, "modified" => {}, "unmodified" => {} } end - when_the_repository 'has a modified, unmodified, added and deleted data bag item' do + when_the_repository "has a modified, unmodified, added and deleted data bag item" do before do - file 'data_bags/x/added.json', {} - file 'data_bags/x/modified.json', { 'foo' => 'bar' } - file 'data_bags/x/unmodified.json', {} + file "data_bags/x/added.json", {} + file "data_bags/x/modified.json", { "foo" => "bar" } + file "data_bags/x/unmodified.json", {} end - it 'knife upload of the modified file succeeds' do - knife('upload /data_bags/x/modified.json').should_succeed <<EOM + it "knife upload of the modified file succeeds" do + knife("upload /data_bags/x/modified.json").should_succeed <<EOM Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the unmodified file does nothing' do - knife('upload /data_bags/x/unmodified.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife upload of the unmodified file does nothing" do + knife("upload /data_bags/x/unmodified.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the added file succeeds' do - knife('upload /data_bags/x/added.json').should_succeed <<EOM + it "knife upload of the added file succeeds" do + knife("upload /data_bags/x/added.json").should_succeed <<EOM Created /data_bags/x/added.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json EOM end - it 'knife upload of the deleted file does nothing' do - knife('upload /data_bags/x/deleted.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife upload of the deleted file does nothing" do + knife("upload /data_bags/x/deleted.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload --purge of the deleted file deletes it' do - knife('upload --purge /data_bags/x/deleted.json').should_succeed <<EOM + it "knife upload --purge of the deleted file deletes it" do + knife("upload --purge /data_bags/x/deleted.json").should_succeed <<EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the entire data bag uploads everything' do - knife('upload /data_bags/x').should_succeed <<EOM + it "knife upload of the entire data bag uploads everything" do + knife("upload /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json EOM end - it 'knife upload --purge of the entire data bag uploads everything' do - knife('upload --purge /data_bags/x').should_succeed <<EOM + it "knife upload --purge of the entire data bag uploads everything" do + knife("upload --purge /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - context 'when cwd is the /data_bags directory' do + context "when cwd is the /data_bags directory" do before do - cwd 'data_bags' + cwd "data_bags" end - it 'knife upload fails' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + it "knife upload fails" do + knife("upload").should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end - it 'knife upload --purge . uploads everything' do - knife('upload --purge .').should_succeed <<EOM + it "knife upload --purge . uploads everything" do + knife("upload --purge .").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - it 'knife upload --purge * uploads everything' do - knife('upload --purge *').should_succeed <<EOM + it "knife upload --purge * uploads everything" do + knife("upload --purge *").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end end end @@ -434,128 +434,128 @@ EOM # Cookbook upload is a funny thing ... direct cookbook upload works, but # upload of a file is designed not to work at present. Make sure that is the # case. - when_the_chef_server 'has a cookbook' do + when_the_chef_server "has a cookbook" do before do - cookbook 'x', '1.0.0', { 'z.rb' => '' } + cookbook "x", "1.0.0", { "z.rb" => "" } end - when_the_repository 'has a modified, extra and missing file for the cookbook' do + when_the_repository "has a modified, extra and missing file for the cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0", "#modified") - file 'cookbooks/x/y.rb', 'hi' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "#modified") + file "cookbooks/x/y.rb", "hi" end - it 'knife upload of any individual file fails' do - knife('upload /cookbooks/x/metadata.rb').should_fail "ERROR: /cookbooks/x/metadata.rb cannot be updated.\n" - knife('upload /cookbooks/x/y.rb').should_fail "ERROR: /cookbooks/x cannot have a child created under it.\n" - knife('upload --purge /cookbooks/x/z.rb').should_fail "ERROR: /cookbooks/x/z.rb cannot be deleted.\n" + it "knife upload of any individual file fails" do + knife("upload /cookbooks/x/metadata.rb").should_fail "ERROR: /cookbooks/x/metadata.rb cannot be updated.\n" + knife("upload /cookbooks/x/y.rb").should_fail "ERROR: /cookbooks/x cannot have a child created under it.\n" + knife("upload --purge /cookbooks/x/z.rb").should_fail "ERROR: /cookbooks/x/z.rb cannot be deleted.\n" end # TODO this is a bit of an inconsistency: if we didn't specify --purge, # technically we shouldn't have deleted missing files. But ... cookbooks # are a special case. - it 'knife upload of the cookbook itself succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload of the cookbook itself succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end - it 'knife upload --purge of the cookbook itself succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload --purge of the cookbook itself succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has a missing file for the cookbook' do + when_the_repository "has a missing file for the cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") end - it 'knife upload of the cookbook succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload of the cookbook succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has an extra file for the cookbook' do + when_the_repository "has an extra file for the cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') - file 'cookbooks/x/z.rb', '' - file 'cookbooks/x/blah.rb', '' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/z.rb", "" + file "cookbooks/x/blah.rb", "" end - it 'knife upload of the cookbook succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload of the cookbook succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has a different file in the cookbook' do + when_the_repository "has a different file in the cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") end - it 'knife upload --freeze freezes the cookbook' do - knife('upload --freeze /cookbooks/x').should_succeed <<EOM + it "knife upload --freeze freezes the cookbook" do + knife("upload --freeze /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM # Modify a file and attempt to upload - file 'cookbooks/x/metadata.rb', 'name "x"; version "1.0.0"#different' - knife('upload /cookbooks/x').should_fail "ERROR: /cookbooks failed to write: Cookbook x is frozen\n" + file "cookbooks/x/metadata.rb", 'name "x"; version "1.0.0"#different' + knife("upload /cookbooks/x").should_fail "ERROR: /cookbooks failed to write: Cookbook x is frozen\n" end end end - when_the_chef_server 'has a frozen cookbook' do + when_the_chef_server "has a frozen cookbook" do before do - cookbook 'frozencook', '1.0.0', {}, :frozen => true + cookbook "frozencook", "1.0.0", {}, :frozen => true end - when_the_repository 'has an update to said cookbook' do + when_the_repository "has an update to said cookbook" do before do - file 'cookbooks/frozencook/metadata.rb', cb_metadata("frozencook", "1.0.0", "# This is different") + file "cookbooks/frozencook/metadata.rb", cb_metadata("frozencook", "1.0.0", "# This is different") end - it 'knife upload fails to upload the frozen cookbook' do - knife('upload /cookbooks/frozencook').should_fail "ERROR: /cookbooks failed to write: Cookbook frozencook is frozen\n" + it "knife upload fails to upload the frozen cookbook" do + knife("upload /cookbooks/frozencook").should_fail "ERROR: /cookbooks failed to write: Cookbook frozencook is frozen\n" end - it 'knife upload --force uploads the frozen cookbook' do - knife('upload --force /cookbooks/frozencook').should_succeed <<EOM + it "knife upload --force uploads the frozen cookbook" do + knife("upload --force /cookbooks/frozencook").should_succeed <<EOM Updated /cookbooks/frozencook EOM end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0') - file 'cookbooks/x/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the local version' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the local version" do + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb EOM - knife('upload --purge /cookbooks/x').should_succeed <<EOM + knife("upload --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed <<EOM + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb @@ -563,35 +563,35 @@ EOM end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the local version' do - knife('upload --purge /cookbooks/x').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the local version" do + knife("upload --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the local version' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the local version" do + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb EOM - knife('upload --purge /cookbooks/x').should_succeed <<EOM + knife("upload --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed <<EOM + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x/metadata.rb D\t/cookbooks/x/onlyin1.0.1.rb A\t/cookbooks/x/onlyin1.0.0.rb @@ -599,31 +599,31 @@ EOM end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the new version' do - knife('upload --purge /cookbooks/x').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the new version" do + knife("upload --purge /cookbooks/x").should_succeed <<EOM Updated /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_chef_server 'has an environment' do + when_the_chef_server "has an environment" do before do - environment 'x', {} + environment "x", {} end - when_the_repository 'has an environment with bad JSON' do + when_the_repository "has an environment with bad JSON" do before do - file 'environments/x.json', '{' + file "environments/x.json", "{" end - it 'knife upload tries and fails' do + it "knife upload tries and fails" do error1 = <<-EOH WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error: premature EOF { @@ -640,75 +640,75 @@ WARN: Parse error reading #{path_to('environments/x.json')} as JSON: parse error (right here) ------^ EOH - knife('upload /environments/x.json').should_fail(error1) - knife('diff --name-status /environments/x.json').should_succeed("M\t/environments/x.json\n", :stderr => warn) + knife("upload /environments/x.json").should_fail(error1) + knife("diff --name-status /environments/x.json").should_succeed("M\t/environments/x.json\n", :stderr => warn) end end - when_the_repository 'has the same environment with the wrong name in the file' do + when_the_repository "has the same environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife upload fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n" - knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n" + it "knife upload fails" do + knife("upload /environments/x.json").should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n" + knife("diff --name-status /environments/x.json").should_succeed "M\t/environments/x.json\n" end end - when_the_repository 'has the same environment with no name in the file' do + when_the_repository "has the same environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife upload succeeds' do - knife('upload /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end end - when_the_chef_server 'is empty' do + when_the_chef_server "is empty" do - when_the_repository 'has an environment with the wrong name in the file' do + when_the_repository "has an environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife upload fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n" - knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n" + it "knife upload fails" do + knife("upload /environments/x.json").should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n" + knife("diff --name-status /environments/x.json").should_succeed "A\t/environments/x.json\n" end end - when_the_repository 'has an environment with no name in the file' do + when_the_repository "has an environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife upload succeeds' do - knife('upload /environments/x.json').should_succeed "Created /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /environments/x.json").should_succeed "Created /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has a data bag with no id in the file' do + when_the_repository "has a data bag with no id in the file" do before do - file 'data_bags/bag/x.json', { 'foo' => 'bar' } + file "data_bags/bag/x.json", { "foo" => "bar" } end - it 'knife upload succeeds' do - knife('upload /data_bags/bag/x.json').should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n" - knife('diff --name-status /data_bags/bag/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /data_bags/bag/x.json").should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n" + knife("diff --name-status /data_bags/bag/x.json").should_succeed "" end end end when_the_chef_server "is empty" do - when_the_repository 'has a cookbook with an invalid chef_version constraint in it' do + when_the_repository "has a cookbook with an invalid chef_version constraint in it" do before do - file 'cookbooks/x/metadata.rb', cb_metadata('x', '1.0.0', "\nchef_version '~> 999.0'") + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'") end - it 'knife upload succeeds' do - knife('upload /cookbooks/x').should_succeed <<EOM + it "knife upload succeeds" do + knife("upload /cookbooks/x").should_succeed <<EOM Created /cookbooks/x EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end @@ -718,29 +718,29 @@ EOM when_the_chef_server "has one of each thing" do before do - client 'x', {} - cookbook 'x', '1.0.0' - data_bag 'x', { 'y' => {} } - environment 'x', {} - node 'x', {} - role 'x', {} - user 'x', {} + client "x", {} + cookbook "x", "1.0.0" + data_bag "x", { "y" => {} } + environment "x", {} + node "x", {} + role "x", {} + user "x", {} end - when_the_repository 'has only top-level directories' do + when_the_repository "has only top-level directories" do before do - directory 'clients' - directory 'cookbooks' - directory 'data_bags' - directory 'environments' - directory 'nodes' - directory 'roles' - directory 'users' - end - - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + directory "clients" + directory "cookbooks" + directory "data_bags" + directory "environments" + directory "nodes" + directory "roles" + directory "users" + end + + it "knife upload does nothing" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM D\t/clients/chef-validator.json D\t/clients/chef-webui.json D\t/clients/x.json @@ -755,8 +755,8 @@ D\t/users/x.json EOM end - it 'knife upload --purge deletes everything' do - knife('upload --purge /').should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") + it "knife upload --purge deletes everything" do + knife("upload --purge /").should_succeed(<<EOM, :stderr => "WARNING: /environments/_default.json cannot be deleted (default environment cannot be modified).\n") Deleted extra entry /clients/chef-validator.json (purge is on) Deleted extra entry /clients/chef-webui.json (purge is on) Deleted extra entry /clients/x.json (purge is on) @@ -768,52 +768,52 @@ Deleted extra entry /roles/x.json (purge is on) Deleted extra entry /users/admin.json (purge is on) Deleted extra entry /users/x.json (purge is on) EOM - knife('diff --name-status /').should_succeed <<EOM + knife("diff --name-status /").should_succeed <<EOM D\t/environments/_default.json EOM end end - when_the_repository 'has an identical copy of each thing' do + when_the_repository "has an identical copy of each thing" do before do - file 'clients/chef-validator.json', { 'validator' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/chef-webui.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0') - file 'data_bags/x/y.json', {} - file 'environments/_default.json', { 'description' => 'The default Chef environment' } - file 'environments/x.json', {} - file 'nodes/x.json', {} - file 'roles/x.json', {} - file 'users/admin.json', { 'admin' => true, 'public_key' => ChefZero::PUBLIC_KEY } - file 'users/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/chef-validator.json", { "validator" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/chef-webui.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/_default.json", { "description" => "The default Chef environment" } + file "environments/x.json", {} + file "nodes/x.json", {} + file "roles/x.json", {} + file "users/admin.json", { "admin" => true, "public_key" => ChefZero::PUBLIC_KEY } + file "users/x.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife upload makes no changes' do - knife('upload /cookbooks/x-1.0.0').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload makes no changes" do + knife("upload /cookbooks/x-1.0.0").should_succeed "" + knife("diff --name-status /").should_succeed "" end - it 'knife upload --purge makes no changes' do - knife('upload --purge /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload --purge makes no changes" do + knife("upload --purge /").should_succeed "" + knife("diff --name-status /").should_succeed "" end - context 'except the role file' do + context "except the role file" do before do - file 'roles/x.json', { 'description' => 'blarghle' } + file "roles/x.json", { "description" => "blarghle" } end - it 'knife upload changes the role' do - knife('upload /').should_succeed "Updated /roles/x.json\n" - knife('diff --name-status /').should_succeed '' + it "knife upload changes the role" do + knife("upload /").should_succeed "Updated /roles/x.json\n" + knife("diff --name-status /").should_succeed "" end end - context 'except the role file is textually different, but not ACTUALLY different' do + context "except the role file is textually different, but not ACTUALLY different" do before do - file 'roles/x.json', <<EOM + file "roles/x.json", <<EOM { "chef_type": "role", "default_attributes": { @@ -832,28 +832,28 @@ EOM EOM end - it 'knife upload / does not change anything' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed '' + it "knife upload / does not change anything" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed "" end end - context 'as well as one extra copy of each thing' do + context "as well as one extra copy of each thing" do before do - file 'clients/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'cookbooks/x-1.0.0/blah.rb', '' - file 'cookbooks/x-2.0.0/metadata.rb', cb_metadata('x', '2.0.0') - file 'cookbooks/y-1.0.0/metadata.rb', cb_metadata('y', '1.0.0') - file 'data_bags/x/z.json', {} - file 'data_bags/y/zz.json', {} - file 'environments/y.json', {} - file 'nodes/y.json', {} - file 'roles/y.json', {} - file 'users/y.json', { 'public_key' => ChefZero::PUBLIC_KEY } + file "clients/y.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "cookbooks/x-1.0.0/blah.rb", "" + file "cookbooks/x-2.0.0/metadata.rb", cb_metadata("x", "2.0.0") + file "cookbooks/y-1.0.0/metadata.rb", cb_metadata("y", "1.0.0") + file "data_bags/x/z.json", {} + file "data_bags/y/zz.json", {} + file "environments/y.json", {} + file "nodes/y.json", {} + file "roles/y.json", {} + file "users/y.json", { "public_key" => ChefZero::PUBLIC_KEY } end - it 'knife upload adds the new files' do - knife('upload /').should_succeed <<EOM + it "knife upload adds the new files" do + knife("upload /").should_succeed <<EOM Created /clients/y.json Updated /cookbooks/x-1.0.0 Created /cookbooks/x-2.0.0 @@ -866,15 +866,15 @@ Created /nodes/y.json Created /roles/y.json Created /users/y.json EOM - knife('diff --name-status /').should_succeed '' + knife("diff --name-status /").should_succeed "" end end end - when_the_repository 'is empty' do - it 'knife upload does nothing' do - knife('upload /').should_succeed '' - knife('diff --name-status /').should_succeed <<EOM + when_the_repository "is empty" do + it "knife upload does nothing" do + knife("upload /").should_succeed "" + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -885,8 +885,8 @@ D\t/users EOM end - it 'knife upload --purge deletes nothing' do - knife('upload --purge /').should_fail <<EOM + it "knife upload --purge deletes nothing" do + knife("upload --purge /").should_fail <<EOM ERROR: /clients cannot be deleted. ERROR: /cookbooks cannot be deleted. ERROR: /data_bags cannot be deleted. @@ -895,7 +895,7 @@ ERROR: /nodes cannot be deleted. ERROR: /roles cannot be deleted. ERROR: /users cannot be deleted. EOM - knife('diff --name-status /').should_succeed <<EOM + knife("diff --name-status /").should_succeed <<EOM D\t/clients D\t/cookbooks D\t/data_bags @@ -906,130 +906,130 @@ D\t/users EOM end - context 'when current directory is top level' do + context "when current directory is top level" do before do - cwd '.' + cwd "." end - it 'knife upload with no parameters reports an error' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + it "knife upload with no parameters reports an error" do + knife("upload").should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end end end end # Test upload of an item when the other end doesn't even have the container - when_the_chef_server 'is empty' do - when_the_repository 'has two data bag items' do + when_the_chef_server "is empty" do + when_the_repository "has two data bag items" do before do - file 'data_bags/x/y.json', {} - file 'data_bags/x/z.json', {} + file "data_bags/x/y.json", {} + file "data_bags/x/z.json", {} end - it 'knife upload of one data bag item itself succeeds' do - knife('upload /data_bags/x/y.json').should_succeed <<EOM + it "knife upload of one data bag item itself succeeds" do + knife("upload /data_bags/x/y.json").should_succeed <<EOM Created /data_bags/x Created /data_bags/x/y.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM A\t/data_bags/x/z.json EOM end end end - when_the_chef_server 'has three data bag items' do + when_the_chef_server "has three data bag items" do before do - data_bag 'x', { 'deleted' => {}, 'modified' => {}, 'unmodified' => {} } + data_bag "x", { "deleted" => {}, "modified" => {}, "unmodified" => {} } end - when_the_repository 'has a modified, unmodified, added and deleted data bag item' do + when_the_repository "has a modified, unmodified, added and deleted data bag item" do before do - file 'data_bags/x/added.json', {} - file 'data_bags/x/modified.json', { 'foo' => 'bar' } - file 'data_bags/x/unmodified.json', {} + file "data_bags/x/added.json", {} + file "data_bags/x/modified.json", { "foo" => "bar" } + file "data_bags/x/unmodified.json", {} end - it 'knife upload of the modified file succeeds' do - knife('upload /data_bags/x/modified.json').should_succeed <<EOM + it "knife upload of the modified file succeeds" do + knife("upload /data_bags/x/modified.json").should_succeed <<EOM Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the unmodified file does nothing' do - knife('upload /data_bags/x/unmodified.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife upload of the unmodified file does nothing" do + knife("upload /data_bags/x/unmodified.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the added file succeeds' do - knife('upload /data_bags/x/added.json').should_succeed <<EOM + it "knife upload of the added file succeeds" do + knife("upload /data_bags/x/added.json").should_succeed <<EOM Created /data_bags/x/added.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json EOM end - it 'knife upload of the deleted file does nothing' do - knife('upload /data_bags/x/deleted.json').should_succeed '' - knife('diff --name-status /data_bags').should_succeed <<EOM + it "knife upload of the deleted file does nothing" do + knife("upload /data_bags/x/deleted.json").should_succeed "" + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload --purge of the deleted file deletes it' do - knife('upload --purge /data_bags/x/deleted.json').should_succeed <<EOM + it "knife upload --purge of the deleted file deletes it" do + knife("upload --purge /data_bags/x/deleted.json").should_succeed <<EOM Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM M\t/data_bags/x/modified.json A\t/data_bags/x/added.json EOM end - it 'knife upload of the entire data bag uploads everything' do - knife('upload /data_bags/x').should_succeed <<EOM + it "knife upload of the entire data bag uploads everything" do + knife("upload /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json EOM - knife('diff --name-status /data_bags').should_succeed <<EOM + knife("diff --name-status /data_bags").should_succeed <<EOM D\t/data_bags/x/deleted.json EOM end - it 'knife upload --purge of the entire data bag uploads everything' do - knife('upload --purge /data_bags/x').should_succeed <<EOM + it "knife upload --purge of the entire data bag uploads everything" do + knife("upload --purge /data_bags/x").should_succeed <<EOM Created /data_bags/x/added.json Updated /data_bags/x/modified.json Deleted extra entry /data_bags/x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - context 'when cwd is the /data_bags directory' do + context "when cwd is the /data_bags directory" do before do - cwd 'data_bags' + cwd "data_bags" end - it 'knife upload fails' do - knife('upload').should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ + it "knife upload fails" do + knife("upload").should_fail "FATAL: Must specify at least one argument. If you want to upload everything in this directory, type \"knife upload .\"\n", :stdout => /USAGE/ end - it 'knife upload --purge . uploads everything' do - knife('upload --purge .').should_succeed <<EOM + it "knife upload --purge . uploads everything" do + knife("upload --purge .").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end - it 'knife upload --purge * uploads everything' do - knife('upload --purge *').should_succeed <<EOM + it "knife upload --purge * uploads everything" do + knife("upload --purge *").should_succeed <<EOM Created x/added.json Updated x/modified.json Deleted extra entry x/deleted.json (purge is on) EOM - knife('diff --name-status /data_bags').should_succeed '' + knife("diff --name-status /data_bags").should_succeed "" end end end @@ -1038,271 +1038,271 @@ EOM # Cookbook upload is a funny thing ... direct cookbook upload works, but # upload of a file is designed not to work at present. Make sure that is the # case. - when_the_chef_server 'has a cookbook' do + when_the_chef_server "has a cookbook" do before do - cookbook 'x', '1.0.0', { 'z.rb' => '' } + cookbook "x", "1.0.0", { "z.rb" => "" } end - when_the_repository 'has a modified, extra and missing file for the cookbook' do + when_the_repository "has a modified, extra and missing file for the cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0', '#modified') - file 'cookbooks/x-1.0.0/y.rb', 'hi' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", '#modified') + file "cookbooks/x-1.0.0/y.rb", "hi" end - it 'knife upload of any individual file fails' do - knife('upload /cookbooks/x-1.0.0/metadata.rb').should_fail "ERROR: /cookbooks/x-1.0.0/metadata.rb cannot be updated.\n" - knife('upload /cookbooks/x-1.0.0/y.rb').should_fail "ERROR: /cookbooks/x-1.0.0 cannot have a child created under it.\n" - knife('upload --purge /cookbooks/x-1.0.0/z.rb').should_fail "ERROR: /cookbooks/x-1.0.0/z.rb cannot be deleted.\n" + it "knife upload of any individual file fails" do + knife("upload /cookbooks/x-1.0.0/metadata.rb").should_fail "ERROR: /cookbooks/x-1.0.0/metadata.rb cannot be updated.\n" + knife("upload /cookbooks/x-1.0.0/y.rb").should_fail "ERROR: /cookbooks/x-1.0.0 cannot have a child created under it.\n" + knife("upload --purge /cookbooks/x-1.0.0/z.rb").should_fail "ERROR: /cookbooks/x-1.0.0/z.rb cannot be deleted.\n" end # TODO this is a bit of an inconsistency: if we didn't specify --purge, # technically we shouldn't have deleted missing files. But ... cookbooks # are a special case. - it 'knife upload of the cookbook itself succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload of the cookbook itself succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end - it 'knife upload --purge of the cookbook itself succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload --purge of the cookbook itself succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has a missing file for the cookbook' do + when_the_repository "has a missing file for the cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', "1.0.0") + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") end - it 'knife upload of the cookbook succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload of the cookbook succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_repository 'has an extra file for the cookbook' do + when_the_repository "has an extra file for the cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0') - file 'cookbooks/x-1.0.0/z.rb', '' - file 'cookbooks/x-1.0.0/blah.rb', '' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x-1.0.0/z.rb", "" + file "cookbooks/x-1.0.0/blah.rb", "" end - it 'knife upload of the cookbook succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload of the cookbook succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Updated /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_repository 'has a cookbook' do + when_the_repository "has a cookbook" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0') - file 'cookbooks/x-1.0.0/onlyin1.0.0.rb', 'old_text' + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0") + file "cookbooks/x-1.0.0/onlyin1.0.0.rb", "old_text" end - when_the_chef_server 'has a later version for the cookbook' do + when_the_chef_server "has a later version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => '' } - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => "" } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife upload /cookbooks uploads the local version' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks uploads the local version" do + knife("diff --name-status /cookbooks").should_succeed <<EOM M\t/cookbooks/x-1.0.0/onlyin1.0.0.rb D\t/cookbooks/x-1.0.1 EOM - knife('upload --purge /cookbooks').should_succeed <<EOM + knife("upload --purge /cookbooks").should_succeed <<EOM Updated /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-1.0.1 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook' do + when_the_chef_server "has an earlier version for the cookbook" do before do - cookbook 'x', '1.0.0', { 'onlyin1.0.0.rb' => ''} - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "1.0.0", { "onlyin1.0.0.rb" => ""} + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife upload /cookbooks uploads the local version' do - knife('upload --purge /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks uploads the local version" do + knife("upload --purge /cookbooks").should_succeed <<EOM Updated /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-0.9.9 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has a later version for the cookbook, and no current version' do + when_the_chef_server "has a later version for the cookbook, and no current version" do before do - cookbook 'x', '1.0.1', { 'onlyin1.0.1.rb' => 'hi' } + cookbook "x", "1.0.1", { "onlyin1.0.1.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the local version' do - knife('diff --name-status /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the local version" do + knife("diff --name-status /cookbooks").should_succeed <<EOM D\t/cookbooks/x-1.0.1 A\t/cookbooks/x-1.0.0 EOM - knife('upload --purge /cookbooks').should_succeed <<EOM + knife("upload --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-1.0.1 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end - when_the_chef_server 'has an earlier version for the cookbook, and no current version' do + when_the_chef_server "has an earlier version for the cookbook, and no current version" do before do - cookbook 'x', '0.9.9', { 'onlyin0.9.9.rb' => 'hi' } + cookbook "x", "0.9.9", { "onlyin0.9.9.rb" => "hi" } end - it 'knife upload /cookbooks/x uploads the new version' do - knife('upload --purge /cookbooks').should_succeed <<EOM + it "knife upload /cookbooks/x uploads the new version" do + knife("upload --purge /cookbooks").should_succeed <<EOM Created /cookbooks/x-1.0.0 Deleted extra entry /cookbooks/x-0.9.9 (purge is on) EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end - when_the_chef_server 'has an environment' do + when_the_chef_server "has an environment" do before do - environment 'x', {} + environment "x", {} end - when_the_repository 'has the same environment with the wrong name in the file' do + when_the_repository "has the same environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife upload fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n" - knife('diff --name-status /environments/x.json').should_succeed "M\t/environments/x.json\n" + it "knife upload fails" do + knife("upload /environments/x.json").should_fail "ERROR: /environments/x.json failed to write: Name must be 'x' (is 'y')\n" + knife("diff --name-status /environments/x.json").should_succeed "M\t/environments/x.json\n" end end - when_the_repository 'has the same environment with no name in the file' do + when_the_repository "has the same environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife upload succeeds' do - knife('upload /environments/x.json').should_succeed "Updated /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /environments/x.json").should_succeed "Updated /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end end - when_the_chef_server 'is empty' do + when_the_chef_server "is empty" do - when_the_repository 'has an environment with the wrong name in the file' do + when_the_repository "has an environment with the wrong name in the file" do before do - file 'environments/x.json', { 'name' => 'y' } + file "environments/x.json", { "name" => "y" } end - it 'knife upload fails' do - knife('upload /environments/x.json').should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n" - knife('diff --name-status /environments/x.json').should_succeed "A\t/environments/x.json\n" + it "knife upload fails" do + knife("upload /environments/x.json").should_fail "ERROR: /environments failed to create_child: Error creating 'x.json': Name must be 'x' (is 'y')\n" + knife("diff --name-status /environments/x.json").should_succeed "A\t/environments/x.json\n" end end - when_the_repository 'has an environment with no name in the file' do + when_the_repository "has an environment with no name in the file" do before do - file 'environments/x.json', { 'description' => 'hi' } + file "environments/x.json", { "description" => "hi" } end - it 'knife upload succeeds' do - knife('upload /environments/x.json').should_succeed "Created /environments/x.json\n" - knife('diff --name-status /environments/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /environments/x.json").should_succeed "Created /environments/x.json\n" + knife("diff --name-status /environments/x.json").should_succeed "" end end - when_the_repository 'has a data bag with no id in the file' do + when_the_repository "has a data bag with no id in the file" do before do - file 'data_bags/bag/x.json', { 'foo' => 'bar' } + file "data_bags/bag/x.json", { "foo" => "bar" } end - it 'knife upload succeeds' do - knife('upload /data_bags/bag/x.json').should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n" - knife('diff --name-status /data_bags/bag/x.json').should_succeed '' + it "knife upload succeeds" do + knife("upload /data_bags/bag/x.json").should_succeed "Created /data_bags/bag\nCreated /data_bags/bag/x.json\n" + knife("diff --name-status /data_bags/bag/x.json").should_succeed "" end end end when_the_chef_server "is empty" do - when_the_repository 'has a cookbook with an invalid chef_version constraint in it' do + when_the_repository "has a cookbook with an invalid chef_version constraint in it" do before do - file 'cookbooks/x-1.0.0/metadata.rb', cb_metadata('x', '1.0.0', "\nchef_version '~> 999.0'") + file "cookbooks/x-1.0.0/metadata.rb", cb_metadata("x", "1.0.0", "\nchef_version '~> 999.0'") end - it 'knife upload succeeds' do - knife('upload /cookbooks/x-1.0.0').should_succeed <<EOM + it "knife upload succeeds" do + knife("upload /cookbooks/x-1.0.0").should_succeed <<EOM Created /cookbooks/x-1.0.0 EOM - knife('diff --name-status /cookbooks').should_succeed '' + knife("diff --name-status /cookbooks").should_succeed "" end end end end # with versioned cookbooks - when_the_chef_server 'has a user' do + when_the_chef_server "has a user" do before do - user 'x', {} + user "x", {} end - when_the_repository 'has the same user with json_class in it' do + when_the_repository "has the same user with json_class in it" do before do - file 'users/x.json', { 'admin' => true, 'json_class' => 'Chef::WebUIUser' } + file "users/x.json", { "admin" => true, "json_class" => "Chef::WebUIUser" } end - it 'knife upload /users/x.json succeeds' do - knife('upload /users/x.json').should_succeed "Updated /users/x.json\n" + it "knife upload /users/x.json succeeds" do + knife("upload /users/x.json").should_succeed "Updated /users/x.json\n" end end end when_the_chef_server "is in Enterprise mode", :osc_compat => false, :single_org => false do before do - user 'foo', {} - user 'bar', {} - user 'foobar', {} - organization 'foo', { 'full_name' => 'Something' } + user "foo", {} + user "bar", {} + user "foobar", {} + organization "foo", { "full_name" => "Something" } end before :each do - Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, '/organizations/foo') + Chef::Config.chef_server_url = URI.join(Chef::Config.chef_server_url, "/organizations/foo") end - context 'and has nothing but a single group named blah' do - group 'blah', {} + context "and has nothing but a single group named blah" do + group "blah", {} - when_the_repository 'has at least one of each thing' do + when_the_repository "has at least one of each thing" do before do # TODO We have to upload acls for an existing group due to a lack of # dependency detection during upload. Fix that! - file 'acls/groups/blah.json', {} - file 'clients/x.json', { 'public_key' => ChefZero::PUBLIC_KEY } - file 'containers/x.json', {} - file 'cookbooks/x/metadata.rb', cb_metadata("x", "1.0.0") - file 'data_bags/x/y.json', {} - file 'environments/x.json', {} - file 'groups/x.json', {} - file 'invitations.json', [ 'foo' ] - file 'members.json', [ 'bar' ] - file 'org.json', { 'full_name' => 'wootles' } - file 'nodes/x.json', {} - file 'policies/x-1.0.0.json', { } - file 'policies/blah-1.0.0.json', { } - file 'policy_groups/x.json', { 'policies' => { 'x' => { 'revision_id' => '1.0.0' }, 'blah' => { 'revision_id' => '1.0.0' } } } - file 'roles/x.json', {} - end - - it 'knife upload / uploads everything' do - knife('upload /').should_succeed <<EOM + file "acls/groups/blah.json", {} + file "clients/x.json", { "public_key" => ChefZero::PUBLIC_KEY } + file "containers/x.json", {} + file "cookbooks/x/metadata.rb", cb_metadata("x", "1.0.0") + file "data_bags/x/y.json", {} + file "environments/x.json", {} + file "groups/x.json", {} + file "invitations.json", [ "foo" ] + file "members.json", [ "bar" ] + file "org.json", { "full_name" => "wootles" } + file "nodes/x.json", {} + file "policies/x-1.0.0.json", { } + file "policies/blah-1.0.0.json", { } + file "policy_groups/x.json", { "policies" => { "x" => { "revision_id" => "1.0.0" }, "blah" => { "revision_id" => "1.0.0" } } } + file "roles/x.json", {} + end + + it "knife upload / uploads everything" do + knife("upload /").should_succeed <<EOM Updated /acls/groups/blah.json Created /clients/x.json Created /containers/x.json @@ -1320,39 +1320,39 @@ Created /policies/x-1.0.0.json Created /policy_groups/x.json Created /roles/x.json EOM - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ 'foo' ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar' ]) + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "foo" ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ]) end context "When the chef server has an identical copy of each thing" do before do - file 'invitations.json', [ 'foo' ] - file 'members.json', [ 'bar' ] - file 'org.json', { 'full_name' => 'Something' } + file "invitations.json", [ "foo" ] + file "members.json", [ "bar" ] + file "org.json", { "full_name" => "Something" } # acl_for %w(organizations foo groups blah) - client 'x', {} - cookbook 'x', '1.0.0' - container 'x', {} - data_bag 'x', { 'y' => {} } - environment 'x', {} - group 'x', {} - org_invite 'foo' - org_member 'bar' - node 'x', {} - policy 'x', '1.0.0', {} - policy 'blah', '1.0.0', {} - policy_group 'x', { - 'policies' => { - 'x' => { 'revision_id' => '1.0.0' }, - 'blah' => { 'revision_id' => '1.0.0' }, + client "x", {} + cookbook "x", "1.0.0" + container "x", {} + data_bag "x", { "y" => {} } + environment "x", {} + group "x", {} + org_invite "foo" + org_member "bar" + node "x", {} + policy "x", "1.0.0", {} + policy "blah", "1.0.0", {} + policy_group "x", { + "policies" => { + "x" => { "revision_id" => "1.0.0" }, + "blah" => { "revision_id" => "1.0.0" }, } } - role 'x', {} + role "x", {} end - it 'knife upload makes no changes' do - knife('upload /').should_succeed <<EOM + it "knife upload makes no changes" do + knife("upload /").should_succeed <<EOM Updated /acls/groups/blah.json EOM end @@ -1360,7 +1360,7 @@ EOM context "When the chef server has a slightly different copy of the policy revision" do before do - policy 'x', '1.0.0', { 'run_list' => [ 'blah' ] } + policy "x", "1.0.0", { "run_list" => [ "blah" ] } end it "should fail because policies are not updateable" do @@ -1373,27 +1373,27 @@ EOM context "When the chef server has a slightly different copy of each thing (except policy revisions)" do before do # acl_for %w(organizations foo groups blah) - client 'x', { 'validator' => true } - container 'x', {} - cookbook 'x', '1.0.0', { 'recipes' => { 'default.rb' => '' } } - data_bag 'x', { 'y' => { 'a' => 'b' } } - environment 'x', { 'description' => 'foo' } - group 'x', { 'groups' => [ 'admin' ] } - node 'x', { 'run_list' => [ 'blah' ] } - policy 'x', '1.0.0', { } - policy 'x', '1.0.1', { } - policy 'y', '1.0.0', { } - policy_group 'x', { - 'policies' => { - 'x' => { 'revision_id' => '1.0.1' }, - 'y' => { 'revision_id' => '1.0.0' }, + client "x", { "validator" => true } + container "x", {} + cookbook "x", "1.0.0", { "recipes" => { "default.rb" => "" } } + data_bag "x", { "y" => { "a" => "b" } } + environment "x", { "description" => "foo" } + group "x", { "groups" => [ "admin" ] } + node "x", { "run_list" => [ "blah" ] } + policy "x", "1.0.0", { } + policy "x", "1.0.1", { } + policy "y", "1.0.0", { } + policy_group "x", { + "policies" => { + "x" => { "revision_id" => "1.0.1" }, + "y" => { "revision_id" => "1.0.0" }, } } - role 'x', { 'run_list' => [ 'blah' ] } + role "x", { "run_list" => [ "blah" ] } end - it 'knife upload updates everything' do - knife('upload /').should_succeed <<EOM + it "knife upload updates everything" do + knife("upload /").should_succeed <<EOM Updated /acls/groups/blah.json Updated /clients/x.json Updated /cookbooks/x @@ -1408,103 +1408,103 @@ Created /policies/blah-1.0.0.json Updated /policy_groups/x.json Updated /roles/x.json EOM - knife('diff --name-status --diff-filter=AMT /').should_succeed '' + knife("diff --name-status --diff-filter=AMT /").should_succeed "" end end end - when_the_repository 'has an org.json that does not change full_name' do + when_the_repository "has an org.json that does not change full_name" do before do - file 'org.json', { 'full_name' => 'Something' } + file "org.json", { "full_name" => "Something" } end - it 'knife upload / emits a warning for bar and adds foo and foobar' do - knife('upload /').should_succeed '' - expect(api.get('/')['full_name']).to eq('Something') + it "knife upload / emits a warning for bar and adds foo and foobar" do + knife("upload /").should_succeed "" + expect(api.get("/")["full_name"]).to eq("Something") end end - when_the_repository 'has an org.json that changes full_name' do + when_the_repository "has an org.json that changes full_name" do before do - file 'org.json', { 'full_name' => 'Something Else'} + file "org.json", { "full_name" => "Something Else"} end - it 'knife upload / emits a warning for bar and adds foo and foobar' do - knife('upload /').should_succeed "Updated /org.json\n" - expect(api.get('/')['full_name']).to eq('Something Else') + it "knife upload / emits a warning for bar and adds foo and foobar" do + knife("upload /").should_succeed "Updated /org.json\n" + expect(api.get("/")["full_name"]).to eq("Something Else") end end - context 'and has invited foo and bar is already a member' do - org_invite 'foo' - org_member 'bar' + context "and has invited foo and bar is already a member" do + org_invite "foo" + org_member "bar" - when_the_repository 'wants to invite foo, bar and foobar' do + when_the_repository "wants to invite foo, bar and foobar" do before do - file 'invitations.json', [ 'foo', 'bar', 'foobar' ] + file "invitations.json", [ "foo", "bar", "foobar" ] end - it 'knife upload / emits a warning for bar and invites foobar' do - knife('upload /').should_succeed "Updated /invitations.json\n", :stderr => "WARN: Could not invite bar to organization foo: User bar is already in organization foo\n" - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ 'foo', 'foobar' ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar' ]) + it "knife upload / emits a warning for bar and invites foobar" do + knife("upload /").should_succeed "Updated /invitations.json\n", :stderr => "WARN: Could not invite bar to organization foo: User bar is already in organization foo\n" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "foo", "foobar" ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ]) end end - when_the_repository 'wants to make foo, bar and foobar members' do + when_the_repository "wants to make foo, bar and foobar members" do before do - file 'members.json', [ 'foo', 'bar', 'foobar' ] + file "members.json", [ "foo", "bar", "foobar" ] end - it 'knife upload / emits a warning for bar and adds foo and foobar' do - knife('upload /').should_succeed "Updated /members.json\n" - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar', 'foo', 'foobar' ]) + it "knife upload / emits a warning for bar and adds foo and foobar" do + knife("upload /").should_succeed "Updated /members.json\n" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar", "foo", "foobar" ]) end end - when_the_repository 'wants to invite foo and have bar as a member' do + when_the_repository "wants to invite foo and have bar as a member" do before do - file 'invitations.json', [ 'foo' ] - file 'members.json', [ 'bar' ] + file "invitations.json", [ "foo" ] + file "members.json", [ "bar" ] end - it 'knife upload / does nothing' do - knife('upload /').should_succeed '' - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ 'foo' ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar' ]) + it "knife upload / does nothing" do + knife("upload /").should_succeed "" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "foo" ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar" ]) end end end - context 'and has invited bar and foo' do - org_invite 'bar', 'foo' + context "and has invited bar and foo" do + org_invite "bar", "foo" - when_the_repository 'wants to invite foo and bar (different order)' do + when_the_repository "wants to invite foo and bar (different order)" do before do - file 'invitations.json', [ 'foo', 'bar' ] + file "invitations.json", [ "foo", "bar" ] end - it 'knife upload / does nothing' do - knife('upload /').should_succeed '' - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ 'bar', 'foo' ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ ]) + it "knife upload / does nothing" do + knife("upload /").should_succeed "" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ "bar", "foo" ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ ]) end end end - context 'and has already added bar and foo as members of the org' do - org_member 'bar', 'foo' + context "and has already added bar and foo as members of the org" do + org_member "bar", "foo" - when_the_repository 'wants to add foo and bar (different order)' do + when_the_repository "wants to add foo and bar (different order)" do before do - file 'members.json', [ 'foo', 'bar' ] + file "members.json", [ "foo", "bar" ] end - it 'knife upload / does nothing' do - knife('upload /').should_succeed '' - expect(api.get('association_requests').map { |a| a['username'] }).to eq([ ]) - expect(api.get('users').map { |a| a['user']['username'] }).to eq([ 'bar', 'foo' ]) + it "knife upload / does nothing" do + knife("upload /").should_succeed "" + expect(api.get("association_requests").map { |a| a["username"] }).to eq([ ]) + expect(api.get("users").map { |a| a["user"]["username"] }).to eq([ "bar", "foo" ]) end end end |