summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
authorBrice Figureau <brice-puppet@daysofwonder.com>2009-09-23 20:22:44 +0200
committerBrice Figureau <brice-puppet@daysofwonder.com>2009-09-23 20:22:44 +0200
commitbfba2cdf8787f1e7fa778bba1b74c03fc06634cd (patch)
tree425a262318df622d213a29730df5d887da722496 /spec/unit/parser
parentdb67e5fd4e2241f59341c38c5a1e291e68aec523 (diff)
downloadpuppet-bfba2cdf8787f1e7fa778bba1b74c03fc06634cd.tar.gz
puppet-bfba2cdf8787f1e7fa778bba1b74c03fc06634cd.tar.xz
puppet-bfba2cdf8787f1e7fa778bba1b74c03fc06634cd.zip
Fix #2672 - Make sure nodenames keep their underscores when used as classname
The #2627 fix was modifying nodename in case of string nodename, but was removing '_'. Since underscores is a valid character in a class name, we now allow it. Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/ast/leaf.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb
index 69b704ad8..e9681503d 100755
--- a/spec/unit/parser/ast/leaf.rb
+++ b/spec/unit/parser/ast/leaf.rb
@@ -195,6 +195,16 @@ describe Puppet::Parser::AST::HostName do
host.to_classname.should == "klassname"
end
+ it "should preserve '_' in to_classname with a string nodename" do
+ host = Puppet::Parser::AST::HostName.new( :value => "node_with_underscore")
+ host.to_classname.should == "node_with_underscore"
+ end
+
+ it "should preserve '_' in to_classname with a regex nodename" do
+ host = Puppet::Parser::AST::HostName.new( :value => Puppet::Parser::AST::Regex.new(:value => "/\dnode_with_underscore\.+/") )
+ host.to_classname.should == "dnode_with_underscore."
+ end
+
it "should return a string usable as classname when calling to_classname" do
host = Puppet::Parser::AST::HostName.new( :value => Puppet::Parser::AST::Regex.new(:value => "/^this-is not@a classname$/") )
host.to_classname.should == "this-isnotaclassname"