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 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.

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

Cheers,
//jarkko

--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://odesign.fi

Check out my latest book, Unobtrusive Prototype, fresh off the Peepcode oven:
http://peepcode.com/products/unobtrusive-prototype-js

_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to