如何调试 rake 规范不执行测试;无限悬挂问题(rails 3)

发布于 11-14 23:59 字数 2610 浏览 2 评论 0原文

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

当我执行 rakerails 或 rspec spec path/to/spec 时,我会得到正常输出,直到我'我期望看到测试实际执行,然后就不再做任何事情了。我必须终止进程kill-9 %1 才能终止任务。

我的 gemfile:

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

shell 的输出:

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,尽管我没有任何直接相关性的具体证据。感谢您提供有关如何更好地调试此问题的任何建议。

Using rake 0.9.2, rspec, expectations, mocks 2.6.0, rspec-core 2.6.4, rspec-rails 2.6.1

When I execute rake rails, or rspec spec path/to/spec I get normal output up until I'd expect to see the tests actually execute, then nothing further. I have to kill the process kill-9 %1 to terminate the task.

My gemfile:

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

Output from shell:

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

And then nothing further until I kill. Running with --trace doesn't provide any additional info. I'm sure I've got to be doing something simply silly. This appears to have started with recent issues I was having with rake versions, hence the upgrade to rake 0.9.2, although I have no concrete proof of any direct correlation. Thanks for any suggestions on how to debug this better.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

甜妞爱困2024-11-21 23:59:05

呃,事实证明这是其中一个灯具文件的问题。我不使用它们,通常是工厂和存根,并且有一个规范不完整,所以看起来 rspec 只是挂在上面。我通过缩小命令范围来测试不同的组来解决这个问题,比如“rakespec:models”,它有效,然后“rakespec:controllers”挂起。查看生成的规格并注意到加载灯具的线路,将其移除,瞧。永远不会沉闷...;-)

Ugh, turns out it was an issue with one of the fixtures files. I don't use them, normally factories and stubs, and there was one with incomplete specification so it looks like rspec was just hanging on that. I figured it out by narrowing down the command to test different groups, like 'rake spec:models', which worked, then 'rake spec:controllers' which hung. Went into the generated specs and noticed the lines loading the fixtures, removed them and voila. Never dull...;-)

时常饿2024-11-21 23:59:05

更新:我从这个问题。我将下面的行添加到我的 config/environments/test.rb 中。

config.active_record.maintain_test_schema = false

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

UPDATE: I found what seems to be a permenant solution to the problem from this question. I added the line below to my config/environments/test.rb.

config.active_record.maintain_test_schema = false

I encountered this exact same problem. On a whim, I decided to run rake db:test:prepare, which seemed to resolve it for me, at least temporarily. After running that, I can run rake again without incident once, but if I run it again, I encounter the same problem as before. I seem to be stuck in this cycle now. This article helped shed some light on the subject, but I still don't know how to permanently solve the problem.

埋葬我深情2024-11-21 23:59:05

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

bundle exec rake db:migrate

然后运行此命令:

bundle exec rake db:schema:load

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

For me it was fixed after I updated the schema:

bundle exec rake db:migrate

and then ran this command:

bundle exec rake db:schema:load

manually check the schema.rb file if it was updated.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文