Как мне указать эту спецификацию
class FlagsController
def like
flag = current_user.flags.find_or_initialize_by_flaggable_type_and_flaggable_id(params[:like_type], params[:like_id])
flag.kind = params[:kind]
if flag.save
head :ok
else
head :unprocessable_entity
end
end
end
Моя текущая спецификация
describe FlagsController do
before (:each) do
@user = Factory(:user)
sign_in @user
end
describe "flag" do
it 'with valid params' do
controller.stub!(:current_user).and_return(@user)
@user.stub_chain(:flags, :find_or_initialize_by_flaggable_type_and_flaggable_id).
with('Comment', '1').
and_return(mock_flag(:save => false)).
stub!(:kind).
with('up').
and_return(mock_flag(:save => true))
post :like, :like_type => 'Comment', :like_id => '1', :kind => 'up'
response.response_code.should eq(200)
end
end
Результаты спец.