【发布时间】:2016-08-16 07:51:40
【问题描述】:
按照 Rails 教程进行操作,但在稍微切线时关闭,现在无法通过测试。
下面是我的路线文件和我的测试文件。 home 测试失败,这条线 , to: "static_pages#home", as: "home" 是让它出现的线。即删除它,它会通过。我想知道为什么有人可以解释为什么会失败以及如何更改测试以使其通过但保留这条线?
我的路线文件:
Rails.application.routes.draw do
resources :static_pages
get 'static_pages/help'
get 'static_pages/test'
get 'static_pages/home', to: "static_pages#home", as: "home"
root 'application#hello'
end
我的测试文件:
require 'test_helper'
class StaticPagesControllerTest < ActionDispatch::IntegrationTest
test "should get home" do
get static_pages_home_url
assert_response :success
end
test "should get help" do
get static_pages_help_url
assert_response :success
end
test "should get test" do
get static_pages_test_url
assert_response :success
end
end
【问题讨论】:
标签: ruby-on-rails ruby testing routes