These are chat archives for rebelidealist/stripe-ruby-mock

20th
Dec 2015
Noman Ur Rehman
@nomanurrehman
Dec 20 2015 08:00
I am using Ruby to write the test cases and that is where it is failing ...
When I call the close method on a dispute, internally, an API request is sent to the same dispute close endpoint ...
That is how all Stripe SDKs work I think ...
kathyonu
@kathyonu
Dec 20 2015 15:06
@nomanurrehman Try the Ruby command. The link will take you right to it.
Noman Ur Rehman
@nomanurrehman
Dec 20 2015 16:53
Is this what you mean?
dispute = Stripe::Dispute.retrieve("dp_15RsQX2eZvKYlo2C0MFNUWJC")
dispute.close
kathyonu
@kathyonu
Dec 20 2015 16:55
Yes. Does it work ?
If not, what is the error reported ?
Noman Ur Rehman
@nomanurrehman
Dec 20 2015 17:13

Here is the code to handle close dispute endpoint ...

def close_dispute(route, method_url, params, headers)
  dispute = get_dispute(route, method_url, params, headers)
  dispute.merge!({:status => 'lost'})
  dispute
end

Here is my test case ...

it "closes a dispute" do
  dispute_id = 'dp_75RsQX2eZvKYlo2C0EDCXSWQ'
  dispute = Stripe::Dispute.retrieve(dispute_id)

  expect(dispute.id).to eq(dispute_id)
  expect(dispute.status).to eq('under_review')

  dispute.close

  expect(dispute.id).to eq(dispute_id)
  expect(dispute.status).to eq('lost')
end
Here are the dispute endpoints that I have added handlers for:
def Disputes.included(klass)
  klass.add_handler 'get /v1/disputes/(.*)',        :get_dispute
  klass.add_handler 'post /v1/disputes/(.*)',       :update_dispute
  klass.add_handler 'post /v1/disputes/(.*)/close', :close_dispute
  klass.add_handler 'get /v1/disputes',             :list_disputes
end
kathyonu
@kathyonu
Dec 20 2015 17:39
Remove that /close on the add_handler.
Does it work ?
If not, what is the error reported ?
Noman Ur Rehman
@nomanurrehman
Dec 20 2015 18:19
I think you might need to re-read our whole conversation from last night ...
kathyonu
@kathyonu
Dec 20 2015 19:07
Far as I can tell, you are using a curl command with the /close ending. I have asked the following:
Remove that /close on klass.add_handler 'post /v1/disputes/(.*)/close', :close_dispute
Does it work ?
If not, what is the error reported ?
Your response to send me back looking for something you do not say specifically ??
I can only repeat my suggestion and question on the error.
Please show the reported error after you remove \close
klass.add_handler 'post /v1/disputes/(.*)', :close_dispute.
Noman Ur Rehman
@nomanurrehman
Dec 20 2015 19:46
Removing "/close" would mean I am declaring two handler functions for the same route which would be :update_dispute and :close_dispute ...
kathyonu
@kathyonu
Dec 20 2015 21:58
Have you tried it ?
I am curious if it works, for the two lines are looking for different things to post.
One is looking for :close_dispute
One is looking for :update_dispute
Please just try it ..
Does it work ?
If not, what is the error reported ?
I hope this third request is your charm.