Why the functional test fails?
Hello when run rake test:functionals, here's what I get on the shell :
1) Failure:
test_should_create_client(ClientsControllerTest) [test/functional/clients_controller_test.rb:20]:
"Client.count" didn't change by 1.
<2> expected but was
<1>.
7 tests, 9 assertions, 1 failures, 0 errors
rake aborted!
Command failed with status (1): [/System/Library/Frameworks/Ruby.framework/...]
and this is what I have on line 20 in the clients_controller_test.rb file:
test "should create client" do
assert_difference('Client.count') do
post :create, :client => @client.attributes
end
Please can anyone tell me where the problem comes from?
Thank you so much nathanvda!!!!
I have pass the attributes to the test and it works.Here' the following code
test "should create client" do
assert_difference('Client.count') do
post :create, :client => {:name => 'jeff', :adress => 'ter', :city => 'ny',
:email =>'get@yahpp.fr', }
end
assert_redirected_to client_path(assigns(:client))
assert_equal 'Client was successfully created.', flash[:notice]
end
Here's what I get after rake:test:functionals:
Finished in 0.292246 seconds.
7 tests, 11 assertions, 0 failures, 0 error开发者_如何学编程s
Probably, due to some validation error in the attributes you pass to the controller, there was no new client created.
精彩评论