summaryrefslogtreecommitdiffstats
path: root/spec/unit/parser
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/parser')
-rwxr-xr-xspec/unit/parser/ast/casestatement.rb38
-rwxr-xr-xspec/unit/parser/ast/leaf.rb4
-rwxr-xr-xspec/unit/parser/ast/selector.rb16
3 files changed, 33 insertions, 25 deletions
diff --git a/spec/unit/parser/ast/casestatement.rb b/spec/unit/parser/ast/casestatement.rb
index 657648e9d..c2e9a6929 100755
--- a/spec/unit/parser/ast/casestatement.rb
+++ b/spec/unit/parser/ast/casestatement.rb
@@ -57,13 +57,6 @@ describe Puppet::Parser::AST::CaseStatement do
@casestmt.evaluate(@scope)
end
- it "should evaluate_match with sensitive parameter" do
- Puppet.stubs(:[]).with(:casesensitive).returns(true)
- @opval1.expects(:evaluate_match).with { |*arg| arg[2][:sensitive] == true }
-
- @casestmt.evaluate(@scope)
- end
-
it "should return the first matching evaluated option" do
@opval2.stubs(:evaluate_match).with { |*arg| arg[0] == "value" }.returns(true)
@option2.stubs(:safeevaluate).with(@scope).returns(:result)
@@ -130,4 +123,35 @@ describe Puppet::Parser::AST::CaseStatement do
end
end
+
+ it "should match if any of the provided options evaluate as true" do
+ ast = nil
+ AST = Puppet::Parser::AST
+
+ tests = {
+ "one" => %w{a b c},
+ "two" => %w{e f g}
+ }
+ options = tests.collect do |result, values|
+ values = values.collect { |v| AST::Leaf.new :value => v }
+ AST::CaseOpt.new(:value => AST::ASTArray.new(:children => values),
+ :statements => AST::Leaf.new(:value => result))
+ end
+ options << AST::CaseOpt.new(:value => AST::Default.new(:value => "default"),
+ :statements => AST::Leaf.new(:value => "default"))
+
+ ast = nil
+ param = AST::Variable.new(:value => "testparam")
+ ast = AST::CaseStatement.new(:test => param, :options => options)
+
+ tests.each do |should, values|
+ values.each do |value|
+ @scope = Puppet::Parser::Scope.new()
+ @scope.setvar("testparam", value)
+ result = ast.evaluate(@scope)
+
+ result.should == should
+ end
+ end
+ end
end
diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb
index 2bb374702..d5534debb 100755
--- a/spec/unit/parser/ast/leaf.rb
+++ b/spec/unit/parser/ast/leaf.rb
@@ -32,7 +32,7 @@ describe Puppet::Parser::AST::Leaf do
@leaf.stubs(:safeevaluate).with(@scope).returns(@value)
@value.expects(:downcase).returns("value")
- @leaf.evaluate_match("value", @scope, :sensitive => true)
+ @leaf.evaluate_match("value", @scope)
end
it "should match undef if value is an empty string" do
@@ -45,7 +45,7 @@ describe Puppet::Parser::AST::Leaf do
parameter = stub 'parameter'
parameter.expects(:downcase).returns("value")
- @leaf.evaluate_match(parameter, @scope, :sensitive => true)
+ @leaf.evaluate_match(parameter, @scope)
end
end
diff --git a/spec/unit/parser/ast/selector.rb b/spec/unit/parser/ast/selector.rb
index f9a1efe6c..23989b902 100755
--- a/spec/unit/parser/ast/selector.rb
+++ b/spec/unit/parser/ast/selector.rb
@@ -86,22 +86,6 @@ describe Puppet::Parser::AST::Selector do
@selector.evaluate(@scope)
end
- it "should transmit the sensitive parameter to evaluate_match" do
- Puppet.stubs(:[]).with(:casesensitive).returns(:sensitive)
- @param1.expects(:evaluate_match).with { |*arg| arg[2][:sensitive] == :sensitive }
-
- @selector.evaluate(@scope)
- end
-
- it "should transmit the AST file and line to evaluate_match" do
- @selector.file = :file
- @selector.line = :line
- @param1.expects(:evaluate_match).with { |*arg| arg[2][:file] == :file and arg[2][:line] == :line }
-
- @selector.evaluate(@scope)
- end
-
-
it "should evaluate the matching param" do
@param1.stubs(:evaluate_match).with { |*arg| arg[0] == "value" and arg[1] == @scope }.returns(true)