You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
there is an issue running test cases with Command-R in a Rails 3 project. I got the following error doing it:
Errno::ENOENT: No such file or directory - /Users/dbreuer/path/to/rails3app/test/functional/config/database.yml
I digged into it and localized the "source" of the problem is concerned with the way Rails 3 sets it root path. In the file railties-3.0.0.beta/lib/rails/engine.rb the root path localization method is as follows:
15 def inherited(base)
16 unless abstract_railtie?(base)
17 base.called_from = begin
18 call_stack = caller.map { |p| p.split(':').first }
19 File.dirname(call_stack.detect { |p| p !~ %r[railties/lib/rails|rack/lib/rack] })
20 end
21 end
22
23 super
24 end
25
26 def find_root_with_flag(flag, default=nil)
27 root_path = self.called_from
28
29 while root_path && File.directory?(root_path) && !File.exist?("#{root_path}/#{flag}")
30 parent = File.dirname(root_path)
31 root_path = parent != root_path && parent
32 end
33
34 root = File.exist?("#{root_path}/#{flag}") ? root_path : default
35 raise "Could not find root path for #{self}" unless root
36
37 RUBY_PLATFORM =~ /(:?mswin|mingw)/ ?
38 Pathname.new(root).expand_path : Pathname.new(root).realpath
39 end
The variable called_from in line 27 points in my case always to the gem directory (which seems to be quite obvious to me). But then it will take always the default parameter as the root directory, which is Dir.pwd as specified in railties-3.0.0.beta/lib/rails/application/configurable.rb:
You could assign the default parameter as the root_path which will result in the correct resolution for the root variable and so in a successful execution of my test execution out of TextMate. But obviously that isn't the best thing to do. You could try first the called_from value and after that the default value to find the root directory but that isn't much better in my opinion. What I ask myself, there must be reason why it is as it is, and you should probably find a way to handle this in the TextMate Rails bundle. But I have no idea how to accomplish this.
The text was updated successfully, but these errors were encountered:
i have the same problem with TextMate and Rails 3 Tests.
For me this seems to be a problem of Rails. As you pointed out, it is only possible to run tests from the root of your project which is kind of inappropriate to me - but i am not deep enough in the rails 3.0 code to judge this.
My solution for this problem is to change the working directory before running the script in the run command of the Ruby bundle in TextMate like this:
Hi folks,
there is an issue running test cases with Command-R in a Rails 3 project. I got the following error doing it:
I digged into it and localized the "source" of the problem is concerned with the way Rails 3 sets it root path. In the file
railties-3.0.0.beta/lib/rails/engine.rb
the root path localization method is as follows:The variable
called_from
in line 27 points in my case always to the gem directory (which seems to be quite obvious to me). But then it will take always thedefault
parameter as the root directory, which isDir.pwd
as specified inrailties-3.0.0.beta/lib/rails/application/configurable.rb
:You could assign the
default
parameter as theroot_path
which will result in the correct resolution for theroot
variable and so in a successful execution of my test execution out of TextMate. But obviously that isn't the best thing to do. You could try first thecalled_from
value and after that thedefault
value to find the root directory but that isn't much better in my opinion. What I ask myself, there must be reason why it is as it is, and you should probably find a way to handle this in the TextMate Rails bundle. But I have no idea how to accomplish this.The text was updated successfully, but these errors were encountered: