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...
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.
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.
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
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
What do you mean remove that line? I don't see that line in the file anywhere.
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
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.
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.
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.
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 <data dir> <index dir>
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...]
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?