[rspec-users] specifying a controller's layout

Stephen Eley sfeley at gmail.com
Thu Oct 16 11:02:44 EDT 2008


On Thu, Oct 16, 2008 at 9:49 AM, Jim Gay <jim at saturnflyer.com> wrote:
>
> 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.

This confused me too at first.  To put it another way:

(1) controller.expect_render(:layout => 'index')   [set expectation]
(2) get :index   [perform action]

...is equivalent to...

(1) Call spouse to say "Honey, I'm coming home, see you shortly."
(2) Go home and kiss spouse.

Putting the "get" first and then setting the "expect" would be equivalent to:

(1) Go home and kiss spouse.
(2) Call spouse to say "Honey, I'm coming home, see you shortly."

Your spouse's natural reaction would be "Ummmm...."  Which is
basically what RSpec is telling you by that error message when you do
the 'get' then the 'expect.'


-- 
Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine
   http://www.escapepod.org


More information about the rspec-users mailing list