4 describe "the is_domain_name function" do
6 Puppet::Parser::Functions.autoloader.loadall
10 @scope = Puppet::Parser::Scope.new
14 Puppet::Parser::Functions.function("is_domain_name").should == "function_is_domain_name"
17 it "should raise a ParseError if there is less than 1 arguments" do
18 lambda { @scope.function_is_domain_name([]) }.should( raise_error(Puppet::ParseError))
21 it "should return true if a valid domain name" do
22 result = @scope.function_is_domain_name(["foo.bar.com"])
23 result.should(be_true)
26 it "should allow domain parts to start with numbers" do
27 result = @scope.function_is_domain_name(["3foo.2bar.com"])
28 result.should(be_true)
31 it "should allow domain to end with a dot" do
32 result = @scope.function_is_domain_name(["3foo.2bar.com."])
33 result.should(be_true)
36 it "should allow a single part domain" do
37 result = @scope.function_is_domain_name(["orange"])
38 result.should(be_true)
41 it "should return false if domain parts start with hyphens" do
42 result = @scope.function_is_domain_name(["-3foo.2bar.com"])
43 result.should(be_false)
46 it "should return true if domain contains hyphens" do
47 result = @scope.function_is_domain_name(["3foo-bar.2bar-fuzz.com"])
48 result.should(be_true)
51 it "should return false if domain name contains spaces" do
52 result = @scope.function_is_domain_name(["not valid"])
53 result.should(be_false)