Forum: Ruby on Rails Superclass mismatch (Functional test)

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Cameron C. (Guest)
on 2009-03-30 22:58
Hilo. I'm trying to build an app with TDD, but my first functional test
is a mess. The example from the book fails, and I haven't found any
information on this issue. When I run my test, it throws:
superclass mismatch for class AuthorControllerTest (TypeError)

Here is my test:
[code]require File.dirname(__FILE__) + '/../../test_helper'
require 'admin/author_controller'
class Admin::AuthorControllerTest; def rescue_action(e) raise e end; end
class Admin::AuthorControllerTest < Test::Unit::TestCase
def setup
  @controller =
  @request =
  @response =

def test_new
  get :new
  assert_template 'admin/author/new'
  assert_tag 'h1', :content => 'Create new author'
  assert_tag 'form', :attributes => {:action => '/admin/author/create'}

Thank you for any help. I'd gladly take a working example if you don't
know what's wrong with this specific code.
Frederick C. (Guest)
on 2009-03-30 23:31
(Received via mailing list)
On Mar 30, 7:58 pm, Cameron C. <removed_email_address@domain.invalid>
> class Admin::AuthorControllerTest < Test::Unit::TestCase
It's these two line above: you've declared Admin::AuthorControllerTest
as deriving from Object , and the line below you say it derives from
Test::Unit::TestCase. The standard boiler plate should actually read

class Admin::AuthorController; def rescue_action(e) raise e end; end
class Admin::AuthorControllerTest < Test::Unit::TestCase

As of rails 2.1 you don't that - you're test file can just be

require File.dirname(__FILE__) + '/../../test_helper'
class Admin::AuthorControllerTest < ActionController::TestCase
  def test_new

subclassing from  ActionController::TestCase means you don't need the
setup method or the funky error re-raising stuff.

This topic is locked and can not be replied to.