# Unit test problem,

**URL:** <https://www.ruby-forum.com/t/unit-test-problem/164803>\
**Category:** Rails\
**Created:** [April 6, 2009, 6:45am UTC](https://www.ruby-forum.com/t/unit-test-problem/164803 "2009-04-06T06:45:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ps\_gem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@ps\_gem](https://www.ruby-forum.com/u/ps_gem)\
**Post date:** [April 6, 2009, 6:45am UTC](https://www.ruby-forum.com/t/unit-test-problem/164803/1 "2009-04-06T06:45:55Z")

</div>

Hi, I am new in ROR. I have 4 fixtures in my ‘…/test/fixtures’ folder:  
user.yml, aggregationfeedmaps.yml, aggregations.yml, and feeds.yml. I  
have few test files in unit tests folder like user\_test.rb,  
feeds\_test.rb, aggregation\_test.rb and such.

When I wrote test for model ‘user’ using fixture user.yml it worked  
fine. But when I tried to run test for my other models using fixtures  
aggregationfeedmaps.yml, aggregations.yml, and feeds.yml it shows this  
error:

FixtureClassNotFound: No class attached to find

my test file ‘feeds\_test.rb’:

require File.dirname( **FILE** ) + ‘/…/test\_helper’

#class FeedsTest \< ActiveSupport::TestCase  
class FeedsTest \< Test::Unit::TestCase

# Replace this with your real tests.

fixtures :feeds

def test\_truth  
assert true  
end

def test\_updatefeed  
feed1 = feeds(:feed\_1)

# Feeds.updatefeed(feed1.id)

# assert\_equal(Time.now, feed1.lastupdate)

end

end

my fixture file: ‘feeds.yml’

# Read about fixtures at [http://ar.rubyonrails.org/classes/Fixtures.html](http://ar.rubyonrails.org/classes/Fixtures.html)

feed\_1:  
id: 1  
sourcelink: [http://sports.yahoo.com/ncaaf/teams/aad/ical.ics](http://sports.yahoo.com/ncaaf/teams/aad/ical.ics)  
feeddata: testdata  
lastupdate: 2009-02-17 22:42:25  
used: 1

feed\_2:  
id: 2  
sourcelink: [http://sports.yahoo.com/ncaaf/teams/aae/ical.ics](http://sports.yahoo.com/ncaaf/teams/aae/ical.ics)  
feeddata: testdata  
lastupdate: 2009-02-17 22:42:25  
used: 2

test\_truth test passes but test\_updatefeed shows the  
FixtureClassNotFound error  
Any help what is going on? Any help on the topic would be highly  
appreciated.

---

<div class="post-metadata">

**Author:** ![ps\_gem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@ps\_gem](https://www.ruby-forum.com/u/ps_gem)\
**Post date:** [April 6, 2009, 1:37pm UTC](https://www.ruby-forum.com/t/unit-test-problem/164803/2 "2009-04-06T13:37:25Z")

</div>

On Apr 6, 2009, at 12:45 AM, Ps\_gem Sh\_gem wrote:

> error:
> 
> FixtureClassNotFound: No class attached to find
> 
> my test file ‘feeds\_test.rb’:

You’re probably running into a naming issue. Models are expected to  
be the singular name and the tables will be plural as will the fixture  
files. You can see them all with the Pluralizer  
[http://nubyonrails.com/tools/pluralize](http://nubyonrails.com/tools/pluralize)

But here’s a simple listing:

test/fixtures/feeds.yml  
app/model/feed.rb  
class Feed \< ActiveRecord::Base  
in a database tables named “feeds”

It also expects to convert between CamelCase and under\_scored so if  
your model is AggregationFeedMap, the file defining it should be app/  
models/aggregation\_feed\_map.rb and the table name should be  
aggregation\_feed\_maps and the fixture found in test/fixtures/  
aggregation\_feed\_maps.yml

Does this help you figure out your issues? It all becomes quite  
natural after a short while, but there are still times where you’ll  
have a model name that the Inflector doesn’t get the pluralization  
right and you either have to adjust or define an extra rule for the  
word you want to use.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![ps\_gem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@ps\_gem](https://www.ruby-forum.com/u/ps_gem)\
**Post date:** [April 6, 2009, 2:24pm UTC](https://www.ruby-forum.com/t/unit-test-problem/164803/3 "2009-04-06T14:24:20Z")

</div>

> It also expects to convert between CamelCase and under\_scored so if  
> your model is AggregationFeedMap, the file defining it should be app/  
> models/aggregation\_feed\_map.rb and the table name should be  
> aggregation\_feed\_maps and the fixture found in test/fixtures/  
> aggregation\_feed\_maps.yml

Further, this command line…

script/generate model aggregation\_feed\_map

…should have set everything up correctly for you. Where’d these  
fixtures come  
from?

---

<div class="post-metadata">

**Author:** ![ps\_gem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@ps\_gem](https://www.ruby-forum.com/u/ps_gem)\
**Post date:** [April 13, 2009, 1:31am UTC](https://www.ruby-forum.com/t/unit-test-problem/164803/4 "2009-04-13T01:31:00Z")

</div>

On Apr 6, 7:23 am, Phlip [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> …should have set everything up correctly for you. Where’d these fixtures come  
> from?

In my case I have a model named LppBase. Pluralize becomes  
lpp\_bases. But if you singularize it back, it became lpp\_basis. So,  
I had to add an entry in the inflections file.

FYI: I debugged this by getting in to script/console and then  
executing: “lpp\_bases”.pluralize.singularize

HTH

---

<div class="post-metadata">

**Author:** ![ps\_gem](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ac8455/32.png) [@ps\_gem](https://www.ruby-forum.com/u/ps_gem)\
**Post date:** [April 13, 2009, 2:00am UTC](https://www.ruby-forum.com/t/unit-test-problem/164803/5 "2009-04-13T02:00:15Z")

</div>

pedz wrote:

> In my case I have a model named LppBase. Pluralize becomes  
> lpp\_bases. But if you singularize it back, it became lpp\_basis. So,  
> I had to add an entry in the inflections file.

All your basis are belong to Rails.
