私は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
アプリ/ビュー/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>
config/routes.rb
SecondApp::Application.routes.draw do
get "static_pages/home"
get "static_pages/help"
end
Gemfile
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
私が間違ったことについて何か考えはありますか?