summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser/ast/node.rb
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-07-28 19:37:11 +0200
committerJames Turnbull <james@lovedthanlost.net>2009-08-01 11:15:29 +1000
commitb45ccf8d38a10d3f5226cbabe494240901e4e383 (patch)
tree9e5e8bbbd88ce7f66dc5a42c6aa7c2c6c57e7b4e /spec/unit/parser/ast/node.rb
parent58a73b5c68485dc5d41a46936c31e5fad5f037b5 (diff)
downloadpuppet-b45ccf8d38a10d3f5226cbabe494240901e4e383.tar.gz
puppet-b45ccf8d38a10d3f5226cbabe494240901e4e383.tar.xz
puppet-b45ccf8d38a10d3f5226cbabe494240901e4e383.zip
Implement node matching with regexes
This patch enhance AST::HostName to support regexes, and modifies the parser to allow regex to be used as node name. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>]
Diffstat (limited to 'spec/unit/parser/ast/node.rb')
-rwxr-xr-xspec/unit/parser/ast/node.rb20
1 files changed, 20 insertions, 0 deletions
diff --git a/spec/unit/parser/ast/node.rb b/spec/unit/parser/ast/node.rb
index aaba4c2e8..5a4a5efe4 100755
--- a/spec/unit/parser/ast/node.rb
+++ b/spec/unit/parser/ast/node.rb
@@ -12,6 +12,26 @@ describe Puppet::Parser::AST::Node do
@scope = @compiler.topscope
end
+ describe "when calling get_classname" do
+ it "should return current node name if name is a Regex" do
+ name = stub 'name', :regex? => true
+ node = @parser.newnode("node").shift
+ node.stubs(:name).returns(name)
+
+ @scope.expects(:host).returns("testnode")
+
+ node.get_classname(@scope).should == "testnode"
+ end
+
+ it "should return the current node classname if name is not a Regex" do
+ name = stub 'name', :regex? => false
+ node = @parser.newnode("node").shift
+ node.stubs(:name).returns(name)
+
+ node.get_classname(@scope).should == "node"
+ end
+ end
+
describe Puppet::Parser::AST::Node, "when evaluating" do
before do