bundle exec rspec spec/requests/static\u pages\u spec.rb错误
正在使用的版本:bundle exec rspec spec/requests/static\u pages\u spec.rb错误,rspec,ruby-on-rails-3.2,gem,tdd,bundler,Rspec,Ruby On Rails 3.2,Gem,Tdd,Bundler,正在使用的版本: 轨道-3.2.13 Ruby-Ruby 1.9.3p429(2013-05-15修订版40747)[x86_64-darwin11.4.2] 我跑 $rails生成集成\u测试静态\u页面 得到 invoke rspec create spec/requests/static_pages_spec.rb 遵循Rails Hartl教程第3.2.1节。 运行时出现以下错误: $bundle exec rspec spec/requests/static\u pages\
轨道-3.2.13
Ruby-Ruby 1.9.3p429(2013-05-15修订版40747)[x86_64-darwin11.4.2] 我跑
$rails生成集成\u测试静态\u页面
得到
invoke rspec
create spec/requests/static_pages_spec.rb
遵循Rails Hartl教程第3.2.1节。
运行时出现以下错误:$bundle exec rspec spec/requests/static\u pages\u spec.rb
静态页面\u规范rb
require 'spec_helper'
describe "Static pages" do
describe "Home page" do
it "should have the content 'Sample App'" do
visit '/static_pages/home'
page.should have_content('Sample App')
end
end
describe "Help page" do
it "should have the content 'Help'" do
visit '/static_pages/help'
page.should have_content('Help')
end
end
end
SampleApp::Application.routes.draw do
get "static_pages/home"
get "static_pages/help"
end
任何帮助都将不胜感激。我可以提供其他版本号或文件,只是不确定要包括什么
routes.rb(示例应用程序/routes.rb)
你应该把你的班级放在
描述
部分
假设控制器的类是StaticPagesController
describe StaticPagesController do
end
或者您可以像这样将type::controller
添加到描述部分
describe "foo", type: :controller do
end
你也应该改变你的路线。我相信他们看起来像:
SampleApp::Application.routes.draw do
root 'static_pages#home'
match '/help' => 'static_pages#help', :via => 'get'
match '/about' => 'static_pages#about', :via => 'get'
match '/contact' => 'static_pages#contact', :via => 'get'
看看这个痕迹;该错误似乎源于您的路由文件。你能发布吗?@rossta我已经在原始问题的底部添加了路由文件。谢谢Pierre,我原来有两个StaticPagesController.rb文件(不是确切的文件名)。我清除了整个目录,并从头开始检查文件,这次没有出现任何错误。工作间歇一定使我的目录变得复杂了。
describe "foo", type: :controller do
end
SampleApp::Application.routes.draw do
root 'static_pages#home'
match '/help' => 'static_pages#help', :via => 'get'
match '/about' => 'static_pages#about', :via => 'get'
match '/contact' => 'static_pages#contact', :via => 'get'