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
…
end
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
capybara.
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:
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.