diff options
author | Marc A. Paradise <marc.paradise@gmail.com> | 2021-01-29 16:28:17 -0500 |
---|---|---|
committer | Marc A. Paradise <marc.paradise@gmail.com> | 2021-02-04 10:40:42 -0500 |
commit | a258c8cb90c5377caaf76c473007043eac787153 (patch) | |
tree | 2e839187eea72c57e13367cab3255fe46469dbb9 /spec/integration | |
parent | a53c4c4db03e8cf1050af76f285d0d00b0088143 (diff) | |
download | chef-a258c8cb90c5377caaf76c473007043eac787153.tar.gz |
Add support for resource action descriptions
This will allow us to generate better documentation by including
action descriptions in the resource help, and includes updates to the
resource inspector and doc generation task to include action descriptions
in resource action data.
This change permits actions to be defined with the optional new
'description' parameter as follows:
```
action :my_action, description: "my_action changes the state of this world"
...
end
Action description can be looked up using the
`.action_description(action)` method of the resource class. Action
descriptions are inheritable and overridable.
Signed-off-by: Marc A. Paradise <marc.paradise@gmail.com>
Diffstat (limited to 'spec/integration')
-rw-r--r-- | spec/integration/recipes/resource_action_spec.rb | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/spec/integration/recipes/resource_action_spec.rb b/spec/integration/recipes/resource_action_spec.rb index 9bfe86c74e..febac64283 100644 --- a/spec/integration/recipes/resource_action_spec.rb +++ b/spec/integration/recipes/resource_action_spec.rb @@ -223,6 +223,10 @@ module ResourceActionSpec ActionJackson.succeeded = ActionJackson.ruby_block_converged end + action :test1, description: "Original description" do + true + end + def foo_public "foo_public!" end @@ -293,7 +297,12 @@ module ResourceActionSpec ActionJackalope.jackalope_ran = :access_attribute ActionJackalope.succeeded = ActionJackson.succeeded end + + action :test1, description: "An old action with a new description" do + super + end end + before do ActionJackalope.jackalope_ran = nil ActionJackalope.load_current_resource_ran = nil @@ -344,6 +353,11 @@ module ResourceActionSpec expect(ActionJackalope.succeeded).to eq "foo!alope blarghle! bar!alope" end + it "allows overridden action to have a description separate from the action defined in the base resource" do + expect(ActionJackson.action_description(:test1)).to eql "Original description" + expect(ActionJackalope.action_description(:test1)).to eql "An old action with a new description" + end + it "non-overridden actions run and can access overridden and non-overridden variables (but not necessarily new ones)" do converge do action_jackalope "hi" do |