Sha256: 4ed186cdb384a440052f6cc52aba4b03e8288ca9574244b31ad150614d493433

Contents?: true

Size: 1023 Bytes

Versions: 49

Compression:

Stored size: 1023 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + "/../spec_helper")

describe "Braintree::ResourceCollection" do
  describe "enumeration" do
    it "iterates over the elements, yielding to the block in pages" do
      values = %w(a b c d e)
      collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2}) do |ids|
        ids.map {|id| values[id] }
      end

      count = 0
      collection.each_with_index do |item, index|
        item.should == values[index]
        count += 1
      end

      count.should == 5
    end
  end

  describe "#ids" do
    it "returns a list of the resource collection ids" do
      collection = Braintree::ResourceCollection.new(:search_results => {:ids => [0,1,2,3,4], :page_size => 2})
      collection.ids.should == [0,1,2,3,4]
    end
  end

  it "returns an empty array when the collection is empty" do
    collection = Braintree::ResourceCollection.new(:search_results => {:page_size => 2})
    collection.ids.should == []
  end
end

Version data entries

49 entries across 49 versions & 1 rubygems

Version Path
braintree-3.1.0 spec/unit/braintree/resource_collection_spec.rb
braintree-3.0.1 spec/unit/braintree/resource_collection_spec.rb
braintree-2.104.1 spec/unit/braintree/resource_collection_spec.rb
braintree-2.104.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.103.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.102.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.101.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.100.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.99.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.98.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.97.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.96.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.95.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.94.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.93.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.92.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.91.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.90.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.89.0 spec/unit/braintree/resource_collection_spec.rb
braintree-2.88.0 spec/unit/braintree/resource_collection_spec.rb