akanshmurthy / railsbridge-testfest

The skeleton app.
MIT License
4 stars 2 forks source link

Post#create Needs Eager Stubing #23

Closed camachom closed 7 years ago

camachom commented 7 years ago

Post.create calls both the Cloudinary and Bitly API.

  def create
      ...
      if post_params[:image].present?
        ...
        cl_resp = Cloudinary::Uploader.upload(params[:post][:image], auth)
      end
      bitly_url = "http://api.bitly.com/..."
      resp = JSON.parse(Net::HTTP.get URI(bitly_url))

However, the Cloudinary spec only stubs the Cloudinary request raising an error about the Bitly request and vice versa. So even if the request are written correctly, the tests will fail.

This can be fixed by eagerly stubing both requests.

akanshmurthy commented 7 years ago

Again, nice catch and thanks for the PR! @schaui6 @siruguri