[rspec-users] more verbosity for be_an?

Andrew Premdas apremdas at gmail.com
Sun Jan 3 16:29:29 EST 2010

2010/1/3 rogerdpack <rogerdpack at gmail.com>

> > > The very first test I thought up was "this method should return an
> > > integer" so kind of a basic test for a not yet existent method.
> >
> > Isn't this a bit anti-ruby though. Surely the things we should be testing
> is
> > that the object exists, responds to certain messages and gives certain
> > values back for those messages. Thinking about types is so Java, C++ :-)
> Yeah, though it's a bit hard when it's supposed to return the pid of
> some external process :)
Well your pid could be a string or an integer, or even some  a bizarre
proprietary un-docomented PID construct from planet foo . But as far as Ruby
is concerned you'll be getting back an object thats for sure, and anything
else is completely up in the air. However as soon as you start specifying
that a Fixnum should be returned, then you've removed the possibility of
receiving a string or a bizarre proprietary un-docomented PID construct from
planet foo. This is very anti-ruby (its a dynamic language). And it means
that your method will have to do all sorts of type conversion rubbish to go
from String, 'construct to Fixnum to pass your test.

In ruby all your interested in is that you get something that responds to
to_s (to_i) and gives you a suitable value

> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20100103/4c3fb91a/attachment.html>

More information about the rspec-users mailing list