views:

74

answers:

0

Hi,

I have some unit tests for a plugin I have written. This plugin is attached to a sample rails application. Both the rails application and the plugin is configured for rails 2.2.2. So far my system had ruby 1.8.7 with rails 2.2.2 and I faced NO issues running the unit tests in my plugin or the tests of my sample rails app.

Just a couple of days back I installed rails 2.3.5 alongside the existing rails 2.2.2. Even now my rails app and its unit tests run just fine. However, when I try to run the Unit tests of my plugin I get the following error:

Missing the Rails 2.2.2 gem. Please gem install -v=2.2.2 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.

After slogging over this issue for long I figured out that may be I need to freeze rails 2.2.2 in my app. And so I did it. But now when I try again to run the plugin tests I get a different error:

undefined method `fixture_path=' for Test::Unit::TestCase:Class (NoMethodError)

The line of code that seems to generate this error is:

Test::Unit::TestCase.fixture_path = File.expand_path(File.dirname(__FILE__)
+ '/fixtures')

in test_helper.rb at RAILS_ROOT/vendor/plugins/sample_plugin/test/
The fixture files are located at RAILS_ROOT/vendor/plugins/sample_plugin/test/fixtures/

This line is used to tell the rails test environment where the fixture files are located so that I can populate test data into the test db.

What I don't understand is why the plugin CANNOT detect rails 2.2.2 when my rails app CAN? And even when I freeze rails 2.2.2 in my app, why am I getting the UNDEFINED METHOD error?
Any workaround for this problem? All I need to do is be able to run the unit tests of my plugin, since I have spent considerable amount of time writing them.

Thanks in advance

Vignesh