ruby-on-rails – 如何让Capybara使用路由助手

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – 如何让Capybara使用路由助手前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用铁杆3,牛排&水豚.我有安静的资源,是否可以使用可用于视图和控制器的路由帮助?

解决方法

你只需要把它放在你的spec_helper.rb上
  1. config.include Rails.application.routes.url_helpers

在配置定义块内,即包装的那个:

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

然后你可以使用它的功能规格:

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

不使用:

  1. include ActionController::UrlWrite

因为它在铁路3中已被弃用

猜你在找的Ruby相关文章