summaryrefslogtreecommitdiff
path: root/spec/unit/context_spec.rb
AgeCommit message (Collapse)AuthorFilesLines
2014-05-16(PUP-2610) Maintain context during application exitAndrew Parker1-0/+39
Because of the way rack servers get configured by puppet, the application system needs to maintain any context information that is setup while starting even after the application has exited. This is because the rack app is created by calling the "master" application and using the return value (which threads all the way back through the application and command line layers) as the rack app. When the contexts were removed on the way out of the application they also removed the setup for how environments were loaded. This also required that there be a way of undoing a series of context pushes without knowing how many had been done. For this there is now a mark and rollback capability in the Puppet::Context system. This is used in the tests to always return to the context that was present at the start of every test.
2014-04-17(maint) Make context handle lazy initializationHenrik Lindberg1-0/+23
This makes it possible to store a Proc in the context. On lookup the Proc is called and the result is memoized for subseqent lookups.
2014-01-23(PUP-1118) Simplify Puppet::ContextAndrew Parker1-4/+0
Puppet::Context can reduce the number of objects that it uses for tracking contexts by keeping everything internal to it. This actually results in much less code, but a few more instance variables to track. Overall is seems like an easier to understand system.
2014-01-17(PUP-1118) Remove use of Environment.currentAndrew Parker1-26/+19
One does not simply change the current environment! This replaces use of Environment.current= and Environment.current with Puppet::Context.lookup(:current_environment). This uncovered a lot of assumptions about what the current environment is at various times, such as during startup before initialization. There is now a "bootstrap" context that is setup as soon as possible which provides a basic setup, once initialization occures this is overridden with another context that is able to do more.
2014-01-16(PUP-1118) Provide context at initialization for environmentsAndrew Parker1-3/+2
When puppet is initialized it now also sets up a environments service so that other parts of the code and go about their merry way. This also changes the handling of component to work the same way as other types so that an extra, and confusing, require isn't needed.
2014-01-02(PUP-672) Fail fast if pop root of Context stackJosh Partlow1-2/+4
Rather than silently accept a root pop and return the root binding, fail fast with a StackUnderflow exception if attempt to pop the root of Puppet::Context.
2014-01-02(PUP-672) Puppet::Context is immutable.Josh Partlow1-52/+58
Previous implementation exposed a bind method allowing you to add bindings to the current context. This method has been removed. Now every context is generated only once, either from an initial push or override, both of which require a hash of bindings which are merged into the parent's binding state.
2013-12-27(PUP-672) Add defaults for context lookupsAndrew Parker1-0/+4
Before it wasn't possible to get a value from the context that might not have the requested binding. This adds the ability to provide a default in the case where there is no finding for the name.
2013-12-27(PUP-672) Add nested context capabilitiesAndrew Parker1-0/+74
A major problem in puppet is keeping track of contextual information. The Puppet::Indirector::Request attempts to do this, but it isn't able to pass that information between indirector requests. This adds a global context system, where once a value is set it cannot be changed, but a subcontext can be created.