1

试图让我的标题测试通过并在运行时看到此错误:

bundle exec rspec spec/requests/static_pages_spec.rb

失败:

1) Static pages Help page should have the h1 'Help'
 Failure/Error: visit '/static_pages/Help'
 ActionController::RoutingError:
   No route matches [GET] "/static_pages/Help"
 # ./spec/requests/static_pages_spec.rb:19:in `block (3 levels) in <top (required)>'

 2) Static pages Help page should have the title 'Help'
 Failure/Error: visit '/static_pages/Help'
 ActionController::RoutingError:
   No route matches [GET] "/static_pages/Help"
 # ./spec/requests/static_pages_spec.rb:24:in `block (3 levels) in <top (required)>'

3) Static pages About page should have the h1 'About Us'
 Failure/Error: visit '/static_pages/About'
 ActionController::RoutingError:
   No route matches [GET] "/static_pages/About"
 # ./spec/requests/static_pages_spec.rb:31:in `block (3 levels) in <top (required)>'

4) Static pages About page should have the title 'About Us'
 Failure/Error: visit '/static_pages/About'
 ActionController::RoutingError:
   No route matches [GET] "/static_pages/About"
 # ./spec/requests/static_pages_spec.rb:36:in `block (3 levels) in <top (required)>'

Finished in 0.16042 seconds
6 examples, 4 failures

Failed examples:

rspec ./spec/requests/static_pages_spec.rb:18 # Static pages Help page should have the h1     'Help'
rspec ./spec/requests/static_pages_spec.rb:23 # Static pages Help page should have the title 'Help'
rspec ./spec/requests/static_pages_spec.rb:30 # Static pages About page should have the h1 'About Us'
rspec ./spec/requests/static_pages_spec.rb:35 # Static pages About page should have the title 'About Us'

SampleApp::Application.routes.draw 做

get "static_pages/home"

get "static_pages/help"

get "static_pages/about"

我已经尝试了其他帖子中已经发布的各种答案,但都没有成功。任何帮助将非常感激。

4

1 回答 1

1

您的 URL 应该是“/static_pages/help”而不是“/static_pages/Help”。

于 2013-04-15T20:04:33.493 回答