Forum: Ruby on Rails RAILS_ROOT issue - plugin unit tests won't work under vendor/plugins

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.
Lee (Guest)
on 2009-03-10 21:55
(Received via mailing list)
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'
<snip>
----

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'
<snip>
----

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
This topic is locked and can not be replied to.