Route generation inside mailer specs

Rails mailers live under “app/models” even though they have some
controller-like responsibilities, and I stick the corresponding specs
under “spec/models”

In one of my mailers I use the kind of dynamic route generation
methods that Rails provides, things like foo_bar_path and foo_bar_url.

What would I need to do to get access to those methods from within my
mailer specs? I basically want to confirm the presence of a url in the
generated body, something like:

url = foo_bar_url(@foo, @bar)
@mail.body.should match(url)

Evidently I need to include some module or something, but as it’s all
dynamically generated I have no idea where to begin looking.

Oddly enough, the foo_bar_url is defined within the context of the
example (ie. I don’t get an “undefined method foo_bar_url in
#Spec::Rails::Example::ModelExampleGroup::Subclass_1:0x214146c
exception), but what I do get is:

You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.foo_bar_url

So the message is being sent to nil… not what I would have expected.

Cheers,
Wincent