[Rspec-devel] Skeleton Generator

David Astels dastels at daveastels.com
Fri Aug 11 20:42:42 EDT 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


On 11-Aug-06, at 8:30 PM, Judson Lester wrote:

>>
> Perhaps there's a philosophical point I'm missing, and it would  
> probably
> be enlightening to me (and maybe others) if you could show me where  
> I'm
> going wrong.  Let me make an example:
>
> I write the following:
>
> context "A fresh pack of cards" do
>   setup do
>     @deck = Deck.new(52)
>   end
>   specify "should be shuffleable" do
>     @deck.shuffle
>   end
> end

First of all, this makes no statement about behaviour.  All that it  
is doing is sending the "shuffle" message to @deck.  No behaviour is  
being specified.  What is the result or side-effect of Deck.shuffle?

Also, nothing is said about the purpose/meaning/value of the argument  
to Deck.new.  What happens for Deck.new(0)?  Deck.new(104)?

>
> And the following is generated:
>
> class Deck
>   def initialize(number)
>   end
>
>   def shuffle
>   end
> end
>
> Now I can review the generated code, and then add specify blocks to my
> spec file in order  to drive development.
>
> What purpose does this defeat?

There is no failing specification/example/test/anything, therefore  
there should be no code.  The whole idea is that you write a tiny bit  
of spec... just enough to fail because the required behaviour does  
not exist.  Then you write just enough code to satisfy the spec that  
is failing.  How is having automated generation of any help?

Dave




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Darwin)

iD8DBQFE3SQCauez/L4x7g4RAnGBAJsER52oskVUkpw7hXaSzk51naLo9gCgktXJ
SsHDMGZaElPc4XLtsHnnrjM=
=lRpT
-----END PGP SIGNATURE-----


More information about the Rspec-devel mailing list