Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

a generated plugin's tests are not run by 'rake test'

#1878

The test_helper.rb file generated for a plugin does not run the plugin's tests on 'rake test' (standing in the plugin's directory). That is very easy to verify:

  • ./script/generate plugin my_plugin
  • cd vendor/plugins/my_plugin
  • rake test

No tests will be run. A "truth test" is generated by default so you should see ("1 tests, 1 assertions, 0 failures, 0 errors"). That's because test/unit is not required in the test_helper.rb file and the fix is just that, require it (see attached patch).

Reported by Balint Erdi · February 4th, 2009 @ 11:08 PM

State: committed
Milestone: 2.3.9
Assigned to: José Valim José Valim
Importance: none

Activity

  1. hiroshi
    hiroshi

    I'v just stumbled upon the same problem with Rails 2.3.0 (RC1). I think this problem may discourages many authors of plugins from writing tests of their own plugins (, so possibly do I).

    I wish this patch is merged before official release of 2.3.X and next version of 2.2.X.

    February 22nd, 2009 @ 08:40 AM

  2. Matt Jones
    Matt Jones
    • Tag changed from 2.2.2, generators, patch, plugins to 2.3, generators, patch, plugins

    I'll confirm that this is a problem, but the patch should swap the order that rubygems and test/unit are required, as miniunit gets pulled in from gems with "require 'test/unit'".

    March 14th, 2009 @ 09:12 PM

  3. Balint Erdi
    Balint Erdi

    Right, I have not thought about that, thank you. Here goes the updated patch.

    March 15th, 2009 @ 12:22 AM

  4. Jeremy Olliver
    Jeremy Olliver

    I think that the tests do run when just 'rake' is called, though you're quite right, that 'rake test' should run them as well. Tests all pass. I'm happy with this patch being added as is.

    March 15th, 2009 @ 01:37 AM

  5. hiroshi
    hiroshi

    Every time I generate a plugin I waste a time googling words like "rails plugin test not run". I think this issue should be attended asap.

    While this issue has been left months, a duplicated ticket #2248 Plugin Tests not Running is created. It also should be closed as "duplicated".

    I hope this comment bump up the priority :)

    June 15th, 2009 @ 08:15 AM

  6. hiroshi
    hiroshi

    I'v found when this issue happened from log of templates/test_helper.rb. It happened since release 2.2.1.

    The commit:
    http://github.com/rails/rails/commit/7418d367f0ac4a4ac0ab4604c1b10d...
    The ticket having a patch which side effected this issue:
    https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets...

    June 15th, 2009 @ 09:18 AM

  7. dwaite
    dwaite

    This patch fixes the issue for me, my tests now run. I'm somewhat surprised this issue has sat open for as long as it has.

    July 11th, 2009 @ 05:10 PM

  8. dwaite
    dwaite
    • Tag changed from 2.3, generators, patch, plugins to 2.3, generators, patch, plugins, verified

    July 11th, 2009 @ 05:38 PM

  9. michaelmell
  10. cnk
    cnk

    Please incorporate this small change into the stock plugin generator. It is a small fix for a puzzling bug.

    July 28th, 2009 @ 01:06 AM

  11. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2.3, generators, patch, plugins, verified to 2.3, generators, patch, plugins, verifiedbugmash

    August 9th, 2009 @ 05:15 PM

  12. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from 2.3, generators, patch, plugins, verifiedbugmash to 2.3, bugmash, generators, patch, plugins, verified

    August 9th, 2009 @ 05:15 PM

  13. Rajesh
  14. Nikolay Petrachkov
    Nikolay Petrachkov
    • Assigned user set to Pratik

    "verified" patch by Balint Erdi "I've attached a patch." for master.

    August 9th, 2009 @ 05:54 PM

  15. Rizwan Reza
    Rizwan Reza

    verified

    +1 The last patch works in master.

    August 9th, 2009 @ 05:58 PM

  16. Repository
  17. CancelProfileIsBroken
    CancelProfileIsBroken
    • Assigned user cleared.
    • Tag changed from 2.3, bugmash, generators, patch, plugins, verified to 2.3, generators, patch, plugins, verified
    • Milestone cleared.

    August 9th, 2009 @ 06:54 PM

  18. Mike Breen
  19. Mike Breen
  20. Michel Pigassou
    Michel Pigassou
    • Importance changed from to

    Was the patch include in versions up to 2.3.8?
    It's the version of Rails I use and I have the same problem, however it's been marked as resolved in August 2009.

    July 2nd, 2010 @ 12:41 PM

  21. Santiago Pastorino
    Santiago Pastorino
    • Assigned user set to José Valim
    • State changed from resolved to open
    • Milestone set to 2.3.9

    July 7th, 2010 @ 04:48 PM

  22. José Valim
    José Valim
    • State changed from open to committed

    2-3-stable patch applied.

    July 8th, 2010 @ 10:16 PM