Functional tests and creating objects

I obviously don’t fully understand functional testing. I’m trying to
test object creation, but I can’t get my functional test to actually
create an object with a unique ID. Here’s a rough outline of what I’m


def create
@my_object = => params[:user_id]) = ‘dog’!


def test_create_empty_object
post :create, :user_id => ‘sample_user’
assert_status 200

my_new_object = MyObject.find_by_owner('sample_user')


My question is: why does my_new_object come back with an ID of 0?

This really causes problems when I’m trying to relate new objects to
one another and somehow the functional tests keep setting the object
IDs to 0. Is there a way around this? Should I be testing this
functionality in another way?


As a follow up, is there a really good functional testing guide
somewhere? Right now they feel pretty useless to me, as it looks like
I can only test that I get a certain type of response from a request,
rather than the controller method did what it was supposed to.

Try selenium on
if you want more flexibility.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs