0

我只是想测试一个尝试过的 minitest。在 Railscast 之后,我终于得到了一些工作模式,但测试运行了两次。看到一些说要进行捆绑更新的东西。这导致了我已经清除的几个问题,除了:

/Users/me/.rvm/gems/ruby-1.9.3-p327/gems/minitest-rails-0.5.2/lib/minitest/rails.rb:34:in `<class:TestCase>': undefined method `register_spec_type' for ActionController::TestCase:Class (NoMethodError)
from /Users/salex/.rvm/gems/ruby-1.9.3-p327/gems/minitest-rails-0.5.2/lib/minitest/rails.rb:32:in `<top (required)>'
from /Users/salex/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /Users/salex/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require'
from /Users/salex/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency'
from /Users/salex/.rvm/gems/ruby-1.9.3-p327/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require'
from /Users/salex/work/aidtdbr/test/minitest_helper.rb:5:in `<top (required)>'
...

它指向require "minitest/rails"我的 minitest 助手中的行

我的捆绑

Using minitest (4.6.1) 
Using minitest-matchers (1.2.0) 
Using minitest-capybara (0.1.0) 
Using rails (3.2.11) 
Using minitest-rails (0.5.2) 
Using minitest-rails-capybara (0.5.1) 

我重新安装了 minitest 助手,只是取消了一些注释

ENV["RAILS_ENV"] = "development"
require File.expand_path('../../config/environment', __FILE__)

require "minitest/autorun"
require "minitest/rails" 
require "minitest/rails/capybara"

class ActiveSupport::TestCase
  # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
  fixtures :all

  # Add more helper methods to be used by all tests here...
end

这并没有作为一个新的应用程序开始,所以我不知道 minitest 之前的任何东西是否是什么搞砸了,但它确实工作了一段时间。我认为我的两次跑步是使用rake test而不是rake minitest.

4

1 回答 1

0

默认的 test_unit 和 mini_test railties 在您的应用程序中存在争用。为确保您的应用程序始终配置为使用 minitest-rails,请将以下内容添加到config/application.rb文件中:

config.generators do |g|
  g.test_framework :mini_test
end

或者,您可以替换文件顶部的这一行config/application.rb

require "rails/all"

有了这个:

# Pick the frameworks you want:
require "active_record/railtie"
require "action_controller/railtie"
require "action_mailer/railtie"
require "active_resource/railtie"
require "sprockets/railtie"
# require "rails/test_unit/railtie"
require "minitest/rails/railtie"
于 2013-02-22T23:13:44.343 回答