# RAILS\_ROOT issue - plugin unit tests won't work under vendor/plugins

**URL:** <https://www.ruby-forum.com/t/rails-root-issue-plugin-unit-tests-wont-work-under-vendor-plugins/162521>\
**Category:** Rails\
**Created:** [March 10, 2009, 8:55pm UTC](https://www.ruby-forum.com/t/rails-root-issue-plugin-unit-tests-wont-work-under-vendor-plugins/162521 "2009-03-10T20:55:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![lee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/bc8723/32.png) [@lee](https://www.ruby-forum.com/u/lee)\
**Post date:** [March 10, 2009, 8:55pm UTC](https://www.ruby-forum.com/t/rails-root-issue-plugin-unit-tests-wont-work-under-vendor-plugins/162521/1 "2009-03-10T20:55:05Z")

</div>

Hi,

I’m relatively new to Ruby/Rails (and developing on Windows boxes).  
I’ve inherited a system and am trying to get the unit tests for a  
plugin running in Windows. Specifically, I have a plugin with some  
unit tests running under my app’s vendor/plugins dir. When I try and  
run a specific model unit test I get a failure:

* * *

## c:/ruby/lib/ruby/site\_ruby/1.8/rubygems/custom\_require.rb:27:in `gem\_original\_require’: no such file to load – C:/Documents and Settings/leedoejgi/workspace/Ruby/config/environment (LoadError)

It’s looking in C:/Documents and Settings/leedoejgi/workspace/Ruby/  
config/environment instead of C:/Documents and Settings/leedoejgi/  
workspace/Ruby/myapp/clients/myapp\_client/config/environment.

The unit test is requiring test\_helper in the same directory, which  
looks like this:

* * *

$:.reject! { |e| e.include? ‘TextMate’}  
ENV[“RAILS\_ENV”] = “test”

unless defined? RAILS\_ROOT  
RAILS\_ROOT = ‘…/…/…’  
end

## require File.expand\_path("#{RAILS\_ROOT}/config/environment") require ‘test\_help’ require ‘logger’ require ‘fileutils’

If I set an environment variable for RAILS\_ROOT in Windows of and make  
the following changes to test\_helper give it the right RAILS\_ROOT

* * *

$:.reject! { |e| e.include? ‘TextMate’}  
ENV[“RAILS\_ENV”] = “test”

# Support for NetBeans testing in Windows with RAILS\_ROOT set in

environement.  
if !ENV[‘RAILS\_ROOT’].empty?  
RAILS\_ROOT = ENV[‘RAILS\_ROOT’]  
end

unless defined? RAILS\_ROOT  
RAILS\_ROOT = ‘…/…/…’  
end

## require File.expand\_path("#{RAILS\_ROOT}/config/environment") require ‘test\_help’ require ‘logger’ require ‘fileutils’

I now get a different error:

* * *

## c:/ruby/lib/ruby/gems/1.8/gems/rails-2.0.2/lib/initializer.rb:499:in `replace’: can’t modify frozen string (TypeError)

Can anyone offer me guidance on how to get the unit tests running  
under Windows?

Thanks!

Lee
