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 <bonachela-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
>
> 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
>
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---