Sha256: d8088ce275f7aafe914c6e7c0e0483ac4065936142cd444c37bb7d2eb3ac7793

Contents?: true

Size: 1.45 KB

Versions: 9

Compression:

Stored size: 1.45 KB

Contents

require 'spec_helper'

describe Killbill::PaypalExpress::StreamyResultSet do
  before :all do
    Killbill::PaypalExpress::PaypalExpressPaymentMethod.delete_all
  end

  it 'should stream results per batch' do
    1.upto(35) do
      Killbill::PaypalExpress::PaypalExpressPaymentMethod.create :kb_account_id => SecureRandom.uuid,
                                                                 :kb_payment_method_id => SecureRandom.uuid,
                                                                 :paypal_express_payer_id => SecureRandom.uuid,
                                                                 :paypal_express_baid => SecureRandom.uuid,
                                                                 :paypal_express_token => SecureRandom.uuid
    end
    Killbill::PaypalExpress::PaypalExpressPaymentMethod.count.should == 35

    enum = Killbill::PaypalExpress::StreamyResultSet.new(40, 10) do |offset,limit|
      Killbill::PaypalExpress::PaypalExpressPaymentMethod.where('kb_payment_method_id is not NULL')
                                                         .order("id ASC")
                                                         .offset(offset)
                                                         .limit(limit)
    end

    i = 0
    enum.each do |results|
      if i < 3
        results.size.should == 10
      elsif i == 3
        results.size.should == 5
      else
        fail 'Too many results'
      end
      i += 1
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
killbill-paypal-express-1.7.0 spec/paypal_express/streamy_result_set_spec.rb
killbill-paypal-express-1.6.7 spec/paypal_express/streamy_result_set_spec.rb
killbill-paypal-express-1.6.6 spec/paypal_express/streamy_result_set_spec.rb
killbill-paypal-express-1.6.5 spec/paypal_express/streamy_result_set_spec.rb
killbill-paypal-express-1.6.4 spec/paypal_express/streamy_result_set_spec.rb
killbill-paypal-express-1.6.3 spec/paypal_express/streamy_result_set_spec.rb
killbill-paypal-express-1.6.2 spec/paypal_express/streamy_result_set_spec.rb
killbill-paypal-express-1.6.1 spec/paypal_express/streamy_result_set_spec.rb
killbill-paypal-express-1.6.0 spec/paypal_express/streamy_result_set_spec.rb