Skip to Main Content
Rails 5 Test Prescriptions
book

Rails 5 Test Prescriptions

by Noel Rappin
February 2018
Intermediate to advanced content levelIntermediate to advanced
406 pages
9h 52m
English
Pragmatic Bookshelf
Content preview from Rails 5 Test Prescriptions

Factories

Generically, the factory pattern refers to a class or module in your application whose sole purpose is to safely and correctly create other objects in your application. Outside of tests, factories are frequently used to encapsulate complex object-creation logic. Inside of Rails tests, factories are used to provide templates for creating valid objects.

Rather than specifying all the test data exactly, the factory tool provides a blueprint for creating a sample instance of your model. When you need data for a specific test, you call a factory method, which gives you an object based on your blueprint. You can override the blueprint to identify any specific attribute values required to make your test work out. Calling the factory method ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Rails 4 Test Prescriptions

Rails 4 Test Prescriptions

Noel Rappin
Agile Web Development with Rails 5.1

Agile Web Development with Rails 5.1

Sam Ruby, David B. Copeland, Dave Thomas
Rspec Essentials

Rspec Essentials

Mani Tadayon

Publisher Resources

ISBN: 9781680505566Errata Page