[rspec-users] specifying a controller's layout

Jim Gay jim at saturnflyer.com
Thu Oct 16 09:49:07 EDT 2008

On Oct 16, 2008, at 7:59 AM, Dave Phiri wrote:

> David Chelimsky wrote:
>> On Thu, Sep 4, 2008 at 8:42 AM, Matt Wynne <matt at mattwynne.net>  
>> wrote:
>>> I want to spec that a controller uses a particular layout
>>> how do I do that?
>> Depends on what else is going on, but this is the simplest situation:
>>  controller.expect_render(:layout => 'special_layout')
>>  get :some_action
> David:
> Why is it that
> get :some_action
> controller.expect_render(:layout => 'special_layout')
> ie having the get statement before the controller.expect.. statement
> produces the ff error:
> Mock 'expect_render_mock_proxy' expected :render with
> ({:layout=>"special_layout"}) once, but received it 0 times

Because you are creating an expectation for the following action.
In your code above, you are doing the action, and then creating an  
expectation for a following action which never occurs, so it receives  
it 0 times following that expectation.


More information about the rspec-users mailing list