mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-04 00:00:47 -04:00
Merge pull request #308 from stripe/brandur-list-empty
Add #empty? helper on ListObject
This commit is contained in:
commit
180a7d849d
@ -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