Sha256: bd2d5c19aaf9ecd1da9c7ec7c49642c703b29989b74cee05eeb8c83ef6428638

Contents?: true

Size: 1.15 KB

Versions: 7

Compression:

Stored size: 1.15 KB

Contents

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

describe Candy::CandyArray do
    before(:all) do
      @verifier = Zagnut.collection
    end
  
    before(:each) do
      @this = Zagnut.new
      @this.bits = ['peanut', 'almonds', 'titanium']
    end
    
    it "writes the array" do
      @verifier.find_one['bits'][1].should == 'almonds'
    end
    
    it "reads the array" do
      that = Zagnut(@this.id)
      that.bits[2].should == 'titanium'
    end
    
    it "cascades appends" do
      @this.bits << 'kryptonite'
      that = Zagnut(@this.id)
      that.bits[-1].should == 'kryptonite'
    end
    
    it "cascades substitutions" do
      @this.bits[0] = 'raisins'
      that = Zagnut(@this.id)
      that.bits.should == ['raisins', 'almonds', 'titanium']
    end
    
    it "cascades deletions" do
      @this.bits.shift.should == 'peanut'
      that = Zagnut(@this.id)
      that.bits.size.should == 2
    end
    
    it "cascades deeply" do
      @this.bits.push [5, 11, {foo: [:bar]}]
      that = Zagnut(@this.id)
      that.bits[3][2][:foo][0].should == :bar
    end

    after(:each) do
      Zagnut.collection.remove
    end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
candy-0.2.7 spec/candy/array_spec.rb
candy-0.2.6 spec/candy/array_spec.rb
candy-0.2.5 spec/candy/array_spec.rb
candy-0.2.4 spec/candy/array_spec.rb
candy-0.2.3 spec/candy/array_spec.rb
candy-0.2.2 spec/candy/array_spec.rb
candy-0.2.1 spec/candy/array_spec.rb