使用minitest的minitest-rails-shoulda给了我未定义的方法`run_teardown_hooks'

时间:2013-02-15 07:37:27

标签: shoulda minitest

请帮助:

我想用minitest用户。

这是我得到的例外:

NoMethodError: undefined method `run_teardown_hooks' for #<#<Class:0x007fd42ed95490>:0x007fd42ed00c78>
/Users/boti/.rvm/gems/ruby-1.9.2-p180@search_server/gems/mocha-0.10.5/lib/mocha/integration/mini_test/version_230_to_262.rb:39:in `run'
/Users/boti/.rvm/gems/ruby-1.9.2-p180@search_server/gems/activesupport-3.2.11/lib/active_support/testing/setup_and_teardown.rb:36:in `block in run'
/Users/boti/.rvm/gems/ruby-1.9.2-p180@search_server/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:425:in `_run__1339649173504478165__setup__555511959301366683__callbacks'
/Users/boti/.rvm/gems/ruby-1.9.2-p180@search_server/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in `__run_callback'
/Users/boti/.rvm/gems/ruby-1.9.2-p180@search_server/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in `_run_setup_callbacks'
/Users/boti/.rvm/gems/ruby-1.9.2-p180@search_server/gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in `run_callbacks'
/Users/boti/.rvm/gems/ruby-1.9.2-p180@search_server/gems/activesupport-3.2.11/lib/active_support/testing/setup_and_teardown.rb:35:in `run'

这是我的gemfile:

gem 'minitest'
gem 'minitest-should_syntax'
gem 'miniskirt'
gem 'rack-livereload'
gem 'guard'
gem 'guard-minitest'
gem 'guard-bundler'
gem 'guard-livereload'

gem 'annotate', ">=2.5.0"
gem 'guard-annotate'
gem "rb-fsevent"
gem 'database_cleaner'
gem "minitest-rails-shoulda"

gem 'sqlite3', :require => 'sqlite3'

这是我的test_helper:

ENV["RAILS_ENV"] = "test"
require File.expand_path('../../config/environment', __FILE__)
require 'rails/test_help'
require 'minitest/autorun'
require 'minitest/should_syntax'
require 'factories/factories'

class ActionController::TestCase
  include Devise::TestHelpers
end

1 个答案:

答案 0 :(得分:5)

Gemfile中,指定gem 'shoulda-matchers', '1.4.1',然后运行bundle update shoulda-matchers

解释

shoulda-matchers 1.4.2引入了对bourne的依赖,这依赖于被minitest破坏的mocha版本,因为run_setup_hooksrun_teardown_hooks已从minitest中删除。

这是一个针对发现者正在发生的事情的错误报告:https://github.com/thoughtbot/shoulda-matchers/issues/235

如果您受到此问题的影响,请花点时间将错误报告+1,以便获得一点爱。