thoughtbot/shoulda

shoulda breaks rake routes in Rails 3.2

Closed this issue · 10 comments

Added "gem 'shoulda', tried 'rake routes', output:

/Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:167:
in `block in non_options': file not found: routes (ArgumentError)
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:21:in `run'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
from /Users/atrapp/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'

if I uninstall the shoulda gem everything works fine.

*** LOCAL GEMS ***

actionmailer (3.2.0)
actionpack (3.2.0)
activemodel (3.2.0)
activerecord (3.2.0)
activeresource (3.2.0)
activesupport (3.2.0)
addressable (2.2.7)
arel (3.0.2)
autotest (4.4.6)
awesome_print (1.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
bundler (1.1.3)
cancan (1.6.7)
capybara (1.1.2)
childprocess (0.3.1)
chronic (0.6.7)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
commonjs (0.2.5)
cucumber (1.1.9)
cucumber-rails (1.3.0)
database_cleaner (0.7.2)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.3.0)
factory_girl (3.0.0)
factory_girl_rails (3.0.0)
ffi (1.0.11)
gherkin (2.9.3)
haml (3.1.4)
haml-rails (0.3.4)
hike (1.2.1)
hirb (0.6.2)
hirb-unicode (0.0.5)
hpricot (0.8.6)
i18n (0.6.0)
journey (1.0.3)
jquery-rails (2.0.1)
json (1.6.6)
launchy (2.1.0)
less (2.0.12)
less-rails (2.1.8)
libv8 (3.3.10.4 x86_64-darwin-11)
mail (2.4.4)
mime-types (1.18)
multi_json (1.2.0)
mysql2 (0.3.11)
nokogiri (1.5.2)
orm_adapter (0.0.7)
paper_trail (2.6.3)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.2)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.0)
rails3-generators (0.17.4)
railties (3.2.0)
rake (0.9.2.2)
rdoc (3.12)
rspec (2.9.0)
rspec-core (2.9.0)
rspec-expectations (2.9.0)
rspec-mocks (2.9.0)
rspec-rails (2.9.0)
ruby_parser (2.3.1)
rubyzip (0.9.6.1)
sass (3.1.15)
sass-rails (3.2.5)
selenium-webdriver (2.20.0)
sexp_processor (3.1.0)
shoulda (3.0.1)
shoulda-context (1.0.0)
shoulda-matchers (1.0.0)
simple_form (2.0.1)
simplecov (0.6.1)
simplecov-html (0.5.3)
sprockets (2.1.2)
term-ansicolor (1.0.7)
therubyracer (0.9.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
twitter-bootstrap-rails (2.0.4)
tzinfo (0.3.32)
uglifier (1.2.4)
unicode-display_width (0.1.1)
warden (1.1.1)
whenever (0.7.3)
xpath (0.1.4)
ZenTest (4.7.0)

I think this is because shoulda is trying to initialize Test::Unit upon initialization. Try putting shoulda within the :test group of your Gemfile, and try rake routes again after that.

group :test do
  gem "shoulda"
end

Yes, can confirm this. Had it in the ":development, :test" group, putting it in the :test group removes the problem!
Thank you very much!

Hi, can you paste the output of bundle show so I can see what's in your local bundle? With a new Rails 3.2 app + shoulda, it looks like rake routes works.

Oops, didn't see that this had been closed.

No problem, thanks for the help.

You've only fixed the symptom; the problem is still there.

For my homebrew continues integration stuff I run RAILS_ENV=test rake db:schema:load a lot. This renders the same issue (and worse; makes rake exit with non-zero exit status)

Please investigate and fix the real problem

PS:

A way to solve this symptom (while the gurus that be fix this problem) is to have Bundler not require shoulda:

gem 'shoulda', '~> 3.1', :require => false

And then later explicitly require it in your spec- / test_helper file

@coffeeaddict, 👍

I have this issue on my CI server, where RAILS_ENV=test.

Here is a piece of logs:

+ bundle exec rake db:schema:load --trace
** Invoke db:schema:load (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:schema:load
NOTICE:  CREATE TABLE will create implicit sequence "albums_id_seq" for serial column "albums.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "albums_pkey" for table "albums"
NOTICE:  CREATE TABLE will create implicit sequence "photos_id_seq" for serial column "photos.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "photos_pkey" for table "photos"
/var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: db:schema:load (ArgumentError)
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/minitest/unit.rb:891:in `_run'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/minitest/unit.rb:884:in `run'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:21:in `run'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
    from /var/lib/jenkins/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'
-- create_table("albums", {:force=>true})
   -> 1.6576s
-- create_table("photos", {:force=>true})
   -> 0.0404s
-- initialize_schema_migrations_table()
   -> 0.0006s
-- assume_migrated_upto_version(20120417222132, ["db/migrate"])
   -> 0.0011s
Build step 'Execute shell' marked build as failure
Finished: FAILURE

@coffeeaddict +1 for your temporary solution. Thanks!

This should be resolved in 3.3.2 due to a fix in shoulda-context.