Problem running unit tests


#1

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.


#2

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


#3

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


#4

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


#5

Ray,

Thank you for the suggestion.

Line 18 is currently:

self.use_transactional_fixtures = true

Any other ideas?

Eden


#6

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


#7

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.


#8

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 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


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