Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ruby 1.9.3 breaks rake test

I have an existing rails 3 project that works just fine on ruby 1.9.2-p290. However upgrading to ruby 1.9.3-p0 causes rake test to spit out the following error:

/Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: test/unit/**/*_test.rb (ArgumentError)
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:21:in `run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'
/Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: test/functional/**/*_test.rb (ArgumentError)
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:21:in `run'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
from /Users/zmanji/.rbenv/versions/1.9.3-p0/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'

It seems to be a consequence of this rake issue. However when I create a simple rails project on ruby 1.9.3 so such error occurs. What can I do to get my rails project to run on ruby 1.9.3?

like image 889
Zameer Manji Avatar asked Oct 31 '11 17:10

Zameer Manji


3 Answers

Adding the test-unit gem worked for me.

like image 155
davidkovsky Avatar answered Nov 16 '22 19:11

davidkovsky


Try the following (independently):

  1. Use test.test_files = FileList['test/unit/**/test*.rb']
  2. Remove shoulda beta dependency.
  3. Use test/unit gem.
like image 6
Xavier Shay Avatar answered Nov 16 '22 18:11

Xavier Shay


The shoulda gem is causing a general problem when using rake in test environment on ruby 1.9.3, this is repported in this issue.

Workaround

You can use this line

gem "shoulda", :require => false

in your Gemfile and then somewhere in your test code (e.g. test/test_helper.rb if you are using test-unit) you can put

require 'shoulda'

If you are using rspec you should not use the shoulda gem at all, you should use the shoulda-matchers and this will not cause problems.

like image 4
Jarl Avatar answered Nov 16 '22 18:11

Jarl