有人可以提供故障排除提示吗?:
使用以下一系列与rails相关的命令:
rails new test6
bundle install
rails generate Controller Gohere left right up down
rake test
...似乎两次运行rake任务'test'。我哪里出错?
日志在这里:
perrys-MacBook-Pro:rails_projects perry_mac$ rails new test6
create
create README
create Rakefile
create config.ru
create .gitignore
create Gemfile
create app
create app/controllers/application_controller.rb
create app/helpers/application_helper.rb
create app/mailers
create app/models
create app/views/layouts/application.html.erb
create config
create config/routes.rb
create config/application.rb
create config/environment.rb
create config/environments
create config/environments/development.rb
create config/environments/production.rb
create config/environments/test.rb
create config/initializers
create config/initializers/backtrace_silencers.rb
create config/initializers/inflections.rb
create config/initializers/mime_types.rb
create config/initializers/secret_token.rb
create config/initializers/session_store.rb
create config/locales
create config/locales/en.yml
create config/boot.rb
create config/database.yml
create db
create db/seeds.rb
create doc
create doc/README_FOR_APP
create lib
create lib/tasks
create lib/tasks/.gitkeep
create log
create log/server.log
create log/production.log
create log/development.log
create log/test.log
create public
create public/404.html
create public/422.html
create public/500.html
create public/favicon.ico
create public/index.html
create public/robots.txt
create public/images
create public/images/rails.png
create public/stylesheets
create public/stylesheets/.gitkeep
create public/javascripts
create public/javascripts/application.js
create public/javascripts/controls.js
create public/javascripts/dragdrop.js
create public/javascripts/effects.js
create public/javascripts/prototype.js
create public/javascripts/rails.js
create script
create script/rails
create test
create test/fixtures
create test/functional
create test/integration
create test/performance/browsing_test.rb
create test/test_helper.rb
create test/unit
create tmp
create tmp/sessions
create tmp/sockets
create tmp/cache
create tmp/pids
create vendor/plugins
create vendor/plugins/.gitkeep
perrys-MacBook-Pro:rails_projects perry_mac$ cd test6
perrys-MacBook-Pro:test6 perry_mac$ bundle install
Fetching source index for http://rubygems.org/
Using rake (0.9.2)
Using abstract (1.0.0)
Using activesupport (3.0.9)
Using builder (2.1.2)
Using i18n (0.5.0)
Using activemodel (3.0.9)
Using erubis (2.6.6)
Using rack (1.2.3)
Using rack-mount (0.6.14)
Using rack-test (0.5.7)
Using tzinfo (0.3.29)
Using actionpack (3.0.9)
Using mime-types (1.16)
Using polyglot (0.3.1)
Using treetop (1.4.9)
Using mail (2.2.19)
Using actionmailer (3.0.9)
Using arel (2.0.10)
Using activerecord (3.0.9)
Using activeresource (3.0.9)
Using bundler (1.0.15)
Using rdoc (3.8)
Using thor (0.14.6)
Using railties (3.0.9)
Using rails (3.0.9)
Using sqlite3 (1.3.3)
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.
perrys-MacBook-Pro:test6 perry_mac$ rake test
perrys-MacBook-Pro:test6 perry_mac$ rails generate controller Gohere left right up down
create app/controllers/gohere_controller.rb
route get "gohere/down"
route get "gohere/up"
route get "gohere/right"
route get "gohere/left"
invoke erb
create app/views/gohere
create app/views/gohere/left.html.erb
create app/views/gohere/right.html.erb
create app/views/gohere/up.html.erb
create app/views/gohere/down.html.erb
invoke test_unit
create test/functional/gohere_controller_test.rb
invoke helper
create app/helpers/gohere_helper.rb
invoke test_unit
create test/unit/helpers/gohere_helper_test.rb
perrys-MacBook-Pro:test6 perry_mac$ rake test Loaded suite /Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader
Started
Finished in 0.002747 seconds.
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 15229
Loaded suite /Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader
Started
....
Finished in 0.438403 seconds.
4 tests, 4 assertions, 0 failures, 0 errors, 0 skips
Test run options: --seed 9266
perrys-MacBook-Pro:test6 perry_mac$
...和rvm info产生:
perrys-MacBook-Pro:test6 perry_mac$ rvm info
ruby-1.9.2-p290:
system:
uname: "Darwin perrys-MacBook-Pro.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 i386"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin10.0)"
zsh: "/bin/zsh => zsh 4.3.9 (i386-apple-darwin10.0)"
rvm:
version: "rvm 1.6.23 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.9.2p290"
date: "2011-07-09"
platform: "x86_64-darwin10.8.0"
patchlevel: "2011-07-09 revision 32553"
full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]"
homes:
gem: "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290"
ruby: "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290"
binaries:
ruby: "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/bin/ruby"
irb: "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/bin/irb"
gem: "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/bin/gem"
rake: "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/bin/rake"
environment:
PATH: "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290/bin:/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290@global/bin:/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/bin:/Users/perry_mac/.rvm/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin"
GEM_HOME: "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290"
GEM_PATH: "/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290:/Users/perry_mac/.rvm/gems/ruby-1.9.2-p290@global"
MY_RUBY_HOME: "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290"
IRBRC: "/Users/perry_mac/.rvm/rubies/ruby-1.9.2-p290/.irbrc"
RUBYOPT: ""
gemset: ""
perrys-MacBook-Pro:test6 perry_mac$
答案 0 :(得分:11)
我意识到这篇文章已经很老了,但如果你从来没想过,或者别人对此感到困惑(就像我今晚一样),这就是发生了什么:
实际上有两套测试在这里运行:功能测试&单元测试。当你在一个像这样的新Rails项目中生成一个控制器时,你会得到一些功能测试,并且你得到一个没有实际测试的存根单元测试文件。
所以,你看到第一个测试结果:
0 tests, 0 assertions, 0 failures, 0 errors, 0 skips
是空单元测试文件的结果。
只要您填写一些单元测试,它就会显示非零结果。请注意,您还可以运行 rake test:units 或 rake test:functionals 来运行一组测试。
我希望有更明确的输出来表明发生了什么。 令人困惑。