diff options
author | Markus Roberts <Markus@reality.com> | 2010-06-24 11:59:27 -0700 |
---|---|---|
committer | Markus Roberts <Markus@reality.com> | 2010-06-24 15:59:11 -0700 |
commit | db44a32695ae2b1249461f187b4b3321c24cfd84 (patch) | |
tree | d5f178f1dc94b5551828546cff02760457f76420 | |
parent | 3bd6f110852fadbc1ef707f0705dc3bc969ce8e4 (diff) | |
download | puppet-db44a32695ae2b1249461f187b4b3321c24cfd84.tar.gz puppet-db44a32695ae2b1249461f187b4b3321c24cfd84.tar.xz puppet-db44a32695ae2b1249461f187b4b3321c24cfd84.zip |
Tweak for fix for #1175 to fix test failures
Tests that weren't managing the environment but were still expecting to have
functions defined in it were appalled when the functions/environments binding
actually started working. This patch fixes those tests.
-rw-r--r-- | lib/puppet/parser/scope.rb | 2 | ||||
-rwxr-xr-x | spec/unit/parser/scope_spec.rb | 2 | ||||
-rwxr-xr-x | test/language/functions.rb | 6 |
3 files changed, 7 insertions, 3 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb index bb548dd47..39317a729 100644 --- a/lib/puppet/parser/scope.rb +++ b/lib/puppet/parser/scope.rb @@ -497,6 +497,6 @@ class Puppet::Parser::Scope def extend_with_functions_module extend Puppet::Parser::Functions.environment_module(Puppet::Node::Environment.root) - extend Puppet::Parser::Functions.environment_module(compiler ? environment : nil ) + extend Puppet::Parser::Functions.environment_module(compiler ? environment : nil) end end diff --git a/spec/unit/parser/scope_spec.rb b/spec/unit/parser/scope_spec.rb index b665ebdb8..37cf4bd8d 100755 --- a/spec/unit/parser/scope_spec.rb +++ b/spec/unit/parser/scope_spec.rb @@ -70,6 +70,8 @@ describe Puppet::Parser::Scope 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().metaclass.ancestors.should be_include(mod) end end diff --git a/test/language/functions.rb b/test/language/functions.rb index 8797a4644..5463cf256 100755 --- a/test/language/functions.rb +++ b/test/language/functions.rb @@ -12,6 +12,7 @@ class TestLangFunctions < Test::Unit::TestCase include PuppetTest::ParserTesting include PuppetTest::ResourceTesting def test_functions + Puppet::Node::Environment.stubs(:current).returns nil assert_nothing_raised do Puppet::Parser::AST::Function.new( :name => "fakefunction", @@ -370,14 +371,14 @@ class TestLangFunctions < Test::Unit::TestCase end } } - + Puppet::Node::Environment.stubs(:current).returns nil obj = nil assert_nothing_raised { obj = Puppet::Parser::Functions.function(:autofunc) } assert(obj, "Did not autoload function") - assert(Puppet::Parser::Scope.method_defined?(:function_autofunc), + assert(Puppet::Parser::Functions.environment_module.method_defined?(:function_autofunc), "Did not set function correctly") end @@ -465,6 +466,7 @@ class TestLangFunctions < Test::Unit::TestCase assert_equal("yay\n", %x{#{command}}, "command did not work") assert_equal("yay-foo\n", %x{#{command} foo}, "command did not work") + Puppet::Node::Environment.stubs(:current).returns nil generate = Puppet::Parser::Functions.function(:generate) scope = mkscope |