Topic: Can't get file directory to find config/environment.

I'm trying to test my routes from integration/routes_test.rb
I go to "cd /test"
and run
ruby integration/routes_test.rb
and what I get is

/usr/local/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/lib/rails/application/configuration.rb:64:in `read': No such file or directory - /home/neoky/workspace/rails_site/test/config/database.yml (Errno::ENOENT)

in my routes_test.rb I have
require 'test_helper'

and from here:
site -> test -> test_helper.rb
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")

I've tried all sort of variations of that directory, but I can't come up with anything that gets rid for the test from the directory.
Even tried:
require (Rails.root.to_s + "/config/environment")

I get error messages saying they don't know what Rails is.

The only thing I found that worked was by making a config folder with database.yml inside of the test folder itself. Where I start getting other errors.

Thanks for any help I can get.

Re: Can't get file directory to find config/environment.

Same problem.
Looks like it is in include path, because it rises at
YAML::load(ERB.new(IO.read(paths.config.database.to_a.first)).result)
where
paths.config.database = "config/database.yml"

I am new to linux and ruby, so its hard to me to solve this problem.

Rails 3.0 beta
Ruby 1.9.1
IDE RubyMine

+ I've problems with autoload models
class ArticleTest < ActiveSupport::TestCase
  test "create new" do
    article = Article.create([... some data ...])
  end

Error test_create_new(ArticleTest):
NameError: uninitialized constant ArticleTest::Article

addiding require "article.rb" -- not found, only full path accepted
require "some/file/in/lib/folder/file.rb" -- not found

also
~/code/rails3/project$ ruby test/unit/article_test.rb
test/unit/article_test.rb:1:in `require': no such file to load -- test_helper (LoadError)
    from test/unit/article_test.rb:1:in `<main>'


I am using ruby 1.9.1 by rvm

Before this on system Ruby 1.8.7 and stable rails all was works fine.

Last edited by Azazello (2010-03-17 16:02:10)

Re: Can't get file directory to find config/environment.

I'm pretty new to Ruby and Rails as well, but if you run the tests from the project root directory instead of in the test directory and use -I option it seems to work. The -I option is needed to add the test directory to the ruby load path so the test_helper.rb file can be located.

Example:
ruby -Itest test/unit/test_model.rb