diff options
| author | Luke Kanies <luke@madstop.com> | 2009-09-01 00:12:07 -0700 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2009-09-01 00:12:07 -0700 |
| commit | 6750aeb90a4d19a2cd1de3ff007f216d31c4e65d (patch) | |
| tree | b2afd8bf2bf30f7ec3c084f995c7b2df6eebc0fa /spec | |
| parent | b728b931e5914cfeaf3d072fb77870e9a8ecf6cd (diff) | |
| download | puppet-6750aeb90a4d19a2cd1de3ff007f216d31c4e65d.tar.gz puppet-6750aeb90a4d19a2cd1de3ff007f216d31c4e65d.tar.xz puppet-6750aeb90a4d19a2cd1de3ff007f216d31c4e65d.zip | |
Fixing #2563 - multiple regex nodes now work together
The problem was that we were needing to convert
one of the regexes to a string, which wasn't working well.
This adds specific rules for how regexes vs. strings
get compared.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'spec')
| -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 |
