I often hear that the most commonly used testing framework in rails is RSpec. I summarized the differences from minitest that can be used with ruby standard.
The reason for using RSpec is "it's convenient because it has all the various functions from the beginning." If you want to share only this part of the test code, or if you want to do something a little elaborate with a mock, you can almost complete it with the standard functions of RSpec.
It is used to check the operation of a simple Ruby program. It is installed in Ruby by default, so it is convenient to use immediately. If you try to do something as elaborate as RSpec, you will have to put in a lot of plugins, inheritance, modules, etc., so minitest is not often used in business level test code.
From a practical point of view, RSpec has some advantages over minitest. Whereas minitest is a "testing framework", Rspec aims to be an "integrated testing environment".
In addition to providing a DSL for behavior definition, RSpec is actively trying to integrate various test-related libraries and peripheral tools and provide standard support. The typical ones are described below.
-Standard support for coloring RSpec execution results (red bar / green bar display) · Support for testing techniques such as mocking and stubs, integration with related libraries · Pending support · Integration with peripheral tools such as Rake, RCov, Heckle, AutoTest (ZenTest) ・ Support for Ruby on Rails -Execution result reports in various formats (eg HTML output). ・ Integration with TextMate ·etc
Due to the active integration and support of the above peripheral tools, there are many things that can be done with the standard functions of RSpec, so it can be inferred that it is widely used.
In the future, I would like to learn about testing using RSpec.
Recommended Posts