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.

[PATCH] Plugin generator creates non-working Test class

#1137

The current plugin generator generates a test case that makes use of ActiveSupport's test method. But the generated test class is a subclass of Test::Unit::TestCase which doesn't have access to said method. So the tests fail out of the box.

My suggestion would be to change the generated code back to the old-style test method naming to generated a method like test_the_truth instead of test "the truth". The latter will only result in Kernel#test being called, which gives rather weird error messages.

The alternative would be to gem and require all the required ActiveSupport files, or to put the test method into a module and include it in Test::Unit::TestCase.

I wanted to put this up for discussion before doing anything about it.

Reported by Mathias Meyer · September 29th, 2008 @ 08:29 PM

State: committed
Milestone: 2.x
Assigned to: DHH DHH
Importance: none

Activity

  1. Mathias Meyer
    Mathias Meyer

    The attached patch introduces a test_helper that includes the required files, and makes the generated test cases subclass ActiveSupport::TestCase instead of Test::Unit::TestCase.

    October 1st, 2008 @ 04:17 PM

  2. Mathias Meyer
    Mathias Meyer
    • Title changed from Plugin generator creates non-working Test class to [PATCH] Plugin generator creates non-working Test class

    October 4th, 2008 @ 11:10 AM

  3. Mathias Meyer
    Mathias Meyer
    • Assigned user set to DHH

    October 5th, 2008 @ 06:53 PM

  4. Repository
    Repository
    • State changed from new to committed

    (from [7418d367f0ac4a4ac0ab4604c1b10db78efc6865]) Fixed plugin generator so that generated unit tests would subclass ActiveSupport::TestCase, also introduced a helper script to reduce the needed require statements. [#1137 [PATCH] Plugin generator creates non-working Test class state:committed]

    Signed-off-by: David Heinemeier Hansson david@loudthinking.com http://github.com/rails/rails/co...

    October 30th, 2008 @ 11:58 AM