[rspec-users] Testing Layout

Andy Croll lists at ruby-forum.com
Wed Apr 16 10:53:04 EDT 2008

Bart Zonneveld wrote:
> On 16-apr-2008, at 13:57, Andy Croll wrote:
>> Is there a way to specify which layout an action should use in a
>> controller?
> Off the top of my head, not tested:
> describe MyController do
>    it "should use the foo layout" do
>      MyController.should_receive(:layout).with("foo")
>      load("app/controllers/my_controller")
>    end
> end
> but I'm sure there's a more BDD way to do it (TIMTOWTDI goes BDDWTDI ?).
> greetz,
> bartz

Tried it. No dice it seems

So I then tried:

  it "should use the admin layout" do

And I get...

Spec::Mocks::MockExpectationError in 'Admin::ProductsController should 
use the admin layout'
Mock 'Admin::ProductsController' expected :layout with ("admin") once, 
but received it 0 times

I'm not doing the load ... command you suggested. What is the thinking 
behind that? I'm finding that testing using RSpec demands you understand 
a lot more of what is going on inside the framework!

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list