Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make Capybara use Routing helpers

I am using rails 3, Steak & Capybara. I have restful resources, is it possible to use routing helpers available to views and controllers?

like image 368
Nerian Avatar asked Dec 10 '10 18:12

Nerian


1 Answers

You just have to put this on your spec_helper.rb

config.include Rails.application.routes.url_helpers

inside the configuration definition block, that is, the one that is wrapped by:

RSpec.configure do |config|
# All your config.include calls go here.
end

And then you can use it on your feature specs:

scenario "Show school" do
school = School.create!(:name => "Pablo de Olavide")
visit(school_path(school))
save_and_open_page
page.has_content?("Pablo de Olavide").should == true
end

Do not use:

include ActionController::UrlWrite

As it is deprecated in rails 3

like image 186
Nerian Avatar answered Nov 12 '22 03:11

Nerian