test/stripe/api_resource_test.rb in stripe-1.28.1 vs test/stripe/api_resource_test.rb in stripe-1.29.0
- old
+ new
@@ -37,14 +37,14 @@
end
end
should "using a nil api key should raise an exception" do
assert_raises TypeError do
- Stripe::Customer.all({}, nil)
+ Stripe::Customer.list({}, nil)
end
assert_raises TypeError do
- Stripe::Customer.all({}, { :api_key => nil })
+ Stripe::Customer.list({}, { :api_key => nil })
end
end
should "specifying api credentials containing whitespace should raise an exception" do
Stripe.api_key = "key "
@@ -229,21 +229,21 @@
end
should "urlencode values in GET params" do
response = make_response(make_charge_array)
@mock.expects(:get).with("#{Stripe.api_base}/v1/charges?customer=test%20customer", nil, nil).returns(response)
- charges = Stripe::Charge.all(:customer => 'test customer').data
+ charges = Stripe::Charge.list(:customer => 'test customer').data
assert charges.kind_of? Array
end
should "construct URL properly with base query parameters" do
response = make_response(make_invoice_customer_array)
@mock.expects(:get).with("#{Stripe.api_base}/v1/invoices?customer=test_customer", nil, nil).returns(response)
- invoices = Stripe::Invoice.all(:customer => 'test_customer')
+ invoices = Stripe::Invoice.list(:customer => 'test_customer')
@mock.expects(:get).with("#{Stripe.api_base}/v1/invoices?customer=test_customer&paid=true", nil, nil).returns(response)
- invoices.all(:paid => true)
+ invoices.list(:paid => true)
end
should "a 400 should give an InvalidRequestError with http status, body, and JSON body" do
response = make_response(make_missing_id_error, 400)
@mock.expects(:get).once.raises(RestClient::ExceptionWithResponse.new(response, 404))
@@ -309,11 +309,11 @@
uri = URI(url)
query = CGI.parse(uri.query)
(url =~ %r{^#{Stripe.api_base}/v1/charges?} &&
query.keys.sort == ['offset', 'sad'])
end.returns(make_response({ :count => 1, :data => [make_charge] }))
- Stripe::Charge.all(:count => nil, :offset => 5, :sad => false)
+ Stripe::Charge.list(:count => nil, :offset => 5, :sad => false)
@mock.expects(:post).with do |url, api_key, params|
url == "#{Stripe.api_base}/v1/charges" &&
api_key.nil? &&
CGI.parse(params) == { 'amount' => ['50'], 'currency' => ['usd'] }
@@ -333,12 +333,13 @@
assert_raises(Stripe::InvalidRequestError) { c.refresh }
end
should "making a GET request with parameters should have a query string and no body" do
params = { :limit => 1 }
- @mock.expects(:get).once.with("#{Stripe.api_base}/v1/charges?limit=1", nil, nil).returns(make_response([make_charge]))
- Stripe::Charge.all(params)
+ @mock.expects(:get).once.with("#{Stripe.api_base}/v1/charges?limit=1", nil, nil).
+ returns(make_response({ :data => [make_charge] }))
+ Stripe::Charge.list(params)
end
should "making a POST request with parameters should have a body and no query string" do
params = { :amount => 100, :currency => 'usd', :card => 'sc_token' }
@mock.expects(:post).once.with do |url, get, post|
@@ -405,10 +406,10 @@
assert c.card.kind_of?(Stripe::StripeObject) && c.card.object == 'card'
end
should "loading all of an APIResource should return an array of recursively instantiated objects" do
@mock.expects(:get).once.returns(make_response(make_charge_array))
- c = Stripe::Charge.all.data
+ c = Stripe::Charge.list.data
assert c.kind_of? Array
assert c[0].kind_of? Stripe::Charge
assert c[0].card.kind_of?(Stripe::StripeObject) && c[0].card.object == 'card'
end