Sha256: b9af2ac77d0adcaa2008dba5d424cb70550430b4b8b7cd9d7f7f50a037441661
Contents?: true
Size: 1.93 KB
Versions: 2
Compression:
Stored size: 1.93 KB
Contents
require File.dirname(__FILE__)+"/spec_helper.rb" describe Rserve::WithNames do before do @a=[1,2,3,4] @a.extend Rserve::WithNames end it "should return nil without names" do @a.names.should be_nil end describe "with incorrect naming" do it "should raise an error with names array of another size" do lambda {@a.names=["1","2"]}.should raise_exception end it "should raise an error with names array !(String or nil) " do lambda {@a.names=[1,"a","b","c"]}.should raise_exception lambda {@a.names=[nil,"a","b","c"]}.should_not raise_exception end end describe "correct naming" do before do @a.names=['a','b','c',nil] end it "should set names and return them without problems" do @a.names.should==['a','b','c',nil] end it "should return correct values with 0-index([x])" do @a[0].should==1 @a[3].should==4 end it "should return correct values with 1-index syntactic sugar ([[x]])" do @a[[1]].should==1 @a[[4]].should==4 end it "should return with names(['x'])" do @a['a'].should==1 @a['b'].should==2 end it "should push with or without name" do @a.push(5) @a.names.should==['a','b','c',nil,nil] @a.push(6,'f') @a.names.should==['a','b','c',nil,nil,'f'] end it "method clear should delete names" do @a.clear @a.names.should be_nil end it "should delete_at names" do @a.delete_at(0) @a.should==[2,3,4] @a.names.should==["b","c",nil] end it "should pop names" do @a.pop @a.names.should==['a','b','c'] end it "should shift names" do @a.shift @a.names.should==['b','c',nil] end it "should reverse! names" do @a.reverse! @a.names.should==[nil,'c','b','a'] end it "should slice names" do b=@a.slice(1,2) b.should==[2,3] b.names.should==['b','c'] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rserve-client-0.1.8 | spec/rserve_withnames_spec.rb |
rserve-client-0.1.7 | spec/rserve_withnames_spec.rb |