On Mon, 2008-09-29 at 13:09 -0500, Luke Kanies wrote:
> On Sep 27, 2008, at 4:21 AM, Brice Figureau wrote:
> > +
> > + it "should return 3 for 1 + 2" do
> > + operator =
> > Puppet::Parser::AST::ArithmeticOperator.new :lval => @one, :operator
> > => "+", :rval => @two
> > + operator.evaluate(@scope).should == 3
> > + end
>
> It *might* be better here to just test that the appropriate methods
> are called on the numbers, rather than test the outcome. Not that the
> outcome is likely to change, mind you, but our real test is that we're
> passing through to someone else, not that a specific number shows up.
Unfortunately the following doesn't work:
it "should return 3 for 1 + 2" do
operator = AST::ArithmeticOperator.new :lval => @one, :operator => "+",
:rval => @two
1.expects(:+).with(3)
operator.evaluate(@scope)
end
It doesn't seem possible to pose expectations on Fixnums.
I tried every possible ways, like:
Fixnum.expects(:+)
or (since that's really send that is called)
1.expects(:send)
or
Fixnum.expects(:send)
The error message is:
"no virtual class for Fixnum"
I already had the issue with the comparison operators, that I solved with:
operator.evaluate(@scope).should == 1.send(op,2)
which doesn't really mean the same thing.
I understand that we can't define singleton method on Fixnums because
there is no virtual class. This renders the whole expectation stuff moot
for expecting actions on numbers :-(
If someone has a workaround, please help me :-)
--
Brice Figureau <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---