Rake test:unit gives Command failed with status (1):

On 20 November 2010 20:11, Colin L. [email protected] wrote:

What happens if you run one of the tests explicitly, for example
ruby -I test test/unit/comment_test.rb

Otherwise I am getting out of my depth I think. Can anyone else
suggest what the problem may be?

From the stack trace, it does look like it’s failing at story_test
(unless that list of test files includes every single test in the
directory…).
As an extension of Colin’s suggestion to run one test; what if you
remove the story_test.rb file from the directory to test running
everything apart from that.

If it works without the story_test, I’d guess there’s something in
there that’s making it not parse…

On 20 November 2010 18:21, Neil B. [email protected] wrote:

** Invoke db:test:load (first_time)
“test/unit/user_mailer_test.rb” “test/unit/friendship_test.rb”
/usr/lib/ruby/1.8/rake.rb:1010:in sh' /usr/lib/ruby/1.8/rake.rb:597:in invoke_with_call_chain’
/usr/lib/ruby/1.8/rake.rb:2068:in standard_exception_handling' /usr/lib/ruby/1.8/rake.rb:1998:in run’
/usr/bin/rake:28

What happens if you run one of the tests explicitly, for example
ruby -I test test/unit/comment_test.rb

That is a capital i in -I test, telling ruby to include the test folder.

Otherwise I am getting out of my depth I think. Can anyone else
suggest what the problem may be?

Colin

On 20 November 2010 21:30, Neil B. [email protected] wrote:

Does any of this help?

Michael P. wrote in post #962835:

On 20 November 2010 20:11, Colin L. [email protected] wrote:

What happens if you run one of the tests explicitly, for example
ruby -I test test/unit/comment_test.rb

neil@baby6:~/*****$ ruby -I test test/unit/comment_test.rb
ruby index.rb

Is that all? What on earth is that about? What if you try one of the
other tests?

Colin

Does any of this help?

Michael P. wrote in post #962835:

On 20 November 2010 20:11, Colin L. [email protected] wrote:

What happens if you run one of the tests explicitly, for example
ruby -I test test/unit/comment_test.rb

neil@baby6:~/$ ruby -I test test/unit/comment_test.rb
ruby index.rb
neil@baby6:~/
$

As an extension of Colin’s suggestion to run one test; what if you
remove the story_test.rb file from the directory to test running
everything apart from that.

That gives

/usr/bin/ruby1.8 -I"lib:test"
“/usr/lib/ruby/1.8/rake/rake_test_loader.rb” “test/unit/comment_test.rb”
“test/unit/user_mailer_test.rb” “test/unit/friendship_test.rb”
“test/unit/helpers/friendship_helper_test.rb”
“test/unit/helpers/profile_helper_test.rb”
“test/unit/helpers/community_helper_test.rb” “test/unit/user_test.rb”
ruby index.rb
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.8 -I"lib:test"
"/usr/lib/ru…]

(See full trace by running task with --trace)
neil@baby6:~/wagging_tales$

Colin L. wrote in post #962842:

On 20 November 2010 21:30, Neil B. [email protected] wrote:

Does any of this help?

Michael P. wrote in post #962835:

On 20 November 2010 20:11, Colin L. [email protected] wrote:

What happens if you run one of the tests explicitly, for example
ruby -I test test/unit/comment_test.rb

neil@baby6:~/*****$ ruby -I test test/unit/comment_test.rb
ruby index.rb

Is that all? What on earth is that about? What if you try one of the
other tests?

Colin
neil@baby6:~/$ ruby -I test test/unit/story_test.rb
ruby index.rb
neil@baby6:~/
$

Gleble

On 20 November 2010 21:50, Neil B. [email protected] wrote:

neil@baby6:~/wagging_tales$ ruby -I test test/unit/story_test.rb
ruby index.rb
neil@baby6:~/wagging_tales$

What happens if you put a trivial ruby program there and try and run
it? Make a file test/unit/puts.rb and in it put just one line

puts “hello”

then run it

ruby test/unit/puts.rb

If that works (display hello obviously) then it is something about
your test files. Empty one of the test files, and gradually build it
back up until it starts to fail. That will hopefully give us a clue
as to what is going on.

Colin

If that works (display hello obviously) then it is something about
your test files. Empty one of the test files, and gradually build it
back up until it starts to fail. That will hopefully give us a clue
as to what is going on.

Colin

It did work. I’ve removed all the tests except story_test.rb which looks
like

require ‘test_helper’

class StoryTest < ActiveSupport::TestCase
def test_should_be_valid_with_author
s = Story.create(:author => ‘neil’, :title => ‘Story’, :body =>
‘test’)
assert s.errors.on(:author)
end
end

I get the same error as before until I remove the line

unit/story_test.rb

If I run

ruby test/unit/story_test.rb

I get

test/unit/story_test.rb:1:in `require’: no such file to load –
test_helper (LoadError)
from test/unit/story_test.rb:1

Could this be the problem, why can’t it find test_helper.rb

Gleble

Colin L. wrote in post #962924:

On 21 November 2010 11:12, Neil B. [email protected] wrote:

I get the same error as before until I remove the line

unit/story_test.rb

What do you mean remove that line? I don’t see that line in the file
anywhere.
Sorry, should read I get the same error as before until I remove the
line

require ‘test_helper’

If I edit story_test.rb so it only contains require ‘test_helper’ this
happens

neil@baby6:~/$ ruby -I test test/unit/story_test.rb
ruby index.rb
neil@baby6:~/
$

Sorry wrong attachment

On 21 November 2010 11:12, Neil B. [email protected] wrote:

I get the same error as before until I remove the line

unit/story_test.rb

What do you mean remove that line? I don’t see that line in the file
anywhere.

Could this be the problem, why can’t it find test_helper.rb

You get that because with the require ‘test_helper’ line you need to
tell ruby where to find it, as we did previously

ruby -I test test/unit/story_test.rb

The -I test tells it to include (-I) the folder test in it’s search.
When you do rake test it does the -I for you.

Can you post the contents of test/test_helper.rb

Also try removing everything from story_test.rb except the test_helper
line and try to run that (with the -I test) in the ruby call.

Colin L. wrote in post #962955:

I’ve attached test_help.rb Had to go to /vendor/railties/lib to find
it, is that right?

You have not mentioned it but I presume your app runs ok? If not then
post environment.rb also.

Yes it works fine.

Gleble

On 21 November 2010 14:26, Neil B. [email protected] wrote:

line
Attachments:
http://www.ruby-forum.com/attachment/5431/test_helper.rb

I see that requires test_help. Please post that also. Did you not
think I might have wanted to see that also? Just post it inline
unless it is large.

You have not mentioned it but I presume your app runs ok? If not then
post environment.rb also.

Colin

On Nov 21, 3:46pm, Neil B. [email protected] wrote:

Yes it works fine.
My guess is that somewhere in your app you have a ruby script
(probably called index.rb) that expects to be invoked on the command
line with some arguments.When rails loads up your tests it loads
everything in app/models, app/controllers (and probably a few other
places) and ends up loading your index.rb script, which blows up since
it wasn’t provided with the arguments it expects.

Fred

On 21 November 2010 16:53, Frederick C. [email protected]
wrote:

You have not mentioned it but I presume your app runs ok? If not then
post environment.rb also.

Yes it works fine.

My guess is that somewhere in your app you have a ruby script
(probably called index.rb) that expects to be invoked on the command
line with some arguments.When rails loads up your tests it loads
everything in app/models, app/controllers (and probably a few other
places) and ends up loading your index.rb script, which blows up since
it wasn’t provided with the arguments it expects.

Just what I was about to suggest. Well that’s my story anyway :slight_smile:

It is amazing how something that seems obvious once pointed out can be
so elusive.

Colin

On 21 November 2010 17:52, Neil B. [email protected] wrote:

ruby index.rb

which I think was the problem. Thanks everyone.

For the record can you tell us where the offending file was? Was it
called index.rb?

Colin

Colin L. wrote in post #963001:

On 21 November 2010 17:52, Neil B. [email protected] wrote:

ruby index.rb

which I think was the problem. Thanks everyone.

For the record can you tell us where the offending file was? Was it
called index.rb?

Colin

It was called index.rb. There was one in app/controllers and one in
app/models. I’ve attached the offending file. This morning they have
both come back and cause the same problem. Removing them makes all OK.
Have you any idea what the file is? Have you any idea how to stop it
coming back?

Gleble

On 22 November 2010 09:01, Neil B. [email protected] wrote:

It was called index.rb. There was one in app/controllers and one in
app/models. I’ve attached the offending file. This morning they have
both come back and cause the same problem. Removing them makes all OK.
Have you any idea what the file is? Have you any idea how to stop it
coming back?

I suggest watching to find what it is you do that makes them come
back. Looking at the file, presumably it is something to do with
Ferret.

Colin

Frederick C. wrote in post #962968:

On Nov 21, 3:46pm, Neil B. [email protected] wrote:

Yes it works fine.
My guess is that somewhere in your app you have a ruby script
(probably called index.rb) that expects to be invoked on the command
line with some arguments.
Fred

I think you’ve got it, that gets rid of the line

ruby index.rb

which I think was the problem. Thanks everyone.

When I run rake test:units now I get

(See full trace by running task with --trace)
neil@baby6:~/$ rake test:units
(in /home/neil/
*)
/usr/bin/ruby1.8 -I"lib:test"
“/usr/lib/ruby/1.8/rake/rake_test_loader.rb” “test/unit/story_test.rb”
Loaded suite /usr/lib/ruby/1.8/rake/rake_test_loader
Started
E
Finished in 0.411785 seconds.

  1. Error:
    test_should_be_valid_with_story(StoryTest):
    ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table:
    avatars: DELETE FROM “avatars” WHERE 1=1

1 tests, 0 assertions, 0 failures, 1 errors
rake aborted!
Command failed with status (1): [/usr/bin/ruby1.8 -I"lib:test"
"/usr/lib/ru…]

(See full trace by running task with --trace)

So I think I just have to sort my tests out now.

Gleble