2011-09-15 187 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

相关问题