# Another test question for Rails

**URL:** <https://www.ruby-forum.com/t/another-test-question-for-rails/110036>\
**Category:** Rails\
**Created:** [July 21, 2007, 9:26pm UTC](https://www.ruby-forum.com/t/another-test-question-for-rails/110036 "2007-07-21T21:26:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [July 21, 2007, 9:26pm UTC](https://www.ruby-forum.com/t/another-test-question-for-rails/110036/1 "2007-07-21T21:26:44Z")

</div>

I added in:

config.active\_record.schema\_format = :sql

But I have another problem. I have a deferred constraint which means  
that it does not trigger until the commit. But… the test rig does not  
do a commit. It just rolls back the changes. Sort of a cute trick I  
suppose but in my case, it is effectively disabling my constraint.

I thought I saw somewhere where you could not run your tests this way.  
That it would use another approach. But I don’t know if I’m dreaming or  
not. I have not found how to do it yet.

Does anyone have any pointers?

Thanks,  
Perry

---

<div class="post-metadata">

**Author:** ![pedz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/839c29/32.png) [@pedz](https://www.ruby-forum.com/u/pedz)\
**Post date:** [July 26, 2007, 12:45am UTC](https://www.ruby-forum.com/t/another-test-question-for-rails/110036/2 "2007-07-26T00:45:51Z")

</div>

Perry S. wrote:

> But I have another problem. I have a deferred constraint which means  
> that it does not trigger until the commit. But… the test rig does not  
> do a commit. It just rolls back the changes. Sort of a cute trick I  
> suppose but in my case, it is effectively disabling my constraint.
> 
> I thought I saw somewhere where you could not run your tests this way.  
> That it would use another approach. But I don’t know if I’m dreaming or  
> not. I have not found how to do it yet.

The global technique is in test/test\_helper.rb:

self.use\_transactional\_fixtures = true

The cheap solution appears to involve setting that to ‘false’, and  
running  
all tests in committed mode.

Note that transactions are not to keep your test data isolated. Fixtures  
take care of that. The transactions help the tests go fast, because they  
reduce database activity to a series of in-memory or buffered  
manipulations.  
At rollback time these vanish efficiently, without causing your hard  
drive’s  
read-write heads to move or anything.

So you might notice slower tests. I would research some way to change  
that  
item per-test, but you must do that before the test’s fixture system  
engages, so that would involve reading the source, monkey-patching, and  
other fun things.

Anything for faster tests!!!

–  
Phlip  
[http://www.oreilly.com/catalog/9780596510657/](http://www.oreilly.com/catalog/9780596510657/)  
“Test Driven Ajax (on Rails)”  
assert\_xpath, assert\_javascript, & assert\_ajax
