4

使用 rake 0.9.2、rspec、期望、模拟 2.6.0、rspec-core 2.6.4、rspec-rails 2.6.1

当我执行 rake rails 或 rspec spec path/to/spec 时,我会得到正常输出,直到我期望看到测试实际执行,然后再无其他。我必须终止进程 kill-9 %1 才能终止任务。

我的宝石文件:

source 'http://rubygems.org'

gem 'rails', '3.0.4'
gem 'rake', '0.9.2'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

# gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'warden'
gem 'devise', "= 1.2.1"
gem 'devise_invitable'
gem 'mysql'
gem 'will_paginate', "~> 3.0.pre2"
gem 'acts-as-taggable-on'
gem 'acts_as_list'
gem 'activemerchant'
gem 'braintree'
gem 'bartt-ssl_requirement', :require => 'ssl_requirement'
gem "paperclip"
gem 'jeditable-rails'
gem 'rdiscount'
gem "nifty-generators", :group => :development

gem "exception_notification", :git => "git://github.com/rails/exception_notification", :require => 'exception_notifier'

# Deploy with Capistrano
gem 'capistrano'
gem 'capistrano-ext'



# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :development, :test do
  gem 'webrat', ">=0.7.2"
  gem "rspec-rails"
  gem "ZenTest"
  #gem "autotest"
  #gem "autotest-rails"
  gem "cucumber",         :git => "git://github.com/cucumber/cucumber.git"
  gem "database_cleaner", :git => 'git://github.com/bmabey/database_cleaner.git'
  gem "cucumber-rails", ">= 0.3.2",   :git => "git://github.com/cucumber/cucumber-rails.git"
  gem 'factory_girl_rails'
  gem "capybara"
  #gem "capybara-envjs"
  gem "launchy"
  gem "spork"
  #gem "ruby-debug"
  gem "cancan"
end

外壳输出:

bill$ rake spec
/Users/bill/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.0/lib/bundler.rb:197: warning: Insecure world writable dir /opt in PATH, mode 040777
/Users/bill/.rvm/rubies/ruby-1.9.2-head/bin/ruby -S bundle exec rspec ./spec/controllers/products_controller_spec.rb ./spec/controllers/roles_controller_spec.rb ./spec/controllers/users_controller_spec.rb ./spec/models/product_spec.rb ./spec/models/role_spec.rb ./spec/models/user_spec.rb
/Users/bill/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.0/lib/bundler.rb:197: warning: Insecure world writable dir /opt in PATH, mode 040777
/Users/bill/.rvm/gems/ruby-1.9.2-head/gems/bundler-1.0.0/lib/bundler.rb:197: warning: Insecure world writable dir /opt in PATH, mode 040777

直到我杀了之后,什么都没有了。使用 --trace 运行不提供任何附加信息。我确定我必须做一些愚蠢的事情。这似乎是从我最近遇到的 rake 版本问题开始的,因此升级到 rake 0.9.2,尽管我没有任何直接相关性的具体证据。感谢您提供有关如何更好地调试此问题的任何建议。

4

3 回答 3

6

呃,原来是其中一个固定文件有问题。我不使用它们,通常是工厂和存根,并且有一个规范不完整,所以看起来 rspec 只是挂在上面。我通过缩小命令来测试不同的组来解决这个问题,比如“rake spec:models”,它起作用了,然后是“rake spec:controllers”,它挂了。进入生成的规范并注意到加载夹具的行,删除它们,瞧。永远不会沉闷...;-)

于 2011-06-16T19:43:00.503 回答
2

更新:我发现这个问题似乎是一个永久的解决方案。我将下面的行添加到我的config/environments/test.rb.

config.active_record.maintain_test_schema = false

我遇到了这个完全相同的问题。一时兴起,我决定跑步rake db:test:prepare,这似乎为我解决了这个问题,至少是暂时的。运行之后,我可以再次运行rake一次而不会发生任何事件,但是如果我再次运行它,我会遇到和以前一样的问题。我现在似乎陷入了这个循环。这篇文章有助于阐明这个主题,但我仍然不知道如何永久解决这个问题。

于 2015-03-09T18:52:13.917 回答
2

对我来说,在更新架构后它已修复:

bundle exec rake db:migrate

然后运行这个命令:

bundle exec rake db:schema:load

手动检查 schema.rb 文件是否已更新。

于 2016-03-05T19:40:07.093 回答