Unit Testing
Learn to add unit testing in rails.
We'll cover the following
One of the joys of the Rails framework is that it has support for testing baked right in from the start of every project. From the moment we create a new application using the rails
command, Rails starts generating a test infrastructure for us. Inside the model
subdirectory lies this file:
depot> ls test/models
product_test.rb
The product_test.rb
file is what Rails created to hold the unit tests for the model we created earlier with the generate
script. This is a good start, but Rails can only help us so much. Let’s see what kind of test goodies Rails generated inside test/models/product_test.rb
when we generated that model:
Get hands-on with 1400+ tech skills courses.