[rspec-users] Stopping example execution?

David Chelimsky dchelimsky at gmail.com
Sun Jun 29 12:59:57 EDT 2008

On Jun 29, 2008, at 11:38 AM, Britt Mileshosky wrote:
> ----------------------------------------
>> From: dchelimsky at gmail.com
>> To: rspec-users at rubyforge.org
>> Date: Sun, 29 Jun 2008 11:20:46 -0500
>> Subject: Re: [rspec-users] Stopping example execution?
>> On Jun 29, 2008, at 11:18 AM, Britt Mileshosky wrote:
>>> However, do you see where something like a return statement or end
>>> example statement could be beneficial?
>>> If you are working from the top down with your controller action
>>> execution, then you only need to test your expectation
>>> and then bail out of your action.  No need to further test or meet
>>> requirements on anything else in that action because your
>>> single test has been met.
>> My instinct about this is that it would encourage long methods  
>> because
>> it would make it less painful to test them, so I would be adverse to
>> anything that let's you short circuit the method.
>> Anybody else have opinions on that?
> I understand your point, but should a testing framework be worried  
> too much about how a user will be writing their application code?

YES. This is Ruby, my friend, land of opinionated software. The whole  
point of RSpec is to encourage good practices. Long Methods (any  
method does more than one thing) are a known Code Smell. If you want  
to write them, it should be painful.

You're certainly entitled to a different opinion, and you can express  
that opinion in a gem that extends rspec to do what you want! If you  
do that and enough people use it and it proves generally useful and  
pain-free, I'd be glad to peek at it again.


> Leave it to the programmer to decide what logic they put in the  
> controller, let the testing framework make it easy to test
> that certain conditions are met,  no matter how those conditions are  
> presented in the application.
> This short-circuting can be completely optional... it would just be  
> nice to have it there if needed.  In the end I honestly can see a more
> natural process to testing methods bit by bit, building up examples  
> and stubs in their respective describe groups as needed.  If someone
> wants to single describe group and all stubs at the top, so be it.   
> I'd like mine to be incrementally built upon each other.
> I'll be quiet now and let others discuss, (...I'm cheering for this  
> though!)
> _________________________________________________________________
> Need to know now? Get instant answers with Windows Live Messenger.
> http://www.windowslive.com/messenger/connect_your_way.html?ocid=TXT_TAGLM_WL_Refresh_messenger_062008
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list