I am trying to make a post request to an action in my controller using rspec, which should return a JSON response. This is my current test code which uses the Facebook Graph Gem. I am unsure of my code:
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
What would be the best way to make a post request to an API? I apologize if my question is not too clear but I have little experience with making requests in tests.
Thanks