我直接说我的过程吧。
我现在希望重新构建 Agile 第四版之中的购物车。
Gems included by the bundle:
* actionmailer (3.2.6)
* actionpack (3.2.6)
* activemodel (3.2.6)
* activerecord (3.2.6)
* activeresource (3.2.6)
* activesupport (3.2.6)
* arel (3.0.2)
* builder (3.0.0)
* bundler (1.1.4)
* coffee-rails (3.2.2)
* coffee-script (2.2.0)
* coffee-script-source (1.3.3)
* erubis (2.7.0)
* execjs (1.4.0)
* hike (1.2.1)
* i18n (0.6.0)
* journey (1.0.4)
* jquery-rails (2.0.2)
* json (1.7.3)
* libv8 (3.3.10.4)
* mail (2.4.4)
* mime-types (1.19)
* multi_json (1.3.6)
* polyglot (0.3.3)
* rack (1.4.1)
* rack-cache (1.2)
* rack-ssl (1.3.2)
* rack-test (0.6.1)
* rails (3.2.6)
* railties (3.2.6)
* rake (0.9.2.2)
* rdoc (3.12)
* sass (3.1.19)
* sass-rails (3.2.5)
* sprockets (2.1.3)
* sqlite3 (1.3.6)
* therubyracer (0.10.1)
* thor (0.15.3)
* tilt (1.3.3)
* treetop (1.4.10)
* tzinfo (0.3.33)
* uglifier (1.2.5)
运行rails new depot, 正常
运行rails g scaffold Product title:string description:text image_url:string price:decimal
运行rake db:migrate
运行rake test, 下面就出错了...
rake aborted!
stack level too deep
Tasks: TOP => test:units
(See full trace by running task with --trace)
运行bundle exec rake test, 输出为无限错误循环。
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Rails::SubTestTask#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Object#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
WARNING: DSL method Object#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
WARNING: DSL method Object#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
WARNING: DSL method Object#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
WARNING: DSL method Object#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
WARNING: DSL method Object#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
WARNING: DSL method Object#ruby call
. . .
如果在 Rakefile 中加入include Rake::DSL, 再次运行 bundle exec rake test, 则错误输出结果为:
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Rails::SubTestTask#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
rake aborted!
stack level too deep
Tasks: TOP => test:units
(See full trace by running task with --trace)
添加 trace 参数后,bundle exec rake test -t , 输出结果:
** Invoke test (first_time)
** Execute test
** Invoke test:run (first_time)
** Execute test:run
** Invoke test:units (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:abort_if_pending_migrations
** Execute db:test:prepare
** Invoke db:test:load (first_time)
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:load
** Invoke db:test:load_schema (first_time)
** Invoke db:test:purge
** Execute db:test:load_schema
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
** Execute test:prepare
** Execute test:units
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Rails::SubTestTask#ruby called at /root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
rake aborted!
stack level too deep
/root/.rvm/gems/ruby-1.9.2-p320@global/gems/rake-0.9.2.2/lib/rake/task.rb:162
Tasks: TOP => test:units
最让人崩溃的是:同样的示例,几个月前,同样的命令,新建的项目 (当时具体的 gem 版本不清楚), 但是有一点我可以确认,rake test是可以运行的。当时还使用autotest之类的自动化测试来着!!
太让人崩溃啦!! 谁来告诉我怎么回事儿??
p.s. 其他 rake 任务貌似一切正常,就是 rake test, 另外,我的需求就是要让 test 跑起来,请大家帮我看看,是否新版本不再使用 rake test 这样的命令,又或者我缺少了某个版本的 gem. 总之,我犯的完全可能是低级小白错误,还望大家指点!