# Superclass mismatch (Functional test)

**URL:** <https://www.ruby-forum.com/t/superclass-mismatch-functional-test/164276>\
**Category:** Rails\
**Created:** [March 30, 2009, 8:58pm UTC](https://www.ruby-forum.com/t/superclass-mismatch-functional-test/164276 "2009-03-30T20:58:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fannus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fannus](https://www.ruby-forum.com/u/fannus)\
**Post date:** [March 30, 2009, 8:58pm UTC](https://www.ruby-forum.com/t/superclass-mismatch-functional-test/164276/1 "2009-03-30T20:58:50Z")

</div>

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:  
C:\Users\NomNomNom\Documents\NetBeansProjects\Embark\test\functional\admin\author\_controller\_test.rb:4:  
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 = AuthorController.new  
@request = ActionController::TestRequest.new  
@response = ActionController::TestResponse.new  
end

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’}  
end  
end  
[/code]

Thank you for any help. I’d gladly take a working example if you don’t  
know what’s wrong with this specific code.

---

<div class="post-metadata">

**Author:** ![fannus](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fannus](https://www.ruby-forum.com/u/fannus)\
**Post date:** [March 30, 2009, 9:31pm UTC](https://www.ruby-forum.com/t/superclass-mismatch-functional-test/164276/2 "2009-03-30T21:31:51Z")

</div>

On Mar 30, 7:58 pm, Cameron C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> 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  
…  
end  
end

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

Fred
