2

请帮忙:

我想用 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
4

1 回答 1

5

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

解释

shoulda-matchers 1.4.2 引入了对 bourne 的依赖,它依赖于被 minitest 破坏的 mocha 版本,因为run_setup_hooks并且run_teardown_hooks已经从 minitest 中删除。

这是一个关于 shoulda-matchers 的错误报告,解释了发生了什么:https ://github.com/thoughtbot/should-matchers/issues/235

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

于 2013-02-19T06:10:17.333 回答