Running tests with command + R

10 views
Skip to first unread message

August Lilleaas

unread,
Jun 15, 2008, 8:04:28 AM6/15/08
to Ruby on Rails: TextMate
Tests in 2.1 does this:

require 'test_helper'

While the pre 2.1 tests did this:

require File.dirname(__FILE__) + '/../test_helper'

As textmate isn't aware of the load path stuff Rails does, it
(obviously) causes it to yield "LoadError: no such file to load —
test_helper" when trying to run a 2.1 test with command + R.

I've heard some people say that textmate should run the tests using
the rake tasks or something. I don't know much about textmate bundles,
so I can't do much about this (I spent ~ 2 hours trying to make it
work, but gave up). Would be very sweet if someone could update the
bundle so that we can again run tests directly from t3h mate.

Nic Williams

unread,
Jun 15, 2008, 8:06:27 AM6/15/08
to rubyonrail...@googlegroups.com
Yeah I don't know why rails moved away from explicit require statement in the generated test files. Annoying.
--
Dr Nic Williams
* Learn TextMate for Rails2 - http://peepcode.com/products/textmate-for-rails-2 *
Training in Ruby/Rails/JavaScript - http://drnicacademy.com
Fun with Ruby/Rails/Javascript - http://drnicwilliams.com
Photos of our new daughter & family- http://flickr.com/photos/drnic

Nic Williams

unread,
Jun 15, 2008, 8:09:42 AM6/15/08
to rubyonrail...@googlegroups.com
So as you figured out, when rails runs the tests, its already updated the $LOAD_PATH with RAILS_ROOT/test but when you run the test file directly (which should successfully run the tests) it has not yet run the config/environment.rb file thus no $LOAD_PATH fixes.

This isn't a TextMate-bundle specific problem. I should be able to run the following from the cmd-line, imo:

ruby test/units/person_test.rb

and have the tests run.

I think rails needs re-patching so that the line you mention below is in all generators. August - you want to do this for the good of man-kind?

Nic

On Sun, Jun 15, 2008 at 10:04 PM, August Lilleaas <augustl...@gmail.com> wrote:

August Lilleaas

unread,
Jun 15, 2008, 8:19:59 AM6/15/08
to Ruby on Rails: TextMate
Sort of already tried, here's the commit:
http://github.com/rails/rails/commit/e8170805df1a32119db9d328daee1239b338ac71
(see the comments). Felt a bit like talking to debian core peeps about
installing gems with 'gem' instead of apt-get - They Have Decided And
Won't Listen To You.

But hey, your voice ranks higher than mine, perhaps it helps if you
whine a bit about it as well? ; )

On Jun 15, 2:09 pm, "Nic Williams" <drnicwilli...@gmail.com> wrote:
> So as you figured out, when rails runs the tests, its already updated the
> $LOAD_PATH with RAILS_ROOT/test but when you run the test file directly
> (which should successfully run the tests) it has not yet run the
> config/environment.rb file thus no $LOAD_PATH fixes.
> This isn't a TextMate-bundle specific problem. I should be able to run the
> following from the cmd-line, imo:
>
> ruby test/units/person_test.rb
>
> and have the tests run.
>
> I think rails needs re-patching so that the line you mention below is in all
> generators. August - you want to do this for the good of man-kind?
>
> Nic
>
> On Sun, Jun 15, 2008 at 10:04 PM, August Lilleaas <augustlille...@gmail.com>
> wrote:
>
>
>
>
>
> > Tests in 2.1 does this:
>
> > require 'test_helper'
>
> > While the pre 2.1 tests did this:
>
> > require File.dirname(__FILE__) + '/../test_helper'
>
> > As textmate isn't aware of the load path stuff Rails does, it
> > (obviously) causes it to yield "LoadError: no such file to load —
> > test_helper" when trying to run a 2.1 test with command + R.
>
> > I've heard some people say that textmate should run the tests using
> > the rake tasks or something. I don't know much about textmate bundles,
> > so I can't do much about this (I spent ~ 2 hours trying to make it
> > work, but gave up). Would be very sweet if someone could update the
> > bundle so that we can again run tests directly from t3h mate.
>
> --
> Dr Nic Williams
> * Learn TextMate for Rails2 -http://peepcode.com/products/textmate-for-rails-2*
> Training in Ruby/Rails/JavaScript -http://drnicacademy.com
> Fun with Ruby/Rails/Javascript -http://drnicwilliams.com

Nic Williams

unread,
Jun 15, 2008, 8:28:15 AM6/15/08
to rubyonrail...@googlegroups.com
I dropped in a comment, but that was just to make myself feel better.

Ultimately we might be better with a "Fix crap 'require 'test_helper'" Command, or perhaps a rake/sake task to run over your source to clean it up + put back in the relative require statement.
* Learn TextMate for Rails2 - http://peepcode.com/products/textmate-for-rails-2 *
Training in Ruby/Rails/JavaScript - http://drnicacademy.com
Fun with Ruby/Rails/Javascript - http://drnicwilliams.com

August Lilleaas

unread,
Jun 15, 2008, 1:43:34 PM6/15/08
to Ruby on Rails: TextMate
Isn't that a bit much? The change could be reverted, and then someone
could make the rake task available somehow (weblog.rubyonrails.org?
*shrug*), but not in the Rails core. Sounds weird to have a task in
the Rails core that is certainly going to be void in the future.

Is dropping a note to the rails core mailing list a good idea,
perhaps? *hint* \o/

On Jun 15, 2:28 pm, "Nic Williams" <drnicwilli...@gmail.com> wrote:
> I dropped in a comment, but that was just to make myself feel better.
> Ultimately we might be better with a "Fix crap 'require 'test_helper'"
> Command, or perhaps a rake/sake task to run over your source to clean it up
> + put back in the relative require statement.
>
> On Sun, Jun 15, 2008 at 10:19 PM, August Lilleaas <augustlille...@gmail.com>
> wrote:
>
>
>
>
>
> > Sort of already tried, here's the commit:
>
> >http://github.com/rails/rails/commit/e8170805df1a32119db9d328daee1239...

August Lilleaas

unread,
Jul 3, 2008, 6:33:33 AM7/3/08
to Ruby on Rails: TextMate
Did anything happen with this, other than the rails core team not
changing their mind after the discussion on the commit at github?

Nic Williams

unread,
Jul 3, 2008, 7:31:56 AM7/3/08
to rubyonrail...@googlegroups.com
I'm not aware of any related changes. 

Perhaps leave a bug report on the rails lighthouse ticket system and then you might get direct feedback on the issue. If you feel keen, submit a patch to the generators.
* Learn TextMate for Rails2 - http://peepcode.com/products/textmate-for-rails-2 *
Training in Ruby/Rails/JavaScript - http://drnicacademy.com
Fun with Ruby/Rails/Javascript - http://drnicwilliams.com
Reply all
Reply to author
Forward
0 new messages