2011-06-13 78 views
4

使用rake 0.9.2,rspec,expect,mocks 2.6.0,rspec-core 2.6.4,rspec-rails 2.6.1如何調試rake spec不執行測試;無限懸掛問題(rails 3)

當我執行rake rails或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 

輸出:

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運行不會提供任何其他信息。我相信我必須做一些簡單的事情。這似乎是從最近我與耙子版本有關的問題開始的,因此升級到了0.9.2,儘管我沒有任何直接關聯的具體證據。感謝有關如何更好地進行調試的任何建議。

回答

5

呃,事實證明這是一個夾具文件的問題。我不使用它們,通常是工廠和存根,並且有一個規格不完整,所以它看起來像rspec只是掛在那裏。我想通過縮小命令來測試不同的羣體,比如'rake spec:models',這些羣體運行正常,然後'rake spec:controllers'被掛起。進入生成的規格,注意到加載燈具的線條,將它們移除,然後瞧。從來沒有沉悶... ;-)

2

更新:我發現什麼似乎是從this question問題的解決方案。我將下面的行添加到我的config/environments/test.rb

config.active_record.maintain_test_schema = false 

我遇到了這個完全相同的問題。一時興起,我決定運行rake db:test:prepare,這似乎至少暫時解決了它。運行之後,我可以再次運行rake而沒有發生過一次,但是如果我再次運行它,則會遇到與以前相同的問題。我似乎現在陷入了這個循環。 This article幫助瞭解了這個問題,但我仍然不知道如何永久解決問題。

2

對我來說,我更新的模式後,這是固定的:

bundle exec rake db:migrate 

,然後運行這個命令:

bundle exec rake db:schema:load 

手動檢查schema.rb文件,如果它已更新。