ruby-on-rails - Minitest::Spec 和 ActiveSupport::TestCase 之间的区别

标签 ruby-on-rails testing minitest

在 Rails 4 的 test_helper 中使用 Minitest::SpecActiveSupport::TestCase 有什么区别?

最佳答案

This project aims to enable MiniTest within the Rails TestCase classes. Your test will continue to inherit from ActiveSupport::TestCase, which will now support the spec 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 )

关于ruby-on-rails - Minitest::Spec 和 ActiveSupport::TestCase 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21783012/

相关文章:

ruby-on-rails - 来自 sidekiq 的 Action Cable Broadcast 消息仅在刷新后显示,从控制台立即生效

ruby-on-rails - 任何来源中的 Rails : Could not find minitest-4. 7.5

ruby-on-rails - has_many 到 has_many ...我必须两种方式都添加索引吗?

ruby-on-rails - 如何使用 RSpec 测试日志内容?

ruby-on-rails - Rails - 在没有 GET 参数的情况下重定向到当前 url

javascript - 禁用不被视为 HTML 属性

javascript - Protractor 运行后出现 uncaughtException

internet-explorer - 如何在不使用任何虚拟以及第三方工具的情况下在同一台机器上运行多个版本的 IE(IE10、IE11)

ruby - 使用参数测试 CLI

ruby - 为什么我应该使用 assert_equal 而不是在 minitest 中使用相等运算符断言?