Ruby on Rails: Unit Testing non activerecord models and still load fixtures
Posted
by
Vaibhav Gumashta
on Stack Overflow
See other posts from Stack Overflow
or by Vaibhav Gumashta
Published on 2011-02-06T07:23:14Z
Indexed on
2011/02/06
7:25 UTC
Read the original article
Hit count: 253
I may be missing something but I am stuck in this scenario:
I have a non activerecord model, which I want to test. I have derived its test case class from: Test::Unit::TestCase.
However, the test case class for the model, uses within itself, other activerecord model classes and I want to load fixtures for them. My problem is that the fixtures class method is available only when I subclass the test case class from ActiveSupport::TestCase (it is defined within ActiveRecord::TestFixtures which gets included in ActiveSupport::TestCase).
Any help, coz running the tests gives me the error: undefined method "fixtures" (which is understandable) and in case I derive my test case class from ActiveSupport::TestCase it complains that there is no corresponding DB table. Also, I don't want to create a dummy table for backing my model class.
Thanks a ton!
© Stack Overflow or respective owner