# Question about testing

**URL:** <https://www.ruby-forum.com/t/question-about-testing/159440>\
**Category:** Rails\
**Created:** [February 4, 2009, 4:07pm UTC](https://www.ruby-forum.com/t/question-about-testing/159440 "2009-02-04T16:07:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zero0x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/c6cbf5/32.png) [@zero0x](https://www.ruby-forum.com/u/zero0x)\
**Post date:** [February 4, 2009, 4:07pm UTC](https://www.ruby-forum.com/t/question-about-testing/159440/1 "2009-02-04T16:07:29Z")

</div>

Hi,

I have a question about testing …

It’s controller test …

First I do something like this:

xhr :get, :status, :id =\> homeworks(:one).id, :status =\> “done”

The :status action sets homework’s length\_done to length.

So I do this:

assert = homeworks(:one).length == homeworks(:one).length\_done

But this test doesn’t pass, while this one:

assert assigns(:homework).length == assigns(:homework).length\_done

Passes. Why?

If I do request - doesn’t the object from fixtures get updated?

---

<div class="post-metadata">

**Author:** ![zero0x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/c6cbf5/32.png) [@zero0x](https://www.ruby-forum.com/u/zero0x)\
**Post date:** [February 4, 2009, 4:27pm UTC](https://www.ruby-forum.com/t/question-about-testing/159440/2 "2009-02-04T16:27:29Z")

</div>

No.

Fixtures are fixed.

Do this:

original\_homework = homeworks(:one)  
xhr :get, :status, :id =\> original\_homework.id, :status =\> “done”

changed\_homework = assigns(:homework) # get it from the controller’s  
instance

# now compare original\_homework and changed\_homework.

I don’t know what you’re really trying to test here, but this sounds  
like business logic. The controller should pass parameters to a  
fully-tested model so your controller tests really should be testing  
for how the controller handles “it worked” vs “it didn’t work”. The  
details of what gets set should be covered in a unit test.

test "it should show a success message when created successfully do

end

test “it should show an error message when not created successfully” do

end

HTH  
-Brian

---

<div class="post-metadata">

**Author:** ![zero0x](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/c6cbf5/32.png) [@zero0x](https://www.ruby-forum.com/u/zero0x)\
**Post date:** [February 4, 2009, 4:30pm UTC](https://www.ruby-forum.com/t/question-about-testing/159440/3 "2009-02-04T16:30:25Z")

</div>

Thanks,

OK I see,

I wanted something like

should be done after setting it done

But I see that’s enough by checking assigns.
