Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby rake/testtask producing incorrect command

Tags:

ruby

rake

testing

I have tests for my project broken up into multiple files - test/test_1.rb and test/test_2.rb.

Running 'rake test' gives:

$ rake test
ruby -I"lib:test" -I"/foo/rake-0.9.2/lib" "/foo/rake_test_loader.rb" "test/test_general.rb test/test_cv.rb"
/home/rob/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2/lib/rake/rake_test_loader.rb:11:in `require': no such file to load -- /home/rob/src/robsyme/bioruby-chado/test/test_general.rb test/test_cv.rb (LoadError)
... #you can guess the rest

Note the last argument in the ruby command : "test/test_general.rb test/test_cv.rb"

If I remove the quotes (splitting the last argument into two arguments), the tests run perfectly.

  1. Why would rake's test runner be grouping the two files together into the one argument?
  2. Am I doing something wrong with the rake test setup?

Environment:

$ grep -A4 TestTask Rakefile 
Rake::TestTask.new(:test) do |test|
  test.libs << 'test'
  test.pattern = FileList['test/**/test_*.rb']
  test.verbose = true
end
$ ruby -v
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]
$ gem --version
1.8.10
$ rake --version
rake, version 0.9.2
like image 956
Rob Syme Avatar asked Dec 06 '25 01:12

Rob Syme


1 Answers

Added:

test.test_files = FileList['test/test*.rb']

File list should be given to test files not to pattern. To pattern I suppose you can give a pattern as a string.

Previous answer (misunderstood question)

That's just how the shell works. You can quote a filename if you want to target a filename that has space in it. It then get's passed as one argument and not two.

$ cat > "foo bar"
foobar
^D
$ cat foo\ bar 
foobar
$ cat "foo bar" 
foobar

or

$ ls "Rakefile Gemfile"
ls: Rakefile Gemfile: No such file or directory

$ ls Rakefile Gemfile
Gemfile  Rakefile
like image 166
sunkencity Avatar answered Dec 07 '25 17:12

sunkencity



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!