require 'support/integration_helper' require 'chef/knife/diff_essentials' describe 'knife diff' do extend IntegrationSupport include KnifeSupport when_the_chef_server "has one of each thing" do client 'x', '{}' cookbook 'x', '1.0.0', { 'metadata.rb' => 'version "1.0.0"' } data_bag 'x', { 'y' => '{}' } environment 'x', '{}' node 'x', '{}' role 'x', '{}' user 'x', '{}' when_the_repository 'has only top-level directories' do directory 'clients' directory 'cookbooks' directory 'data_bags' directory 'environments' directory 'nodes' directory 'roles' directory 'users' it 'knife diff reports everything as deleted' do knife('diff --name-status /').should_succeed < 'version "1.0.0"', 'onlyin1.0.0.rb' => ''} cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => '' } it 'knife diff /cookbooks/x shows differences' do knife('diff --name-status /cookbooks/x').should_succeed < 'version "1.0.0"', 'onlyin1.0.0.rb' => '' } cookbook 'x', '0.9.9', { 'metadata.rb' => 'version "0.9.9"', 'onlyin0.9.9.rb' => '' } 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 cookbook 'x', '1.0.1', { 'metadata.rb' => 'version "1.0.1"', 'onlyin1.0.1.rb' => '' } it 'knife diff /cookbooks/x shows the differences' do knife('diff --name-status /cookbooks/x').should_succeed < 'version "0.9.9"', 'onlyin0.9.9.rb' => '' } it 'knife diff /cookbooks/x shows the differences' do knife('diff --name-status /cookbooks/x').should_succeed <