0
我想在我的控制器中使用rspec發出一個操作的post請求,它應該返回一個JSON響應。這是我使用Facebook Graph Gem的當前測試代碼。我不確定我的代碼:Rspec使用post請求來獲得響應
it "creates JSON format metadata with facebook post social message info about social account" do
stub_request(:post, "https://graph.facebook.com/test_fixed_origin_id_str/likes").with(:body => {"access_token"=>"this_is_a_test_token"}, :headers => {'Content-Type'=>'application/x-www-form-urlencoded'}).to_return(:status => 200, :body => "", :headers => {})
post :like, id: combined_id, format: :json
end
什麼是做一個POST請求API的最佳方式?我很抱歉,如果我的問題不太清楚,但我在測試中提出請求的經驗很少。
感謝
非常感謝。我想知道是否可以推薦一個資源來完成這項工作,而沒有寶石並進行實時通話?再次感謝 –