Intro to Testing With Rails: The Test Database and Fixtures

# in fixtures/authors.yml
name: J. K. Rowling
age: 55
# in fixtures/books.yml
title: Harry Potter
author: rowling
# in models/book_test.rbtest "fixtures properly save to database" do
assert_not_nil books(:harry),
"book fixture did not save to database"
assert_equal authors(:rowling), books(:harry).author,
"book fixture does not reference author fixture"




Software Engineer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Lean project management

Top 8 marketplace features to ensure the best customer experience and boost sales

R Markdown: My Favorite Tool for Conducting and Sharing Analysis

Product of Array Except Self

Error Code -43 OneDrive for Business

Dutch error message, translation: Can’t download file, error code -43.

10 Best Web Scraping Tools of All Times

Design Patterns used in Swift for iOS App Development

Five Types of Dysfunctional Software Teams and How To Fix Them

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Valerie Foster

Valerie Foster

Software Engineer

More from Medium

The Rises and Falls of Ruby on Rails and AngularJS

Ruby + Dynamodb in Local environment

Understanding the MVC with Rails

Testing a Rails API with RSpec