Skip to content

Instantly share code, notes, and snippets.

@lak
Created July 5, 2011 19:12
Show Gist options
  • Save lak/1065612 to your computer and use it in GitHub Desktop.
Save lak/1065612 to your computer and use it in GitHub Desktop.
luke@syringe $ rspec spec/unit/parser/scope_spec.rb spec/unit/parser/functions/versioncmp_spec.rb
...............................................................................FFF
Failures:
1) the versioncmp function should raise a ParseError if there is less than 2 arguments
Failure/Error: lambda { @scope.function_versioncmp(["1.2"]) }.should raise_error(Puppet::ParseError)
expected Puppet::ParseError, got #<NoMethodError: undefined method `function_versioncmp' for #<Puppet::Parser::Scope:0x102008e50>>
# ./spec/unit/parser/functions/versioncmp_spec.rb:18
2) the versioncmp function should raise a ParseError if there is more than 2 arguments
Failure/Error: lambda { @scope.function_versioncmp(["1.2", "2.4.5", "3.5.6"]) }.should raise_error(Puppet::ParseError)
expected Puppet::ParseError, got #<NoMethodError: undefined method `function_versioncmp' for #<Puppet::Parser::Scope:0x1020018a8>>
# ./spec/unit/parser/functions/versioncmp_spec.rb:22
3) the versioncmp function should call Puppet::Util::Package.versioncmp (included in scope)
Failure/Error: @scope.function_versioncmp(["1.2", "1.3"])
NoMethodError:
undefined method `function_versioncmp' for #<Puppet::Parser::Scope:0x101ffb3e0>
# ./spec/unit/parser/functions/versioncmp_spec.rb:28
Finished in 0.27247 seconds
82 examples, 3 failures
[refactor/master/8232-array_indexers_on_scope ~/puppet]
luke@syringe $
@lak
Copy link
Author

lak commented Jul 5, 2011

diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index e19ac12..683450b 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -29,8 +29,9 @@ module Puppet::Parser::Functions
Environment = Puppet::Node::Environment

def self.environment_module(env = nil)

  • p @modules.keys
    @modules.synchronize {
  •  @modules[ env || Environment.current || Environment.root ] ||= Module.new
    
  •  @modules[ (env || Environment.current || Environment.root).name ] ||= Module.new
    
    }
    end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment