[rspec-users] Merb

Ashley Moran ashley.moran at patchspace.co.uk
Wed Oct 22 16:19:27 EDT 2008

On Oct 21, 2008, at 7:24 am, Jarkko Laine wrote:

> 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 project:
> http://pastie.org/private/6uijgfwwzjngvhbkgxwqq
> 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.

Hi Jarkko

Thanks a lot for that.  I've just got my first controller spec  
working, that's a big win!

How do you handle #only_provides ?  The merb format handler is way  
slicker than respond_to, but I can't get a handle on how to spec its  
behaviour.  (Should you fake an XML request for controllers with  
"only_provides :html", or is  
controller.should_receive(:only_provides).with(:html) more appropriate?)

And actually:

   it "should display a new Item" do
     do_get do |controller|

is really nice syntax.  Just need to work on factoring out the helper:

   def do_get(&blk)
     dispatch_to(Items, :new) do |controller|
         yield controller if block_given?

from specs, but you can't abstract one file!

In this case, RSpec mocks are simpler than not_a_mock.  (More reason  
to be able to switch framework at runtime?)

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

I notice you're on both list so hopefully you can give me nudges in  
the right Merb direction and Merb nudges in the right BDD direction :)

But I also hope they will make concessions to isolated controller  
fans.  All the more reason for me to write up what I find, I guess.



More information about the rspec-users mailing list