---
title: "restful_authentication 中  单元测试问题"
author: "xanderzhang"
date: "2009-07-16T10:11:05Z"
tags: ["ActiveRecord", "单元测试"]
slug: "restful-authentication"
draft: false
lastmod: "2009-07-16T10:11:05Z"
id: 426889
url: "https://xanderzhang.iteye.com/blog/426889"
---

The tests installed by restful_authentication encounter undefined-method errors, starting with "undefined method fixtures'" for the unit tests. The problem seems to be that the tests derive only from Test::Unit::TestCase, whereas the relevant methods are defined in ActiveRecord::TestCase and ActionController::TestCase for unit and functional tests, respectively.

My current work-around is to change the base class by hand, e.g. to replace

class UserTest < Test::Unit::TestCase

with

class UserTest < ActiveRecord::TestCase

This addresses the error, so that the tests at least can run.