diff options
author | John Keiser <jkeiser@opscode.com> | 2014-02-06 17:14:19 -0800 |
---|---|---|
committer | John Keiser <jkeiser@opscode.com> | 2014-04-29 15:46:30 -0700 |
commit | d12e41e599ea4af60937547bd3318422b6d7782f (patch) | |
tree | 228606bdc0cdf02aa118de0fec3d9e239673d2da /spec/integration/recipes | |
parent | 8401b6c28799e070290476ca9fab5aeb4f5fd7ae (diff) | |
download | chef-d12e41e599ea4af60937547bd3318422b6d7782f.tar.gz |
Add indentation to pretty-print LWRPs with inline resources
Diffstat (limited to 'spec/integration/recipes')
-rw-r--r-- | spec/integration/recipes/lwrp_inline_resources_spec.rb | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/spec/integration/recipes/lwrp_inline_resources_spec.rb b/spec/integration/recipes/lwrp_inline_resources_spec.rb new file mode 100644 index 0000000000..dca5713ace --- /dev/null +++ b/spec/integration/recipes/lwrp_inline_resources_spec.rb @@ -0,0 +1,73 @@ +require 'support/shared/integration/integration_helper' +require 'chef/mixin/shell_out' + +describe "LWRPs with inline resources" do + extend IntegrationSupport + include Chef::Mixin::ShellOut + + let(:chef_dir) { File.join(File.dirname(__FILE__), "..", "..", "..", "bin") } + + # Invoke `chef-client` as `ruby PATH/TO/chef-client`. This ensures the + # following constraints are satisfied: + # * Windows: windows can only run batch scripts as bare executables. Rubygems + # creates batch wrappers for installed gems, but we don't have batch wrappers + # in the source tree. + # * Other `chef-client` in PATH: A common case is running the tests on a + # machine that has omnibus chef installed. In that case we need to ensure + # we're running `chef-client` from the source tree and not the external one. + # cf. CHEF-4914 + let(:chef_client) { "ruby #{chef_dir}/chef-client" } + + when_the_repository "has a cookbook with a nested LWRP" do + directory 'cookbooks/x' do + + file 'resources/do_nothing.rb', <<EOM +actions :create, :nothing +default_action :create +EOM + file 'providers/do_nothing.rb', <<EOM +action :create do +end +EOM + + file 'resources/my_machine.rb', <<EOM +actions :create, :nothing +default_action :create +EOM + file 'providers/my_machine.rb', <<EOM +use_inline_resources +action :create do + x_do_nothing 'a' + x_do_nothing 'b' +end +EOM + + file 'recipes/default.rb', <<EOM +x_my_machine "me" +x_my_machine "you" +EOM + + end # directory 'cookbooks/x' + + it "should complete with success" do + file 'config/client.rb', <<EOM +local_mode true +cookbook_path "#{path_to('cookbooks')}" +log_level :warn +EOM + + result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" --no-color -F doc -o 'x::default'", :cwd => chef_dir) + result.stdout.should include(<<EOM) + * x_my_machine[me] action create + * x_do_nothing[a] action create (up to date) + * x_do_nothing[b] action create (up to date) + (up to date) + * x_my_machine[you] action create + * x_do_nothing[a] action create (up to date) + * x_do_nothing[b] action create (up to date) + (up to date) +EOM + result.error! + end + end +end |