Forum: Ruby on Rails Problem running unit tests

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eden B. (Guest)
on 2006-04-16 05:24
(Received via mailing list)
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.
Eden B. (Guest)
on 2006-04-17 19:36
(Received via mailing list)
How about you weekday folk?  Anyone have an idea about this problem?
Ray B. (Guest)
on 2006-04-17 22:45
(Received via mailing list)
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
Eden B. (Guest)
on 2006-04-18 00:25
(Received via mailing list)
Ray,

Thank you for the suggestion.

Line 18 is currently:

  self.use_transactional_fixtures = true

Any other ideas?

Eden
Ray B. (Guest)
on 2006-04-18 02:16
(Received via mailing list)
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
Eden B. (Guest)
on 2006-04-18 02:31
(Received via mailing list)
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
Derek H. (Guest)
on 2006-06-19 01:03
(Received via mailing list)
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
Alan F. (Guest)
on 2006-06-19 15:58
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.
This topic is locked and can not be replied to.