padrino / padrino-framework

Padrino is a full-stack ruby framework built upon Sinatra.
http://www.padrinorb.com
MIT License
3.37k stars 509 forks source link

Project Generator With Shoulda Test Causing Test::Unit::TestCase Related Error #1847

Closed sshaw closed 8 years ago

sshaw commented 9 years ago

Using Padrino 0.12.3 with ActiveRecord ORM.

The shoulda generator requires Test::Unit::TestCase which results in a variety of errors.

Under 2.1.2:

/tmp/shoulda-padrino >rake test:models
=> Executing Rake test:models ...
/Users/sshaw/.rvm/rubies/ruby-2.1.2/bin/ruby -I"lib" -I"/Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib" "/Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/models/**/*_test.rb" 
MiniTest::Unit::TestCase is now Minitest::Test. From /Users/sshaw/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/test/unit/testcase.rb:8:in `<module:Unit>'
/Users/sshaw/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/test/unit.rb:676:in `<class:Runner>': undefined method `_run_suite' for class `Test::Unit::Runner' (NameError)
    from /Users/sshaw/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/test/unit.rb:261:in `<module:Unit>'
    from /Users/sshaw/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/test/unit.rb:15:in `<module:Test>'
    from /Users/sshaw/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/test/unit.rb:7:in `<top (required)>'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
    from /private/tmp/shoulda-padrino/test/test_config.rb:5:in `<top (required)>'
    from /private/tmp/shoulda-padrino/test/models/user_test.rb:1:in `require'
    from /private/tmp/shoulda-padrino/test/models/user_test.rb:1:in `<top (required)>'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:10:in `require'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:9:in `each'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `select'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `<main>'
/Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/testtask.rb:108:in `block (3 levels) in define': Command failed with status (1): [ruby -I"lib" -I"/Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib" "/Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/models/**/*_test.rb" ] (RuntimeError)
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/file_utils.rb:57:in `call'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/file_utils.rb:57:in `sh'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/file_utils_ext.rb:37:in `sh'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/file_utils.rb:96:in `ruby'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/file_utils_ext.rb:37:in `ruby'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/testtask.rb:104:in `block (2 levels) in define'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/file_utils_ext.rb:58:in `verbose'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/testtask.rb:100:in `block in define'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/task.rb:240:in `call'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/task.rb:240:in `block in execute'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/task.rb:235:in `each'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/task.rb:235:in `execute'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/task.rb:179:in `block in invoke_with_call_chain'
    from /Users/sshaw/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/monitor.rb:211:in `mon_synchronize'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/task.rb:172:in `invoke_with_call_chain'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/task.rb:165:in `invoke'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/application.rb:150:in `invoke_task'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/application.rb:106:in `block (2 levels) in top_level'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/application.rb:106:in `each'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/application.rb:106:in `block in top_level'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/application.rb:115:in `run_with_threads'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/application.rb:100:in `top_level'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/padrino-core-0.12.3/lib/padrino-core/cli/base.rb:23:in `rake'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/padrino-core-0.12.3/bin/padrino:9:in `<top (required)>'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/bin/padrino:23:in `load'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/bin/padrino:23:in `<main>'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `eval'
    from /Users/sshaw/.rvm/gems/ruby-2.1.2/bin/ruby_executable_hooks:15:in `<main>'

Under 1.9.3:

/tmp/shoulda-padrino >rake test:models
=> Executing Rake test:models ...
/Users/sshaw/.rvm/rubies/ruby-1.9.3-p547/bin/ruby -I"lib" -I"/Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib" "/Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/models/**/*_test.rb" 
MiniTest::Unit::TestCase is now Minitest::Test. From /Users/sshaw/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/test/unit/testcase.rb:8:in `<module:Unit>'
/Users/sshaw/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/test/unit.rb:328:in `autorun': uninitialized class variable @@installed_at_exit in Test::Unit::Runner (NameError)
    from /Users/sshaw/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/test/unit.rb:640:in `<top (required)>'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `block in require'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:240:in `load_dependency'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.2.0/lib/active_support/dependencies.rb:274:in `require'
    from /private/tmp/shoulda-padrino/test/test_config.rb:5:in `<top (required)>'
    from /private/tmp/shoulda-padrino/test/models/user_test.rb:1:in `require'
    from /private/tmp/shoulda-padrino/test/models/user_test.rb:1:in `<top (required)>'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:10:in `require'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:10:in `block (2 levels) in <main>'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:9:in `each'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:9:in `block in <main>'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `select'
    from /Users/sshaw/.rvm/gems/ruby-1.9.3-p547/gems/rake-10.4.2/lib/rake/rake_test_loader.rb:4:in `<main>'

Once I replace the Test::Unit stuff with Minitest::Test I get a deprecation warning that's sure to confuse some:

/tmp/shoulda-padrino >rake test:models
=> Executing Rake test:models ...
/Users/sshaw/.rvm/rubies/ruby-2.1.2/bin/ruby -I"lib" -I"/Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib" "/Users/sshaw/.rvm/gems/ruby-2.1.2/gems/rake-10.4.2/lib/rake/rake_test_loader.rb" "test/models/**/*_test.rb" 
Run options: --seed 45402

# Running:

DEPRECATION WARNING: You did not specify a value for the configuration option `active_support.test_order`. In Rails 5, the default value of this option will change from `:sorted` to `:random`.
To disable this warning and keep the current behavior, you can add the following line to your `config/environments/test.rb`:

  Rails.application.configure do
    config.active_support.test_order = :sorted
  end

Alternatively, you can opt into the future behavior by setting this option to `:random`. (called from test_order at /Users/sshaw/.rvm/gems/ruby-2.1.2/gems/activesupport-4.2.0/lib/active_support/test_case.rb:42)
.

I would try to fix this but I wondered: Should shoulda -well shoulda-context really- continue to be supported? My thinking is that with the popularity of MiniTest, people are now using MiniTest::Spec for their rspec free contexts.

namusyaka commented 9 years ago

Hmm. shoulda hasn't been maintained for quite a while. I think we could drop shoulda and other old components.

ujifgc commented 9 years ago

:+1:

nesquena commented 9 years ago

Yep 0.13.0 is a great time to drop outdated components. Shoulda being one of them.

sshaw commented 9 years ago

As far as I can tell Shoulda (context and validations) is still maintained.

namusyaka commented 9 years ago

shoulda-matchers has been maintained actively, but shoulda-context seems to be stopped maintaining. I'm not sure if we should support the shoulda as our component. If we continue to support shoulda, we should fix a few points.

About outdated components, I've just opened an issue.