# Problem running unit tests

**URL:** <https://www.ruby-forum.com/t/problem-running-unit-tests/57911>\
**Category:** Rails\
**Created:** [April 16, 2006, 3:24am UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911 "2006-04-16T03:24:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [April 16, 2006, 3:24am UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911/1 "2006-04-16T03:24:04Z")

</div>

I am running Rails 1.1.2 with Ruby 1.82-15. My database is Postgresql.  
I  
haven’t had any problems generating models, migrations, using scaffolds,  
and  
generally building and using my application, but I haven’t been able to  
get  
testing to work. I initially just ignored the problem and kept  
developing,  
but would like to add proper testing from here on out.

Currently when I type rake in my application directory, it attempts to  
load  
my unit tests (all generated files with single default assertion), but  
immediately fails with the error:

./test/unit/…/test\_helper.rb:18: undefined method  
‘use\_transactional\_fixtures=’

I read up on transactional\_fixtures and testing in general and also  
searched  
this list and in Google, but haven’t been able to find any reference to  
this  
problem. It is probably something stupid simple, but I am at a dead end  
for  
now.

Has anyone else run into this? At this point I have deleted all my  
controllers and views along with the functional test fixtures just to  
attempt to narrow the problem down with just models and unit tests.

Any help is very much appreciated.

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [April 17, 2006, 5:36pm UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911/2 "2006-04-17T17:36:18Z")

</div>

How about you weekday folk? Anyone have an idea about this problem?

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [April 17, 2006, 8:45pm UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911/3 "2006-04-17T20:45:09Z")

</div>

Eden B. wrote:

> On 4/15/06, _Eden B._ \<removed\_email\_address@domain.invalid

> ```
> Currently when I type rake in my application directory, it attempts
> to load my unit tests (all generated files with single default
> assertion), but immediately fails with the error:
> 
> ./test/unit/../test_helper.rb:18: undefined method
> 'use_transactional_fixtures='
> 
> ```

You are invoking the method use\_transactional\_fixtures=.

There is no such method.

Does line 18 of ./test/test\_helper.rb say

use\_transactional\_fixtures=true

You probably want to replace this with

self.use\_transactional\_fixtures = true

–

Ray

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [April 18, 2006, 12:16am UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911/4 "2006-04-18T00:16:01Z")

</div>

Eden B. wrote:

> Ray,
> 
> Thank you for the suggestion.
> 
> Line 18 is currently:
> 
> self.use\_transactional\_fixtures = true

After posting I realized that that was probably true and that your  
problem is that you aren’t requiring the right modules.

Do you have

require ‘test\_help’

? I can get the same error as you if I comment out that line in my  
test\_helper.rb.

–

Ray

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [April 17, 2006, 10:25pm UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911/5 "2006-04-17T22:25:11Z")

</div>

Ray,

Thank you for the suggestion.

Line 18 is currently:

self.use\_transactional\_fixtures = true

Any other ideas?

Eden

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [April 18, 2006, 12:31am UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911/6 "2006-04-18T00:31:29Z")

</div>

Hi Ray,

Here is my whole test\_helper.rb with comments removed:

ENV[“RAILS\_ENV”] = “test”  
require File.expand\_path(File.dirname( **FILE** ) +  
“/…/config/environment”)  
require ‘test\_help’

class Test::Unit::TestCase  
self.use\_transactional\_fixtures = true  
self.use\_instantiated\_fixtures = false  
end

Also, just in case something went wrong during my upgrade to 1.1.2, here  
is  
boot.rb:

unless defined?(RAILS\_ROOT)  
root\_path = File.join(File.dirname( **FILE** ), ‘…’)  
unless RUBY\_PLATFORM =~ /mswin32/  
require ‘pathname’  
root\_path = Pathname.new(root\_path).cleanpath(true).to\_s  
end  
RAILS\_ROOT = root\_path  
end

if File.directory?("#{RAILS\_ROOT}/vendor/rails")  
require “#{RAILS\_ROOT}/vendor/rails/railties/lib/initializer”  
else  
require ‘rubygems’  
require ‘initializer’  
end

Rails::Initializer.run(:set\_load\_path)

Thank you again for your help,

Eden

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [June 19, 2006, 1:58pm UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911/7 "2006-06-19T13:58:40Z")

</div>

Derek H. wrote:

> Anyone come up with a reason for this? I’m getting the same error when  
> running an app on linux. It works fine on mac osx.

Could it be you’re not running against the gem versions you think you  
are ? It looks almost like it was genberated with one version of rails  
and is running against an older version (which doesn’t have the  
transactional fixtures).

I’m not sure how to go about dumping out gem version numbers at runtime,  
but it might be worth trying something like that in your test file.

A.

---

<div class="post-metadata">

**Author:** ![Eden\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/6de8d8/32.png) [@Eden\_B](https://www.ruby-forum.com/u/Eden_B)\
**Post date:** [June 18, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/problem-running-unit-tests/57911/8 "2006-06-18T23:03:18Z")

</div>

Anyone come up with a reason for this? I’m getting the same error when  
running an app on linux. It works fine on mac osx.

- Derek

On 4/17/06, Eden B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> self.use\_transactional\_fixtures = true  
> root\_path =  
> require ‘initializer’
> 
> > Eden B. wrote:  
> > problem is that you aren’t requiring the right modules.  
> > Ray  
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
Derek H.  
HighGroove Studios - [http://www.highgroove.com](http://www.highgroove.com)  
San Mateo, CA | Atlanta, GA  
Keeping it Simple.  
650.276.0908
