Ruby Forum Rails-core (closed, excessive spam) > Problem with generated tests

Posted by Lance Carlson (Guest)
on 24.06.2008 08:36
(Received via mailing list)
Hi everyone,

This may not be an issue, but I'm just checking. When I generate a
scaffold in rails 2.1, all of the tests that get generated have a
require 'test_helper' at the top. When you try to run a test
individually through command line, you get an error:

$ ruby test/functional/foos_controller_test.rb
test/functional/foos_controller_test.rb:1:in `require': no such file
to load -- ../test_helper (LoadError)

Obviously changing this to require File.dirname(__FILE__) +
"../test_helper" fixes the problem, however is there a rake task that
lets you run tasks individually or is this just a bug?

Sorry if I'm being nit-picky, but I like generators and think they
should be kept up to date. :)

TIA,
-Lance
Posted by Lance Carlson (Guest)
on 24.06.2008 08:41
(Received via mailing list)
Sorry,

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

I didn't test my test ;)
Posted by Jeffrey Hardy (Guest)
on 24.06.2008 08:56
(Received via mailing list)
Hi Lance --

On 24-Jun-08, at 2:35 AM, Lance Carlson wrote:
> This may not be an issue, but I'm just checking. When I generate a
> scaffold in rails 2.1, all of the tests that get generated have a
> require 'test_helper' at the top. When you try to run a test
> individually through command line, you get an error:
>
> $ ruby test/functional/foos_controller_test.rb
> test/functional/foos_controller_test.rb:1:in `require': no such file
> to load -- ../test_helper (LoadError)

You can use the -I option to include the test dir in the load path
when running from the command line:

$ ruby -Itest test/functional/foos_controller_test.rb


/Jeff
Posted by Lance Carlson (Guest)
on 24.06.2008 09:01
(Received via mailing list)
Ah OK. Thanks Jeff. Sorry for the false alarm.
Posted by Rob Sanheim (rsanheim)
on 24.06.2008 15:41
(Received via mailing list)
On Tue, Jun 24, 2008 at 2:35 AM, Lance Carlson <lancecarlson@gmail.com> 
wrote:
> to load -- ../test_helper (LoadError)
>
This sounds like a bug - many users will try to run the test directly
either within textmate or their ide, or just by doing 'ruby
foo_test.rb'.  Using the relative path is the right way to go...

- Rob
Posted by Aliaksey Kandratsenka (Guest)
on 24.06.2008 15:50
(Received via mailing list)
У Аўт, 24/06/2008 у 09:40 -0400, Rob Sanheim піша:

> This sounds like a bug - many users will try to run the test directly
> either within textmate or their ide, or just by doing 'ruby
> foo_test.rb'.  Using the relative path is the right way to go...

+1

--
Aliaksey Kandratsenka <alkondratenko@gmail.com>
Posted by Raul Murciano (raul)
on 24.06.2008 16:03
(Received via mailing list)
It's being discussed here: http://github.com/rails/rails/commit/e8170805

--
Raul Murciano - Freelance Web Developer
http://raul.murciano.net
Posted by Rob Sanheim (rsanheim)
on 24.06.2008 16:22
(Received via mailing list)
On Tue, Jun 24, 2008 at 9:59 AM, Raul Murciano <raul@murciano.net> 
wrote:
>
> It's being discussed here: http://github.com/rails/rails/commit/e8170805
>

Great, only three places to check for core discussion now!
Lighthouse, github, and here. ;)

- Rob
Posted by Chad Woolley (Guest)
on 24.06.2008 16:30
(Received via mailing list)
On Tue, Jun 24, 2008 at 7:21 AM, Rob Sanheim <rsanheim@gmail.com> wrote:
> Great, only three places to check for core discussion now!
> Lighthouse, github, and here. ;)

Well, a ticket system and a mailing list are pretty traditional for
Open Source projects.

But using your SCM as a messaging platform?  Come on, that's taking
the social networking thing too far...  I pray that I never see the
official Twitter channel for an open source project I care about,
because I ain't going there...

-- Chad