thoughtbot / shoulda

Makes tests easy on the fingers and the eyes

Home Page:http://www.thoughtbot.com/community

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Critical: shoulda 3.0 prevents asset:precompile for Ruby 1.9.3-p125, Rails 3.2.3

sr3d opened this issue · comments

running

rake assets:precompile --trace

with shoulda and Ruby 1.9.3-p125 with Rails 3.2.3 throw this error:

/Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: assets:precompile (ArgumentError)

Here's the full stack trace:

** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/alex/.rvm/rubies/ruby-1.9.3-p125/bin/ruby /Users/alex/.rvm/gems/ruby-1.9.3-p125@marrily/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
** Invoke assets:precompile:nondigest (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke environment (first_time)
** Execute environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:nondigest
/Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:167:in `block in non_options': file not found: assets:precompile (ArgumentError)
    from /Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:146:in `map!'
    from /Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:146:in `non_options'
    from /Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:207:in `non_options'
    from /Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:52:in `process_args'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p125@marrily/gems/minitest-2.11.4/lib/minitest/unit.rb:934:in `_run'
    from /Users/alex/.rvm/gems/ruby-1.9.3-p125@marrily/gems/minitest-2.11.4/lib/minitest/unit.rb:927:in `run'
    from /Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:21:in `run'
    from /Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:326:in `block (2 levels) in autorun'
    from /Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:27:in `run_once'
    from /Users/alex/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/test/unit.rb:325:in `block in autorun'

I was following a different thread here, jimweirich/rake#51, and after commenting out shoulda, I was able to run rake asset:precompile successfully.

This is still a problem with 1.9.3-p194.

A slightly nicer fix is to change the Gemfile line to gem 'shoulda', :require => false and then add require 'shoulda'to spec_helper.rb.

I say nicer because then you don't have to keep commenting and uncommenting the Gemfile each time you want to test or run a rake task.

➜  rspec -v
2.9.0

➜  ruby -v
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10.8.0]

➜  rake about
About your application's environment
Ruby version              1.9.3 (x86_64-darwin10.8.0)
RubyGems version          1.8.23
Rack version              1.4
Rails version             3.2.3
JavaScript Runtime        JavaScriptCore
Active Record version     3.2.3
Action Pack version       3.2.3
Active Resource version   3.2.3
Action Mailer version     3.2.3
Active Support version    3.2.3
Middleware                ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x00000101f2b0a0>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport
Application root          /Users/xxx/xxx/xxx
Environment               development
Database adapter          postgresql
Database schema version   20120425150804

If you are using rspec and not Test::Unit, please use shoulda-matchers instead of shoulda. shoulda is for Test::Unit.

Thanks. There are still plenty of tutorials around that say to add "gem 'shoulda'" - i know it's pretty clear already on the read me but you might want to make that more prominent. Thanks for letting us know :)

affects me too...