summaryrefslogtreecommitdiff
path: root/spec/unit/application/indirection_base_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-03-12(maint) Fix yet another face spec issue.Peter Huene1-4/+4
Commit 275ac959db060f80e4b8635e1213cc0c2255c732 prevented specs that did 'describe Puppet::Face[...]' from working correctly. That is because the instance returned for the describe call would then differ if face_collection_spec is run before the spec in question. The fix is rather than clearing all face state, save and restore the global state before and after all examples. Also correcting a mistake in indirection_base_spec where a ivar wasn't being used between the before and after clauses.
2014-03-12(maint) Fix face specs to not pollute global state.Peter Huene1-10/+18
The face_collection_base spec attempts to restore global state stored in Puppet::Interface::FaceCollection so that it doesn't interfere with other specs that may use faces. It fails to clear any files required by the autoloader, but clears the @faces member. The result is that if a face is referenced again from another spec, it doesn't get defined and added to @faces and cannot be found. The fix is to clear the state before and after each example. The problem can be observed with the following: rspec spec/unit/interface/face_collection_spec.rb spec/unit/application/face_base_spec.rb Additionally, the indirection_base spec registers a face but does not remove the face after the examples have fun. The fix is to remove the face from the FaceCollection after all examples.
2012-11-21(Maint) Stop changing internals of object during testAndrew Parker1-8/+4
Previously the test depended on the internal implementation of CommandLine (specifically the @args instance var) to control the test. This makes the test very brittle. This changes it to use the public interface of CommandLine.
2012-10-04Revert "Merge pull request #1190 from ↵Jeff McCune1-20/+16
jeffmccune/fix/master/7316_load_faces_from_modulepath_try4" This reverts commit bdda511d06ed6f89b58343e815585957a33db94e, reversing changes made to 8f9699cee0d1028d538b0a26aa5bc885751b6d46. Conflicts: lib/puppet/settings/config_file.rb
2012-09-26Revert "Revert "Merge branch 'fix/3.x/7316_load_faces_from_modulepath_try3' ↵Jeff McCune1-16/+20
into 3.x"" This reverts commit ef3fe695fd0be5ff2b5aeb563f34f62a0f503831.
2012-09-26(Maint) Remove rspec from shebang lineJeff McCune1-1/+1
Without this patch Ruby 1.9 is still complaining loudly about trying to parse the spec files. The previous attempt to clean up this problem in edc3ddf works for Ruby 1.8 but not 1.9. I'd prefer to remove the shebang lines entirely, but doing so will cause encoding errors in Ruby 1.9. This patch strives for a happy middle ground of convincing Ruby it is actually working with Ruby while not confusing it to think it should exec() to rspec. This patch is the result of the following command run against the source tree: find spec -type f -print0 | \ xargs -0 perl -pl -i -e 's,^\#\!\s?/(.*)rspec,\#! /usr/bin/env ruby,'
2012-09-25Revert "Merge branch 'fix/3.x/7316_load_faces_from_modulepath_try3' into 3.x"Andrew Parker1-20/+16
This reverts commit b277bb3874ecd50e1cd6e600bf6d36e3240d5510, reversing changes made to bdf193640701e9a107b1c6f6661499b31fdefb4d. These changes are being backed out because they referenced a undefined methods (`default_global_config_dir` and `default_global_var_dir`). After fixing that locally, there was still a problem with `puppet help` printing out a large number of warnings because it could not load face code correctly. I think we need to step back from this, re-evaluate what is happening, and try a new approach.
2012-09-24Revert "Merge branch 'revert/3.x/faces_from_modulepath' into 3.x"Jeff McCune1-16/+20
This is a "revert-the-revert" commit. This reverts commit 87ea7a8849f90a232f2bb683fb8a2ce1573a21db, reversing changes made to 8dff14b9c5a3cdd99ede63dbcbb2dbe00b457926.
2012-09-21Revert "Merge branch 'fix/3.x/7316_load_faces_from_modulepath' into 3.x"Jeff McCune1-20/+16
Revert the modulepath face loader change set for the following reason: This change set is intended to load faces from the module path. It works great... _if_ you explicitly set --confdir on the command line like I do with my zsh puppet() function. If you don't, then it blows up because the global for the confdir is set by defaults at a different enough point in the code for us to overlook the issue. If we invest in removing global state, specifically Puppet.settings, I think we'll see a very quick return. The confdir setting should be "available" for use at the same point, regardless of where it comes from; defaults, puppet.conf, CLI, or (hopefully) the environment. This reverts commit 8b059a9a9e7c765d3050163ca59abeffe3e297b5, reversing changes made to 7c3b620182602012b191a5b5ade7b1df5cbc8b19.
2012-09-20(#7316) Load applications from the modulepathJeff McCune1-16/+20
Without this patch Puppet does not search the modulepath lib subdirectories for application subcommands. This is a problem because face applications that aren't affected by #3947 should work. This patch fixes the problem by searching through the modules along the modulepath to find available subcommands in addition to those available along the Ruby $LOAD_PATH and RubyGems $GEM_PATH. Both legacy application files and modern face applications are loaded from the modulepath with this patch. This patch does _not_ add the module's `lib/` subdirectory to the $LOAD_PATH, so issue #3947 will still affect face applications that attempt to use `require` with library files inside the module.
2012-07-02(maint) Standardize on /usr/bin/env ruby -S rspecJeff McCune1-1/+1
Without this patch some spec files are using `ruby -S rspec` and others are using `rspec`. We should standardize on a single form of the interpreter used for spec files. `ruby -S rspec` is the best choice because it correctly informs editors such as Vim with Syntastic that the file is a Ruby file rather than an Rspec file.
2012-04-26(#14200) Fix help faceChris Price1-4/+10
This commit does the following: 1. Fix the help face so that--in the case where there exists both an App and a Face by the same name, and the App is not just a stub for the Face--help gives preference to the App instead of the Face. The help face (as a command line tool) is mostly going to be used to help users navigate the other command line tools, so, e.g., "puppet help resource" should show help for the same tool that you will get by running "puppet resource". This was not the case prior to this commit. 2. Get rid of the separation between faces and applications in the help screen... making this distinction seems more confusing than helpful to the users, and exposes implementation details that users should not need to be concerned with. 3. Change all class names for Applications to conform to the convention of "foo_bar" file names mapping to "FooBar" class names.
2011-05-26maint: Fix order dependent spec failure for face indirectionMatt Robinson1-1/+2
An indirected face is being created in spec/unit/application/indirection_base_spec.rb that uses a stubbed out indirection. This stub didn't have a name method defined, which caused the documentation_spec.rb, that does checks against every available face, to blow up with: expected no Exception, got #<NoMethodError: undefined method `to_sym' for nil:NilClass> in lib/puppet/face/indirector/face.rb when listing the indirections for the help text. I toyed with creating a real indirection for the test, but that was harder than expected. Paired-with: Max Martin <max@puppetlabs.com>
2011-05-12(#7469) Add license to test face so tests passMax Martin1-0/+2
The TestIndirection test face defined in indirection_base_spec did not have copyright or license information defined; this was causing order-dependent test failures when unit tests were run before other specs (as in rake spec). This commit adds license and copyright info to the test face to prevent these failures. Paired-with: Daniel Pittman <daniel@puppetlabs.com>
2011-05-02maint: move the indirector face base out of puppet/faceDaniel Pittman1-2/+2
We used to shove the base class Puppet::Face::Indirector next to the actual faces; this made a bunch of things, including testing, confusing. Instead, move it away into the indirector where it lives with the rest of the indirector related things. Reviewed-By: Nick Lewis <nick@puppetlabs.com>
2011-04-28(#7122) Enforce call arity on actions in the CLI wrapper.Daniel Pittman1-1/+2
We had a problem, previously, in the generic translation of command line arguments to Ruby method calls: we could mistake the options, added by the CLI wrapper, for a positional argument to the action method. This was caused by a combination of factors, but primarily that the wrapper methods for actions are designed to present a friendly, helpful Ruby API for internal use. Consequently, they have a default value if you don't wish to pass options. Unfortunately, this meant that the options that the CLI *always* passed could be treated as a positional argument instead, and the default set of options added to the back of the call. To resolve this we now check the number of positional arguments in the CLI wrapper, and raise an exception if they are mismatched. This makes the generic CLI handling do the right thing in adapting the command line arguments to the Ruby API. (As an aside, we would have had a similar-but-different failure mode if we type-checked positional arguments: these calls would have failed with an invalid argument validation error.) Reviewed-By: Max Martin <max@puppetlabs.com>
2011-04-22maint: use the exit_with helper everywhere...Daniel Pittman1-1/+1
Now we have the exit_with matcher, we should use it everywhere that we previously stubbed, expected, or caught the exit status in an ad-hoc way. Reviewed-By: Jesse Wolf <jesse@puppetlabs.com>
2011-04-21Merge remote-tracking branch ↵Daniel Pittman1-0/+1
'remotes/lak/tickets/next/7118-summaries_for_all_faces' into 2.7.x Fix conflicts due to version drift in: lib/puppet/face/certificate.rb lib/puppet/face/facts.rb lib/puppet/face/node.rb lib/puppet/face/secret_agent.rb spec/lib/puppet/face/basetest.rb spec/unit/face/help_spec.rb Reviewed-By: Markus Roberts <markus@puppetlabs.com>
2011-04-15(#7059) Use option hooks for the indirector terminus option.Daniel Pittman1-4/+3
We used to open-code terminus setting, which had a bunch of duplicate code. Now, instead, we use the option hooks, resulting in the same behaviour with much less code. Paired-With: Max Martin <max@puppetlabs.com>
2011-04-14(7118) Adding summaries for all facesLuke Kanies1-0/+1
It's usually just a one-liner, but when I saw an obvious opportunity for longer docs, I've added a @longdocs variable that can be converted to longer forms when ready. Signed-off-by: Luke Kanies <luke@puppetlabs.com>
2011-04-13maint: clean up the spec test headers in bulk.Daniel Pittman1-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.
2011-04-13(#7056) Use 'face' rather than 'faces' in the production code.Daniel Pittman1-3/+3
After some discussion we decided that most uses of the Puppet Face infrastructure were about single faces on their own, not about the collection, and so we were better referring to Puppet::Face[...] in code. This implements that by translating names and references in the Ruby code to the new, s-less, name.
2011-04-12(#6962) Implement 'summary' for faces.Daniel Pittman1-1/+1
This adds the methods to the summary builder and runtime instance to support setting and getting a summary of the face. This is a short description used to summarize the purpose of the face in help output. For example, from the help face: "Displays help about puppet subcommands" Reviewed-By: Matt Robinson <matt@puppetlabs.com>
2011-04-08maint: just require 'spec_helper', thanks rspec2Daniel Pittman1-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>
2011-04-07(#7012) Update references in code to use face(s)Daniel Pittman1-4/+4
The codebase is now using the new name, faces, uniformly to reference the objects contained. All tests pass.
2011-04-04(#6760) set terminus in indirector string base class.Daniel Pittman1-1/+1
We now accept a terminus option to each invocation, and set the terminus based on that call. This is probably incomplete, because it only sets the terminus when given, and doesn't try to reset it to the default afterwards. This also resets the terminus class after every invocation, to stop it leaking state across calls. This make, sadly, have some effects if you are not just using the strings to invoke the terminus, but it beats having the strings broken as well... Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
2011-04-04(#6749) implementing option handling in CLI string wrapperDaniel Pittman1-12/+29
The purpose of this is to adapt the generic option support in our strings to the command line; we adapt the generic option information to optparse, and establish our environment early in the process to ensure that we can play nice with Puppet::Application for the moment. In the process we ensure that we detect, and report, conflicts in option naming across the board. Additionally, when an option is declared with multiple aliases, we insist that either all, or none, of them take an argument. To support this we support introspecting options having an optional argument, as well as documentation and all. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
2011-04-02MAINT: implement a pending test for code we wrote...Daniel Pittman1-1/+11
We had an outstanding pending test for code we wrote, and which we were not actually testing stand-alone. This implements the test for that. Reviewed-By: Pieter van de Bruggen <pieter@puppetlabs.com>
2011-03-28MAINT: the API is officially named "string" as of this moment.Daniel Pittman1-1/+1
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>
2011-02-22Splitting the Application base classLuke Kanies1-0/+12
We now have an indirection_base class along with interface_base. I've also added some basic tests for most of the interfaces. Signed-off-by: Luke Kanies <luke@puppetlabs.com>