diff options
| author | Luke Kanies <luke@puppetlabs.com> | 2011-06-08 18:55:10 -0700 |
|---|---|---|
| committer | Luke Kanies <luke@puppetlabs.com> | 2011-07-15 11:52:03 -0700 |
| commit | 06e86e40bbb173fa24a7d1c2ecf4e54e1748de67 (patch) | |
| tree | a62ea123336f6f5298df16f97d0ec252648b9e07 /spec/unit/parser | |
| parent | 0d2e0672eb516a1b1f2ced6b8c74bd2064dd205e (diff) | |
| download | puppet-06e86e40bbb173fa24a7d1c2ecf4e54e1748de67.tar.gz puppet-06e86e40bbb173fa24a7d1c2ecf4e54e1748de67.tar.xz puppet-06e86e40bbb173fa24a7d1c2ecf4e54e1748de67.zip | |
Adding default environment to Scope
We were previously not defaulting to an environment,
which is silly given that there's always a default. It
just made setup code harder. We now default to the default
environment.
This makes further testing involving scopes much easier.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'spec/unit/parser')
| -rwxr-xr-x | spec/unit/parser/scope_spec.rb | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb index cd34df065..e08180020 100755 --- a/spec/unit/parser/scope_spec.rb +++ b/spec/unit/parser/scope_spec.rb @@ -47,6 +47,10 @@ describe Puppet::Parser::Scope do scope = Puppet::Parser::Scope.new :compiler => compiler scope.environment.should equal(env) end + + it "should use the default environment if none is available" do + Puppet::Parser::Scope.new.environment.should equal(Puppet::Node::Environment.new) + end it "should use the resource type collection helper to find its known resource types" do Puppet::Parser::Scope.ancestors.should include(Puppet::Resource::TypeCollectionHelper) @@ -55,22 +59,18 @@ describe Puppet::Parser::Scope do describe "when initializing" do it "should extend itself with its environment's Functions module as well as the default" do env = Puppet::Node::Environment.new("myenv") + root = Puppet::Node::Environment.root compiler = stub 'compiler', :environment => env - mod = Module.new - root_mod = Module.new - Puppet::Parser::Functions.expects(:environment_module).with(Puppet::Node::Environment.root).returns root_mod - Puppet::Parser::Functions.expects(:environment_module).with(env).returns mod - Puppet::Parser::Scope.new(:compiler => compiler).singleton_class.ancestors.should be_include(mod) + scope = Puppet::Parser::Scope.new(:compiler => compiler) + scope.singleton_class.ancestors.should be_include(Puppet::Parser::Functions.environment_module(env)) + scope.singleton_class.ancestors.should be_include(Puppet::Parser::Functions.environment_module(root)) end - it "should extend itself with the default Functions module if it has no environment" do - mod = Module.new - Puppet::Parser::Functions.expects(:environment_module).with(Puppet::Node::Environment.root).returns(mod) - - Puppet::Parser::Functions.expects(:environment_module).with(nil).returns mod - - Puppet::Parser::Scope.new.singleton_class.ancestors.should be_include(mod) + it "should extend itself with the default Functions module if its environment is the default" do + root = Puppet::Node::Environment.root + scope = Puppet::Parser::Scope.new + scope.singleton_class.ancestors.should be_include(Puppet::Parser::Functions.environment_module(root)) end it "should remember if it is dynamic" do |
