Sha256: d043f13dd69b3b11238a6a4a7d8117dc47faa92414b638111b4a8afedf9b06d8
Contents?: true
Size: 1.1 KB
Versions: 2
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' describe Array do it 'should sum members' do [1,2,3,4,5].sum.should == 15 [1.5, 5.6].sum.should == 7.1 end it 'should find the mean of members' do [1,2,3,4,5].mean.should == 3 [1.5, 5.6].mean.should == 3.55 end it 'should compact blank objects and leave non-blank objects in place' do [0, 1, 2, 3].compakt.should == [0, 1, 2, 3] [0, nil, 'awesome sauce'].compakt.should == [0, 'awesome sauce'] [0, '', :symbol].compakt.should == [0, :symbol] [[], [1, 2]].compakt.should == [[1, 2]] [{ :stuff => :junk }, {}, 'stuff'].compakt.should == [{ :stuff => :junk }, 'stuff'] [' ', ' I need trimming! '].compakt.should == [' I need trimming! '] end it 'should return random sections of an array' do srand(123456) arr = (1..20).to_a sections = arr.sections(3, 5) sections[0..-2].map{ |s| s.size }.each{ |l| (3..5).should include(l) } sections.flatten.size.should == arr.size end it 'should return the median value of an array' do [1,5,7,8,500].median.should == 7 [5,6,7,12,42,55,55,56].median.should == 27 end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bootstripe-0.2.23 | spec/array_additions_spec.rb |
bootstripe-0.2.22 | spec/array_additions_spec.rb |