我有以下代码:
Group.where('name ~* ?', params[:name]).first
在这种情况下如何存根where
方法?
Group.stub(:where).and_return(mock_model(Group, name: "SomeName"))
导致错误:
Mock "Group_1001" received unexpected message :first with (no args)
我有以下代码:
Group.where('name ~* ?', params[:name]).first
在这种情况下如何存根where
方法?
Group.stub(:where).and_return(mock_model(Group, name: "SomeName"))
导致错误:
Mock "Group_1001" received unexpected message :first with (no args)