[rspec-users] specifying a controller's layout

Rahoul Baruah baz at madeofstone.net
Thu Oct 16 11:18:39 EDT 2008


On 16 Oct 2008, at 16:02, Stephen Eley wrote:

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

I've written some helpers for this - nothing complex, just reverses  
the order that things happen in:

when_getting :index do
   expect_some_stuff_to_happen
end

The helper itself looks like this:

def when_getting action, parameters = {}
   yield if block_given?
   get action, parameters
end

Likewise there is when_posting_to, when_putting_to and  
when_deleting_from

One day (soon) I'll get round to packaging them up and submitting them  
as a patch.


Rahoul Baruah
Web design and development: http://www.3hv.co.uk/
Nottingham Forest: http://www.eighteensixtyfive.co.uk/
Serious Rails Hosting: http://www.brightbox.co.uk/
Lifecast: http://www.madeofstone.net/








More information about the rspec-users mailing list