Skip to content

[PATCH] Requiring ActiveSupport::TestCase in a vanilla test fails to run the test case #614

Closed
lighthouse-import opened this Issue May 16, 2011 · 3 comments

1 participant

@lighthouse-import

Imported from Lighthouse. Original ticket at: http://rails.lighthouseapp.com/projects/8994/tickets/2519
Created by Christos Zisopoulos - 2011-02-22 08:32:35 UTC

It seems that because ActiveSupport::TestCase fails to require test/unit before requiring test/unit/testcase none of the test cases that inherit from ActiveSupport::TestCase are being run.

Normal Rails application tests that require test_helper, which in turn requires environment, don't exhibit this problem. This is possibly due to the fact that test/unit is required somewhere during Rails initialization.

I came across the issue when trying to run tests for a plugin created by Rails' own plugin generator which creates a test_helper which requires ActiveSupport::TestCase

The following won't execute any tests:

  #
  # test_helper.rb
  #
  require 'rubygems'
  require 'active_support'
  require 'active_support/test_case'
  #
  # my_plugin_test.rb
  #
  require 'test_helper'

  class MyPluginTest < ActiveSupport::TestCase
    test "the truth" do
      assert true
    end
  end

I am attaching the one-line patch which fixes it for me. I tried to figure a way to test that the test cases are run, but to be honest, I am lost. If anyone wants to point me to the right direction, I'll give it another try.

@lighthouse-import

Imported from Lighthouse.
Comment by giles bowkett - 2009-08-04 23:30:25 UTC

For what it's worth, you don't need to patch ActiveSupport, you can just require 'test/unit' in your plugin tests.

Also, I think the best place to patch this is not in ActiveSupport, but the plugin generator.

@lighthouse-import

Imported from Lighthouse.
Comment by Jeremy Kemper - 2010-05-04 17:48:47 UTC

[bulk edit]

@lighthouse-import

Attachments saved to Gist: http://gist.github.com/971628

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.