Error w/dynamic fixtures

Hey All,

I’m trying to do the basic test/unit stuff & having trouble w/a dynamic
fixture error. I’m running rails 2.0.2 on windows.

I have statuses & projects. Projects belong_to status and so forth.

statuses.yml ===================

active:
name: Active
description: MyString

projects.yml ===================

one:
name: Center for Health Communications Research
abbreviation: CHCR
description: A collection of 3 projects.
grant_number: 8
status_id: <%= statuses(:active).id %>
start_date: 2008-03-20
end_date: 2008-03-20

==========================================

But when I run tests I get this for output:

==========================================

  1. Error: test_truth(DomainTest): Fixture::FormatError: a YAML error
    occurred parsing C:/railsapps/collabtrac/test/fixtures/projects.yml.
    Please note that YAML must be consistently indented using spaces. Tabs
    are not allowed. Please have a look at YAML Ain't Markup Language The
    exact error was: NoMethodError: undefined method `statuses’ for
    main:Object

==========================================

Can someone tell me what I’m doing wrong here? Is the problem that
projects.yml is getting read in before statuses.yml? If so, how do I
control that load order?

Thanks!

-Roy

Roy P.
Research Analyst/Programmer
Group Health Center For Health Studies (Cancer Research Network)
(206) 287-2078
Google Talk: rpardee

On Nov 26, 10:49 pm, “Pardee, Roy” [email protected] wrote:

Hey All,

Can someone tell me what I’m doing wrong here? Is the problem that projects.yml is getting read in before statuses.yml? If so, how do I control that load order?

That is correct and the statuses method probably isn’t even defined in
the context you are using this in. The write way to do this is to put

status: active

in that fixture. As long as you have the status belongs_to
association, rails will figure out that this means that you want the
status_id column to have the value of the id of the status fixture
with label ‘active’. This won’t work if your fixture for statuses
explicitly sets an id.

Fred

Sweetness–thanks!

-Roy