正在使用的版本:
Rails - 3.2.13
Ruby - ruby 1.9.3p429(2013-05-15 修订版 40747)[x86_64-darwin11.4.2]
我跑了
$ rails generate integration_test static_pages
并得到
invoke rspec
create spec/requests/static_pages_spec.rb
遵循 Rails Hartl 教程第 3.2.1 节。
运行时出现以下错误:
$ bundle exec rspec spec/requests/static_pages_spec.rb
/Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:175:in `default_controller_and_action': missing :controller (ArgumentError)
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:72:in `normalize_options!'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:60:in `initialize'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1308:in `new'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1308:in `add_route'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1287:in `decomposed_match'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `block in match'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `each'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:1269:in `match'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:501:in `map_method'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/mapper.rb:463:in `get'
from /Users/mwsage/rails_projects/sample_app/config/routes.rb:2:in `block in <top (required)>'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `instance_exec'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:289:in `eval_block'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/actionpack-3.2.13/lib/action_dispatch/routing/route_set.rb:267:in `draw'
from /Users/mwsage/rails_projects/sample_app/config/routes.rb:1:in `<top (required)>'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `block in load'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/dependencies.rb:245:in `load'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `each'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:40:in `load_paths'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:16:in `reload!'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:26:in `block in updater'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/file_update_checker.rb:78:in `call'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/activesupport-3.2.13/lib/active_support/file_update_checker.rb:78:in `execute'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:27:in `updater'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /Users/mwsage/rails_projects/sample_app/config/environment.rb:5:in `<top (required)>'
from /Users/mwsage/rails_projects/sample_app/spec/spec_helper.rb:3:in `require'
from /Users/mwsage/rails_projects/sample_app/spec/spec_helper.rb:3:in `<top (required)>'
from /Users/mwsage/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `require'
from /Users/mwsage/rails_projects/sample_app/spec/requests/static_pages_spec.rb:1:in `<top (required)>'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `block in load_spec_files'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `map'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/configuration.rb:780:in `load_spec_files'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/command_line.rb:22:in `run'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:69:in `run'
from /Users/mwsage/.rvm/gems/ruby-1.9.3-p429@rails3tutorial2ndEd/gems/rspec-core-2.11.1/lib/rspec/core/runner.rb:8:in `block in autorun'
宝石文件
source 'https://rubygems.org'
gem 'rails', '3.2.13'
gem 'bootstrap-sass', '2.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails', '2.0.2'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
# gem 'guard-rspec', '1.2.1'
# gem 'guard-spork', '1.2.0'
# gem 'childprocess', '0.3.6'
# gem 'spork', '0.9.2'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
group :test do
gem 'capybara', '1.1.2'
gem 'factory_girl_rails', '4.1.0'
gem 'cucumber-rails', '1.2.1', :require => false
gem 'database_cleaner', '0.7.0'
# gem 'launchy', '2.1.0'
# gem 'rb-fsevent', '0.9.1', :require => false
# gem 'growl', '1.0.3'
end
group :production do
gem 'pg', '0.12.2'
end
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
# gem 'jbuilder'
# Use unicorn as the app server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'debugger'
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
describe "Help page" do
it "should have the content 'Help'" do
visit '/static_pages/help'
page.should have_content('Help')
end
end
end
任何帮助将不胜感激。我可以提供其他版本号或文件,只是不确定要包含什么。
路线.rb (sample_app/routes.rb)
SampleApp::Application.routes.draw do
get "static_pages/home"
get "static_pages/help"
end