How do I include routing path helpers?

I’m writing some Steak acceptance tests in Rspec2 for my Rails3 app
and I can’t access various route helpers(members_path,
new_member_path, etc…) in my specs, and can’t figure out how to
include them. I’m sure it’s probably a simple config setting. Does
anyone know what I need to do?


Not sure on how to do that with Steak but you must be looking to
include Rails.application.routes.url_helpers
somewhere, with vanilla RSpec it would be

describes ‘included helpers’ do
include Rails.application.routes.url_helpers


I went with:

config.include Rails.application.routes.url_helpers, :type
=> :acceptance

but knowing what exactly to include was the important part. I still
have a nil error when url_for tries to call host_with_port on the
request object, but I think that has to do with my using subdomains
with capybara. So now I’m off to figure that out.


Thanks, that did it. I still have a nil error when trying to call
host_with_port on the request object inside url_for, but I think that
is related to my app having subdomains, and trying to use those with

Hm, make sure you have something like

MySuperApp::Application.configure do
routes.default_url_options = { :host => “”, :protocol =>
‘https’ }

in your config\environments\test.rb

That didn’t seem to change anything. I’ll have to keep playing with
it, but if you have any other thoughts I’m all for it.

We are indeed. There is no request var available in Capybara. I think
that is supposed to be taken care of by Capybara.default_host which I
have set, but still no dice. I see exciting times ahead trying to get
this working.

We’re into some horrible throw-it-and-see-if-it-works loop now, but I
can tell you
here is what I use in my before blocks to test the subdomain routing
in controller specs:

request.env.merge!(‘HTTP_HOST’ => ‘’)

The issue is actually before getting to anything Capybara related.
It’s coming from my call to member_path @member in my spec to
determine the route path to use. Looking at it this way the error
makes more sense. Not sure how much fudging I would need to do to
simulate there being a request there for the routing helpers to work
off of.