# Error with test:functionals

**URL:** <https://www.ruby-forum.com/t/error-with-test-functionals/166891>\
**Category:** Rails\
**Created:** [April 30, 2009, 4:19pm UTC](https://www.ruby-forum.com/t/error-with-test-functionals/166891 "2009-04-30T16:19:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Luciano](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f05b48/32.png) [@Luciano](https://www.ruby-forum.com/u/Luciano)\
**Post date:** [April 30, 2009, 4:19pm UTC](https://www.ruby-forum.com/t/error-with-test-functionals/166891/1 "2009-04-30T16:19:12Z")

</div>

Hello there,

I working on my tests but I getting this strange errror:

I can see on the database that the object was created but I still got  
an failure on my test.

this is my test code:

test “should create artist” do  
assert\_difference(‘Artist.count’, difference = 1) do  
post :create, :artist =\> { }  
end  
assert\_redirected\_to artist\_path(assigns(:artist))  
end

and this is my failure message:

1. Failure:  
test\_should\_create\_artist(ArtistsControllerTest)  
[/Users/bonacode/Desktop/arteacesso-br/arteacesso/vendor/rails/  
activesupport/lib/active\_support/testing/core\_ext/test/unit/  
assertions.rb:51:in `assert_difference' (eval):3:in`each\_with\_index’  
/Users/bonacode/Desktop/arteacesso-br/arteacesso/vendor/rails/  
activesupport/lib/active\_support/testing/core\_ext/test/unit/  
assertions.rb:47:in `each' /Users/bonacode/Desktop/arteacesso-br/arteacesso/vendor/rails/ activesupport/lib/active_support/testing/core_ext/test/unit/ assertions.rb:47:in`each\_with\_index’  
/Users/bonacode/Desktop/arteacesso-br/arteacesso/vendor/rails/  
activesupport/lib/active\_support/testing/core\_ext/test/unit/  
assertions.rb:47:in `assert_difference' ./test/functional/artists_controller_test.rb:16:in`test\_should\_create\_artist’  
/Users/bonacode/Desktop/arteacesso-br/arteacesso/vendor/rails/  
activesupport/lib/active\_support/testing/setup\_and\_teardown.rb:60:in  
` __send__' /Users/bonacode/Desktop/arteacesso-br/arteacesso/vendor/rails/ activesupport/lib/active_support/testing/setup_and_teardown.rb:60:in`run’]:  
\<Artist.count\> was the expression that failed.  
\<2\> expected but was  
\<1\>.

I checking the database and my use was created, I just dont’t  
understand why is it expecting 2 if there’s only one on my fixture…

thanks for any help!

Luciano

---

<div class="post-metadata">

**Author:** ![Luciano](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/f05b48/32.png) [@Luciano](https://www.ruby-forum.com/u/Luciano)\
**Post date:** [April 30, 2009, 6:08pm UTC](https://www.ruby-forum.com/t/error-with-test-functionals/166891/2 "2009-04-30T18:08:17Z")

</div>

I think that the message is saying that the value of Artist.count after  
the  
create is 1 when it should be 2, rather than the expected difference  
being  
2, though I am not sure whether this is what you are confused about or  
not.

By the way,  
assert\_difference(‘Artist.count’, 1) do  
may be what you want, though I don’t think that will make any difference  
to  
the result.

2009/4/30 Luciano [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
