[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Matt Robinson
matt at puppetlabs.com
Tue May 10 08:09:18 UTC 2011
The following commit has been merged in the experimental branch:
commit 29f3dda2aaa4a6225baaa5819ebad32909b01f93
Author: Matt Robinson <matt at puppetlabs.com>
Date: Mon Mar 28 21:35:34 2011 -0700
(#6830) Fix overly stubbed tests
In Ruby 1.9 calling .each on a stub calls to_a, and if you're not
stubbing to_a you get:
unexpected invocation: #<Mock:option1>.to_a()
Could have stubbed to_a also, but less stubbing is better in these cases
Reviewed-by: Jesse Wolfe <jesse at puppetlabs.com>
diff --git a/spec/unit/parser/ast/casestatement_spec.rb b/spec/unit/parser/ast/casestatement_spec.rb
index a77c04c..bce3ad8 100755
--- a/spec/unit/parser/ast/casestatement_spec.rb
+++ b/spec/unit/parser/ast/casestatement_spec.rb
@@ -13,11 +13,14 @@ describe Puppet::Parser::AST::CaseStatement do
@test = stub 'test'
@test.stubs(:safeevaluate).with(@scope).returns("value")
- @option1 = stub 'option1', :eachopt => nil, :default? => false
- @option2 = stub 'option2', :eachopt => nil, :default? => false
+ @option1 = Puppet::Parser::AST::CaseOpt.new({})
+ @option1.stubs(:eachopt)
+ @option1.stubs(:default?).returns false
+ @option2 = Puppet::Parser::AST::CaseOpt.new({})
+ @option2.stubs(:eachopt)
+ @option2.stubs(:default?).returns false
- @options = stub 'options'
- @options.stubs(:each).multiple_yields(@option1, @option2)
+ @options = Puppet::Parser::AST::ASTArray.new(:children => [@option1, @option2])
@casestmt = Puppet::Parser::AST::CaseStatement.new :test => @test, :options => @options
end
@@ -29,8 +32,6 @@ describe Puppet::Parser::AST::CaseStatement do
end
it "should scan each option" do
- @options.expects(:each).multiple_yields(@option1, @option2)
-
@casestmt.evaluate(@scope)
end
@@ -137,12 +138,15 @@ describe Puppet::Parser::AST::CaseStatement do
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))
+ 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"))
+ options << AST::CaseOpt.new(
+ :value => AST::Default.new(:value => "default"),
+ :statements => AST::Leaf.new(:value => "default")
+ )
ast = nil
param = AST::Variable.new(:value => "testparam")
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list