mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
Add #empty? helper on ListObject
This makes ListObject behave a little more like an Array in that it gets an #empty? helper. This should fit pretty well with the Enumerable methods that it already has. Replaces #193.
This commit is contained in:
parent
9aa13697f7
commit
af72a57c9d
@ -16,6 +16,11 @@ module Stripe
|
||||
self.data.each(&blk)
|
||||
end
|
||||
|
||||
# Returns true if the page object contains no elements.
|
||||
def empty?
|
||||
self.data.empty?
|
||||
end
|
||||
|
||||
def retrieve(id, opts={})
|
||||
id, retrieve_params = Util.normalize_id(id)
|
||||
response, opts = request(:get,"#{url}/#{CGI.escape(id)}", retrieve_params, opts)
|
||||
|
@ -13,6 +13,13 @@ module Stripe
|
||||
assert all.data.kind_of?(Array)
|
||||
end
|
||||
|
||||
should "provide #empty?" do
|
||||
object = Stripe::ListObject.construct_from({ :data => [] })
|
||||
assert object.empty?
|
||||
object = Stripe::ListObject.construct_from({ :data => [{}] })
|
||||
refute object.empty?
|
||||
end
|
||||
|
||||
should "provide enumerable functionality" do
|
||||
@mock.expects(:get).once.returns(make_response(make_charge_array))
|
||||
c = Stripe::Charge.all
|
||||
|
Loading…
x
Reference in New Issue
Block a user