summaryrefslogtreecommitdiffstats
path: root/spec/unit/interface/action_builder_spec.rb
Commit message (Collapse)AuthorAgeFilesLines
* (#7507) Fix when_invoked action specs in Ruby 1.9Matt Robinson2011-05-171-21/+21
| | | | | | | | Ruby 1.9 is strict about argument arity for methods that are metaprogrammatically defined. A ton of specs that were setting up when_invoked didn't pass options even though they should have been. Reviewed-by: Daniel Pittman <daniel@puppetlabs.com>
* (#7353) Remove :for_humans format entirely.Daniel Pittman2011-05-051-10/+0
| | | | | | | Since we never shipped this in a real release, we don't need to maintain compatibility. So, remove it entirely from the codebase. Reviewed-By: Max Martin <max@puppetlabs.com>
* (#7353) Note the :for_humans compatibility issue.Daniel Pittman2011-05-041-0/+2
| | | | | | | | Where we need special support for :for_humans as an alias for :console, call it out in comments. This makes it clear to someone who wonders why what the actual underlying purpose of the whole thing is. Reviewed-By: Jacob Helwig <jacob@puppetlabs.com>
* (#7282) action without `when_invoked` should fail...Daniel Pittman2011-05-021-4/+33
| | | | | | | | | | | | | | We used to let actions be declared without the `when_invoked` block, which was usually a sign of either someone writing their method code direct in action declaration, or someone forgetting to add their code at all. This was just let silently by: the error only showed up when you finally tried to invoke the action, and a NoMethod error was raised by the face. ...except for our own testing. We took advantage of this a whole pile of times in there; fixing the original UI issue means fixing all those too. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
* (#7013) Handle rendering modes out in the application layer.Daniel Pittman2011-04-191-2/+2
| | | | | | | | | | | We no longer establish the rendering mode in the actions; they just default to "nothing", and let that flow on out to the application layer. That lets the facade we put before the face determine the default behaviour. This is mostly a no-op down in the CLI side, but it makes it much easier to integrate into MCollective, HTTP-API, and for other non-CLI users of Faces. Reviewed-By: Max Martin <max@puppetlabs.com>
* (#7013) Return bound methods for when_rendering hooks.Daniel Pittman2011-04-191-3/+10
| | | | | | | | We can return a method bound to the current face instance when we access the 'when_rendering' hook, which allows us to directly call them. Make that change, and add appropriate testing. Reviewed-By: Max Martin <max@puppetlabs.com>
* (#7013) Support 'when_rendering' and 'render_as' in actions.Daniel Pittman2011-04-191-45/+149
| | | | | | | | | | | These define the API used by folks writing actions that supports their rendering hooks. 'when_rendering' defines a helper method on the interface, which runs the users code in their expected context. 'render_as' just sets the default rendering format; by default this is :for_humans. Reviewed-By: Max Martin <max@puppetlabs.com>
* maint: make sure we don't ever default to being default...Daniel Pittman2011-04-191-1/+6
| | | | | | | We tested that we could make something a default action, but we also want to assert that we never accidentally make everything the default action. Paired-With: Max Martin <max@puppetlabs.com>
* (#7013) Add support for required options.Pieter van de Bruggen2011-04-171-5/+1
| | | | | | | | This adds another hook into the generated wrapper, which invokes a method to validate arguments. This is used to raise an exception when required options have not been passed to the method. Reviewed-By: Daniel Pittman <daniel@puppetlabs.com>
* Merge branch ↵Daniel Pittman2011-04-151-4/+5
|\ | | | | | | 'feature/2.7.x/6978-face-and-action-options-should-have-hooks-for-various-actions' into 2.7.x
| * (#6978) Add before and after decorators to actions from options.Daniel Pittman2011-04-151-4/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Options can now add before_action and after_action blocks; these are invoked before or after any action is invoked on the face. This allows these options to declare common behaviour and have it automatically applied to the actions invoked. Option hooks have no defined order of invocation: they will run in a completely random order. Where there are dependencies they should be on the value of the options hash passed to the invocation, not on side-effects of the other invocations. You are not able to influence the arguments, options, or calling of the action body in a before or after decorator. This is by design. The invocation passes to the hook: 1. The action object representing this action. 2. The arguments to the action, as an array. 3. The options for the action, as a hash. Paired-With: Max Martin <max@puppetlabs.com>
* | (#7115) Enable default actions.Pieter van de Bruggen2011-04-151-0/+11
|/ | | | | | | This also enables the 'help' action on the 'help' face to serve as a default action. Reviewed-By: Daniel Pittman Reviewed-By: Nick Lewis
* maint: clean up the spec test headers in bulk.Daniel Pittman2011-04-131-2/+1
| | | | | | | We now use a shebang of: #!/usr/bin/env rspec This enables the direct execution of spec tests again, which was lost earlier during the transition to more directly using the rspec2 runtime environment.
* (#6962) Implement 'summary' for actions.Daniel Pittman2011-04-121-0/+11
| | | | | | | This extends the summary function down through the actions themselves, allowing us to display a useful summary to the user. Reviewed-By: Matt Robinson <matt@puppetlabs.com>
* maint: just require 'spec_helper', thanks rspec2Daniel Pittman2011-04-081-1/+1
| | | | | | | | | | | rspec2 automatically sets a bunch of load-path stuff we were by hand, so we can just stop. As a side-effect we can now avoid a whole pile of stupid things to try and include the spec_helper.rb file... ...and then we can stop protecting spec_helper from evaluating twice, since we now require it with a consistent name. Yay. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
* (#7012) Split plumbing into Puppet::InterfaceDaniel Pittman2011-04-071-0/+59
| | | | | | | | | This splits out the plumbing into the Puppet::Interface namespace, and uses Puppet::Faces for all the public-facing code. The fault line is "what you care about if you are using or writing a face", which is public, against "what you care about to enable either of those two", which is the plumbing.
* MAINT: the API is officially named "string" as of this moment.Daniel Pittman2011-03-281-30/+0
| | | | | | | Now that we have settled on the final public name for the API, "Puppet::String", mass-rename and mass-edit all the files to follow. Reviewed-By: Randall Hansen <randall@puppetlabs.com>
* (#6770) Refactor Puppet::Interface#initialize.Pieter van de Bruggen2011-03-251-1/+1
| | | | | | | | | P::I#initialize now takes a name and a version (and an optional block). The options hash has been removed, though it may be reintroduced if a legitimate use case can be made for it (so far, it's only been used for the version number). Reviewed-By: Jacob Helwig
* (#6770) Changing versioning to semver.Pieter van de Bruggen2011-03-231-1/+1
| | | | | | More information about the versioning scheme can be found at http://semver.org. Paired-With: Nick Lewis
* (#6770) Add basic versioning for interfaces.Pieter van de Bruggen2011-03-231-1/+1
| | | | Reviewed-By: Nick Lewis
* (#6814) Create a dedicated Action classNick Lewis2011-03-221-0/+30
This class will represents an action, and allows us to store metadata for an action, and programmatically introspect and invoke them. A helper class ActionBuilder represents the DSL for defining an action. Also defined an "invoke" DSL method to handle the functionality of defining the method for an action. Reviewed-By: Daniel Pittman