# Ruby on Rails Test Fixtures

**URL:** <https://www.ruby-forum.com/t/ruby-on-rails-test-fixtures/80456>\
**Category:** Ruby\
**Created:** [December 27, 2006, 3:11am UTC](https://www.ruby-forum.com/t/ruby-on-rails-test-fixtures/80456 "2006-12-27T03:11:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 27, 2006, 3:11am UTC](https://www.ruby-forum.com/t/ruby-on-rails-test-fixtures/80456/1 "2006-12-27T03:11:09Z")

</div>

When I use test fixtures to populate test data into mysql database I am  
running into an unexpected behavior. Only columns explicitly defined  
in the fixture is populated into the database. However, created\_on,  
created\_by, updated\_on, updated\_by fields along with all fields  
normally populated by observers are NULL. For example, I have a couple  
fields that have their values calculated via observers. I want to test  
that these calculations are performed correctly by the observer, so I  
don’t want to hard code their values in the fixture.

Has anyone else run into this issue? If so, how did you perform  
testing of these fields? I realize that I could perform these tests  
without fixtures by creating and saving the object. Behind the scenes,  
Active Record populates all the fields in the expected manner. Then I  
could find the saved record and assert\_equal the expected calculations.  
However this approach seems brittle and I rather use fixtures. It  
doesn’t seem (from the results) that I am getting that the fixtures  
functionality uses Active Record to serialize data to mysql.

Thanks!

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [December 27, 2006, 3:51am UTC](https://www.ruby-forum.com/t/ruby-on-rails-test-fixtures/80456/2 "2006-12-27T03:51:10Z")

</div>

removed\_email\_address@domain.invalid wrote:

> When I use test fixtures to populate test data into mysql database I am  
> running into an unexpected behavior  
> Probably the Ruby on Rails mailing list will have lots of folks who  
> would be able to help. Here’s info about it:

> **[Ruby on Rails](https://rubyonrails.org)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.
