我关注 Rails 教程,但在图 3.6之前的第 3.2.1 节有问题。跑步时
$ bundle exec rspec spec/requests/static_pages_spec.rb
我失败了
Failures:
1) StaticPages GET /static_pages works! (now write some real specs)
Failure/Error: get static_pages_index_path
NameError:
undefined local variable or method `static_pages_index_path' for # <RSpec::Core::ExampleGroup::Nested_1::Nested_1:0x007fe7592b33b8>
# ./spec/requests/static_pages_spec.rb:7:in `block (3 levels) in <top (required)>'
Finished in 0.00454 seconds
1 example, 1 failure
Failed examples:
rspec ./spec/requests/static_pages_spec.rb:5 # StaticPages GET /static_pages works! (now write some real specs)
这是文件:
规范/请求/static_pages_spec.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
end
应用程序/控制器/static_pages_controller.rb
class StaticPagesController < ApplicationController
def home
end
def help
end
end
app/views/static_pages/home.html.erb
<h1>Sample App</h1>
<p>
This is the home page for the
<a href="http://railstutorial.org/">Ruby on Rails Tutorial</a>
sample application.
</p>
配置/路由.rb
SecondApp::Application.routes.draw do
get "static_pages/home"
get "static_pages/help"
end
宝石文件
source 'https://rubygems.org'
gem 'rails', '3.2.3'
group :development do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.9.0'
gem 'guard-rspec', '0.5.5'
end
group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.0'
group :test do
gem 'rspec-rails', '2.9.0'
gem 'capybara', '1.1.2'
gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
知道我做错了什么吗?