vendredi 26 février 2016

Rspec test rails action with third party api

class SessionsController < ApplicationController::Base  
  def create
      result = verify_sms_code(params[:session][:phone], params[:session][:code]
       if result['code'] == 200
         render json: {code: 200, msg: 'success'}
       else
         render json: {code: 404, msg: 'failed'}
       end
    end
end

verify_sms_code method invoke third party api from network, the api returns json result for validation short message.

How can I test create action? Thanks

Aucun commentaire:

Enregistrer un commentaire