Forum: Ruby on Rails After Rails 2.3.2 upgrade: superclass mismatch for class TestCase (TypeError)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
13de37c0466c10344a11a7e1f7a64c63?d=identicon&s=25 Constantin Gavrilescu (Guest)
on 2009-04-07 00:10
(Received via mailing list)
I upgraded a working app from rails 2.1 to 2.3.2. Now when I run rake
test:units I get this error: /usr/lib/ruby/gems/1.8/gems/
activesupport-2.3.2/lib/active_support/test_case.rb:17: superclass
mismatch for class TestCase (TypeError)

I generated a new test app and all tests run OK.

For the upgrade I ran rake:update and renamed the class in test_helper
to ActiveSupport::TestCase. Also renamed the classes in all unit tests
and to inherit from ActiveSupport::TestCase and in functional tests to
inherit from ActionController::TestCase.
I still could not fix it this error. I compared line by line the
config files and the test_helper.rb with a brand new app and there are
almost the same. Google didn't provide any clue.

Full stack trace here:

/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/
test_case.rb:17: superclass mismatch for class TestCase (TypeError)
  from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
  from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
  from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:158:in `require'
  from /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/
action_controller/test_case.rb:1
  from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
  from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
  from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:158:in `require'
  from /usr/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/test_help.rb:6
  from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`gem_original_require'
  from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in
`require'
  from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/
active_support/dependencies.rb:158:in `require'
  from /home/costi/workspace/r2rrails/test/test_helper.rb:3
  from ./test/unit/customer_test.rb:1:in `require'
  from ./test/unit/customer_test.rb:1
  from /usr/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/
rake_test_loader.rb:5:in `load'
  from /usr/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/
rake_test_loader.rb:5
  from /usr/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/
rake_test_loader.rb:5:in `each'
  from /usr/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake/
rake_test_loader.rb:5
rake aborted!
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-04-07 00:25
(Received via mailing list)
On Apr 6, 11:09 pm, Constantin Gavrilescu
<comisarulmoldo...@gmail.com> wrote:
> inherit from ActionController::TestCase.
Looks to me like you accidentally declared a new class called
ActiveSupport::TestCase. You said your test_helper.rb is almost the
same as one in a freshly generated app - what are the differences?

Fred
13de37c0466c10344a11a7e1f7a64c63?d=identicon&s=25 Constantin Gavrilescu (Guest)
on 2009-04-07 00:42
(Received via mailing list)
On 6 avr, 17:23, Frederick Cheung <frederick.che...@gmail.com> wrote:
> > For the upgrade I ran rake:update and renamed the class in test_helper
> > to ActiveSupport::TestCase. Also renamed the classes in all unit tests
> > and to inherit from ActiveSupport::TestCase and in functional tests to
> > inherit from ActionController::TestCase.
>
> Looks to me like you accidentally declared a new class called
> ActiveSupport::TestCase. You said your test_helper.rb is almost the
> same as one in a freshly generated app - what are the differences?


This is the diff between the two test_helper.rb (one being the virgin
one, the second being the new one). Not much of a difference but my
extra functions.

18,21d17
<   #
<   # The only drawback to using transactional fixtures is when you
actually
<   # need to test transactions.  Since your test is bracketed by a
transaction,
<   # any transactions started in your code will be automatically
rolled back.
23a20
>
36a34,35
>   #
>
37a37,56
>     login_as(user)
>     yield
>     logout!
>   end
>
>   def get_roles_and_rights
>     Right.synchronize_with_controllers
>     DefaultRights.update
>   end
>
13de37c0466c10344a11a7e1f7a64c63?d=identicon&s=25 Constantin Gavrilescu (Guest)
on 2009-04-07 08:45
(Received via mailing list)
On 6 avr, 17:23, Frederick Cheung <frederick.che...@gmail.com> wrote:
> > For the upgrade I ran rake:update and renamed the class in test_helper
> > to ActiveSupport::TestCase. Also renamed the classes in all unit tests
> > and to inherit from ActiveSupport::TestCase and in functional tests to
> > inherit from ActionController::TestCase.
>
> Looks to me like you accidentally declared a new class called
> ActiveSupport::TestCase. You said your test_helper.rb is almost the
> same as one in a freshly generated app - what are the differences?

There must have been a plugin that changed the class TestCase class. I
realized that have done a search and replace in the plugins folder too
for Test::Unit::TestCase and replaced it to ActiveSupport::TestCase. I
did an svn revert on plugins and the rake test:units don't show the
superclass mismatch for class TestCase error.
This topic is locked and can not be replied to.