[rspec-users] Merb

Ashley Moran ashley.moran at patchspace.co.uk
Mon Oct 20 15:05:06 EDT 2008

On Oct 19, 2008, at 10:31 pm, Caius Durling wrote:

> Funny you should post this, I picked up merb today as well (seeing  
> as the API is finally frozen) and was thinking about posting to see  
> if anyone else was.

Well, I've done a bit more research (asking around on the Merb list),  
and it seems the best practice* in Merbland is to use controller specs  
in much the same way as Rails integration tests[1].  While I see the  
point that you should test behaviour not implementation, I think that  
goes a *little* too far.  In short, it's not recommended to do the  
equivalent of:

   it "should create a new, unsaved person on GET to create" do
     get 'create'

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

And I assume it works similarly with the #get, #post etc.  (I have yet  
to try it though, and I can't visualise a clean way to write specs  
with it.)

Anyway the whole discussion provoked me to crystallise my thoughts on  
Ruby web BDD, which I decided to blog[3], and I thought it may be of  
interest to people here, in case there's yet a third "right way" of  
doing things.

(If anyone finds this of interest, let me know.  If so, I might start  
an "Adventures in Merb BDD" series - or something - on my blog.)


* I've padded up in anticipation of the chair I know Aslak will hurl  
when he reads that ;o)

[1] http://www.slideshare.net/wycats/testing-merb-presentation
[2] http://merbivore.com/documentation/0.9.9/doc/rdoc/merb-core/index.html?a=C00000147&name=RequestHelper
[3] http://aviewfromafar.net/2008/10/20/web-app-bdd-thoughts-as-i-move-to-merb


More information about the rspec-users mailing list