Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"undefined method `fixtures' for ActiveSupport::TestCase:Class" while testing with Rails 3.1

I'm writing tests for a Gem and after a couple of hours trying to get rid of this, decided to look around - and to my surprise, there's not a single reference to it on Google (apart from one on mongoid, where people simply ignored it).

So, the problem is simple: I have this block on my test initialization:

class ActiveSupport::TestCase
  fixtures :all
end

but the tests fail to execute:

`<class:TestCase>': undefined method `fixtures' for ActiveSupport::TestCase:Class (NoMethodError)

The gem depends on Rails 3 and every dependency is checked & double-checked. The code is on github, in case anyone wants to check (https://github.com/herval/acts_as_recommendable) I'm out of ideas. Anyone share a light?

like image 517
herval Avatar asked Dec 27 '11 03:12

herval


2 Answers

I'm not sure, but it seems that fixtures cannot be used with mongoid.

Take a look at this for further details:

https://groups.google.com/forum/?fromgroups=#!topic/mongoid/tqlx3j88Lqw

like image 73
Zen Avatar answered Nov 06 '22 04:11

Zen


It's been a long time since I used Rails' built in testing, so take this with a grain of salt. I'm guessing that the actual ActiveSupport::TestCase class hasn't actually been loaded before the initializer is being reached.

It might be enough to just add require 'test_help' at the top of the initializer.

like image 30
Ryan Avatar answered Nov 06 '22 06:11

Ryan