TypeError:无法将Class转换为String

时间:2014-04-28 22:04:28

标签: ruby

测试让我觉得这个方法有错误,

def test_create
 get :new    
 assert_template 'admin/supplier/new'
 assert_difference(Supplier, :count) do
   post :create, :supplier => {:name => 'Juan', :province => 'provincia'}
   assert_response :redirect
   assert_redirected_to :action => 'index'      
 end
 assert_equal 'was succesfully created.', flash[:notice]
end

确切地说错误在

assert_difference(Supplier, :count) do

1 个答案:

答案 0 :(得分:3)

您没有正确使用assert_difference。尝试

assert_difference 'Supplier.count' do

docs

中有更多示例