mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-10-05 00:02:50 -04:00
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.
31 lines
997 B
Ruby
31 lines
997 B
Ruby
require File.expand_path('../../test_helper', __FILE__)
|
|
|
|
module Stripe
|
|
class ListObjectTest < Test::Unit::TestCase
|
|
should "be able to retrieve full lists given a listobject" do
|
|
@mock.expects(:get).twice.returns(make_response(make_charge_array))
|
|
c = Stripe::Charge.all
|
|
assert c.kind_of?(Stripe::ListObject)
|
|
assert_equal('/v1/charges', c.url)
|
|
all = c.all
|
|
assert all.kind_of?(Stripe::ListObject)
|
|
assert_equal('/v1/charges', all.url)
|
|
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
|
|
assert c.kind_of?(Stripe::ListObject)
|
|
assert_equal 3, c.count
|
|
end
|
|
end
|
|
end
|