【发布时间】:2014-02-14 15:16:33
【问题描述】:
在 Rails 4 的 test_helper 中使用 Minitest::Spec 和 ActiveSupport::TestCase 有什么区别?
【问题讨论】:
标签: ruby-on-rails testing minitest
在 Rails 4 的 test_helper 中使用 Minitest::Spec 和 ActiveSupport::TestCase 有什么区别?
【问题讨论】:
标签: ruby-on-rails testing minitest
该项目旨在在 Rails TestCase 中启用 MiniTest 类。您的测试将继续继承自
ActiveSupport::TestCase,现在将支持规范 DSL。 Minitest on Github
这意味着您不必使用Minitest::Spec,并且可以一直使用ActiveSupport::TestCase 来在您的代码中获得一些约定。
编辑:当您不使用 minitest-rails gem 时,您必须 register_spec_type
class ControllerSpec < MiniTest::Spec
end
# Functional tests = describe ***Controller
MiniTest::Spec.register_spec_type( /Controller$/, ControllerSpec )
【讨论】:
我实际上从未使用过除 rspec 之外的任何东西,但根据他们的公共 API,ActiveSupport::TestCase 仅支持在引发错误时进行测试,而Minitest::Spec 更多地支持测试除了成功的数据库查询之外的东西。
【讨论】: