2011-09-15 190 views
2

您好:這裏函,這就是我得到的shell:爲什麼功能測試失敗?運行rake測試時,

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/...] 

,這就是我對在clients_controller_test.rb文件行20:

test "should create client" do 
    assert_difference('Client.count') do 
     post :create, :client => @client.attributes 
    end 

請誰能告訴我問題來自哪裏?

非常感謝你nathanvda !!!!

我通過屬性測試,它works.Here」下面的代碼

test "should create client" do 
    assert_difference('Client.count') do 
     post :create, :client => {:name => 'jeff', :adress => 'ter', :city => 'ny', 
        :email =>'[email protected]', } 
    end 
    assert_redirected_to client_path(assigns(:client)) 
    assert_equal 'Client was successfully created.', flash[:notice] 
    end 

這裏是我耙後得到:測試:泛函:

Finished in 0.292246 seconds. 

7 tests, 11 assertions, 0 failures, 0 errors 

回答

0

可能,由於您傳遞給控制器​​的屬性中存在一些驗證錯誤,因此沒有創建新客戶端。

+0

非常感謝 – blawzoo

相關問題