سؤال

what is the difference between using Minitest::Spec and ActiveSupport::TestCase in my test_helper in Rails 4?

هل كانت مفيدة؟

المحلول

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

This means you don't have to use Minitest::Spec and can simply use ActiveSupport::TestCase all the time to get some convention in your code.

Edit: When you don't use minitest-rails gem you have to register_spec_type

class ControllerSpec < MiniTest::Spec                                                                                                                                                
end                                                                                                                                                                                  

# Functional tests = describe ***Controller                                                                                                                                          
MiniTest::Spec.register_spec_type( /Controller$/, ControllerSpec )

نصائح أخرى

I've never actually used anything besides rspec, but according to their public APIs, ActiveSupport::TestCase only supports testing if an error was raised, while Minitest::Spec has a bit more support for testing things other than succesful DB queries.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top