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? Thanks, Steve
Evgeniy Dolzhenko
2010-Nov-12 20:56 UTC
[rspec-users] How do I include routing path helpers?
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 On Fri, Nov 12, 2010 at 8:42 PM, Steve <vertebrate at gmail.com> wrote:> 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? > > Thanks, > Steve > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
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. On Nov 12, 2:56?pm, Evgeniy Dolzhenko <dolze... at gmail.com> wrote:> 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 >
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, Steve On Nov 12, 2:56?pm, Evgeniy Dolzhenko <dolze... at gmail.com> wrote:> 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
Evgeniy Dolzhenko
2010-Nov-13 11:53 UTC
[rspec-users] How do I include routing path helpers?
Hm, make sure you have something like MySuperApp::Application.configure do routes.default_url_options = { :host => "test.host", :protocol => ''https'' } end in your config\environments\test.rb On Sat, Nov 13, 2010 at 4:01 AM, Steve <vertebrate at gmail.com> wrote:> 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. > > On Nov 12, 2:56?pm, Evgeniy Dolzhenko <dolze... at gmail.com> wrote: >> 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 >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
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. On Nov 13, 5:53?am, Evgeniy Dolzhenko <dolze... at gmail.com> wrote:> Hm, make sure you have something like > > MySuperApp::Application.configure do > ? routes.default_url_options = { :host => "test.host", :protocol => ''https'' } > end > > in your config\environments\test.rb > > > > On Sat, Nov 13, 2010 at 4:01 AM, Steve <vertebr... at gmail.com> wrote: > > 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. > > > On Nov 12, 2:56?pm, Evgeniy Dolzhenko <dolze... at gmail.com> wrote: > >> 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 > > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
Evgeniy Dolzhenko
2010-Nov-13 20:31 UTC
[rspec-users] How do I include routing path helpers?
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'' => ''hi5.test.host'') On Sat, Nov 13, 2010 at 7:54 PM, Steve <vertebrate at gmail.com> wrote:> 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. > > On Nov 13, 5:53?am, Evgeniy Dolzhenko <dolze... at gmail.com> wrote: >> Hm, make sure you have something like >> >> MySuperApp::Application.configure do >> ? routes.default_url_options = { :host => "test.host", :protocol => ''https'' } >> end >> >> in your config\environments\test.rb >> >> >> >> On Sat, Nov 13, 2010 at 4:01 AM, Steve <vertebr... at gmail.com> wrote: >> > 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. >> >> > On Nov 12, 2:56?pm, Evgeniy Dolzhenko <dolze... at gmail.com> wrote: >> >> 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 >> >> > _______________________________________________ >> > rspec-users mailing list >> > rspec-us... at rubyforge.org >> >http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
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. On Nov 13, 2:31?pm, Evgeniy Dolzhenko <dolze... at gmail.com> wrote:> 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'' => ''hi5.test.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. On Nov 13, 2:31?pm, Evgeniy Dolzhenko <dolze... at gmail.com> wrote:> 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'' => ''hi5.test.host'') >