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
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.
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
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.
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?
…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
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.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.