我只是想尝试测试一个尝试过的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"
行
我的包
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)
我重新安装了最小的帮手,并且只是取消了一些注意事项
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
。
答案 0 :(得分:0)
默认的test_unit和mini_test栏目在您的应用中处于争用状态。要确保您的应用始终配置为使用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"