Reputation: 389
So I'm using Pragmatic's "Agile Development with Rails" book and it's been a great learning resource.
For those not familiar (and those that are), the book guides you through making an online store.
I generated a scaffold for my "store products" which generates the full MVC structure, then I generated only a controller and a view for the "cart".
This creates these directories:
/app/models/products.rb
/test/models/products-test.rb
/test/models/cart.rb
My question is general: what is the difference between a test model and an app model? I understand that the app model controls what goes in and out of the database, but what does the test model do? And why is it created even for components that don't have a database model?
Upvotes: 0
Views: 57
Reputation: 2165
test/models
is place for tests which should testing your models. Like app/models/products.rb
is file for application model and test/models/products_test.rb
is file with specs for testing your Products
model.
http://guides.rubyonrails.org/testing.html#unit-testing-your-models
Upvotes: 1