diff options
Diffstat (limited to 'spec/unit/parser/ast/leaf.rb')
| -rwxr-xr-x | spec/unit/parser/ast/leaf.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb index c9593b967..6215f6345 100755 --- a/spec/unit/parser/ast/leaf.rb +++ b/spec/unit/parser/ast/leaf.rb @@ -200,6 +200,11 @@ describe Puppet::Parser::AST::HostName do host.to_classname.should == "this-isnotaclassname" end + it "should delegate 'match' to the underlying value if it is an HostName" do + @value.expects(:match).with("value") + @host.match("value") + end + it "should delegate eql? to the underlying value if it is an HostName" do @value.expects(:eql?).with("value") @host.eql?("value") @@ -220,4 +225,37 @@ describe Puppet::Parser::AST::HostName do @value.expects(:is_a?).with(Puppet::Parser::AST::Regex).returns(true) @host.regex?.should be_true end + + it "should return the results of comparing the regexes if asked whether a regex matches another regex" do + hosts = [1,2].collect do |num| + vreg = /vreg#{num}/ + value = Puppet::Parser::AST::Regex.new(:value => vreg) + Puppet::Parser::AST::HostName.new(:value => value) + end + + hosts[0].match(hosts[1]).should be_false + hosts[0].match(hosts[0]).should be_true + end + + it "should return false when comparing a non-regex to a regex" do + vreg = /vreg/ + value = Puppet::Parser::AST::Regex.new(:value => vreg) + regex = Puppet::Parser::AST::HostName.new(:value => value) + + value = Puppet::Parser::AST::Regex.new(:value => "foo") + normal = Puppet::Parser::AST::HostName.new(:value => value) + + normal.match(regex).should be_false + end + + it "should true when a provided string matches a regex" do + vreg = /r/ + value = Puppet::Parser::AST::Regex.new(:value => vreg) + regex = Puppet::Parser::AST::HostName.new(:value => value) + + value = Puppet::Parser::AST::Leaf.new(:value => "bar") + normal = Puppet::Parser::AST::HostName.new(:value => value) + + regex.match(normal).should be_true + end end |
