[rspec-users] Merb

Jarkko Laine jarkko at jlaine.net
Tue Oct 21 02:24:55 EDT 2008

On 20.10.2008, at 22.05, Ashley Moran wrote:
> There is an API for this though[2], and it was deprecated as of RC1,  
> but has now apparently been reintroduced.
> Lawrence Pit on the merb list explains the syntax:
>>     # ==== Example
>>     #   dispatch_to(MyController, :create, :name => 'Homer' ) do
>> |controller|
>>     #     controller.stub!(:current_user).and_return(@user)
>>     #   end

Yeah, I was using that API to a great extent with a recent project and  
was pretty successful at doing outside-in development with rspec and  
merb. The syntax used in merb controller specs is a bit different from  
what Rails uses, but once you got around it, it was actually pretty  
cool and flexible. Here's a snippet from a controller spec in the  


Note that I generally stub both render and display for the controller  
to make the tests run faster.

There's probably a lot of optimization left to do with the specs but I  
find the dispatch helpers pretty cool for building more specialized  
methods such as do_post.

I hope the merb folks will keep us outside-(s)inners in mind and not  
scrap the API.


Jarkko Laine

Check out my latest book, Unobtrusive Prototype, fresh off the  
Peepcode oven:

More information about the rspec-users mailing list