Tests Losing Data (factory girl)

This is a cross post from the fg mailing list but the traffic is very low there so I thought I’d try here, too.

While running a test with Cukes/FG, I pre populate a table (event_categories), run my test and it passes on a successful failure (duplicate record)

When the controller executes … render {:action => :new}, I get the following error …

You have a nil object when you didn’t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.inject (ActionView::TemplateError) On line #10 of app/views/event_types/_form.html.erb

9:   <%= form.label :event_category_id, 'Event Categories' %>
10:   <%= form.select :event_category_id, @event_categories %>

Does anyone know what I have to do to preserve my data?

CIA

-ants

Solved. Sorry to take up bandwidth :frowning:

Ants Pants wrote:

Solved. Sorry to take up bandwidth :frowning:

Solved how? Please explain so others can learn.

I didn’t want to advertise my stupidity :wink:

in my create action, I was repopulating the event_categories list after a successful save. In this instance, I was actually testing for a failure so the list never got touched.

Believe me, if I had a nugget of inspiration, I would’ve informed the list. Sorry for the vagueness in my solved reply.

-ants