Sha256: 39688b8cf8c5e3db686a645638509e04f1185483650ec345bd09a314964eca38
Contents?: true
Size: 1.48 KB
Versions: 9
Compression:
Stored size: 1.48 KB
Contents
require 'spec_helper' require 'sugar-high/array' describe "SugarHigh" do describe "Array ext" do describe '#to_symbols' do it "should translate nested array of numbers and strings into symbols only array, excluding numbers" do [1, 'blip', [3, "hello"]].to_symbols.should == [:blip, :hello] end it "should translate nested array of numbers and strings into symbols only array, including numbers" do [[1, 'blip', [3, "hello"]]].to_symbols(:num).should == [:_1, :blip, :_3, :hello] end it "should translate nested array of numbers and strings into strings only array" do [['blip', [3, :hello]]].to_strings.should == ['blip', 'hello'] end end describe '#to_strings' do it "should translate nested array of numbers and strings into symbols only array, excluding numbers" do [1, 'blip', [3, "hello"]].to_strings.should == ['blip', 'hello'] end end describe '#flat_uniq' do it "should flatten array, remove nils and make unique" do [1, 'blip', ['blip', nil, 'c'], nil].flat_uniq.should == [1, 'blip', 'c'] end it "should return empty list if called on nil" do nil.flat_uniq.should == [] end end describe '#none?' do it "should be none if no real values in array" do [nil, nil].none?.should be_true nil.none?.should be_true end end end end
Version data entries
9 entries across 9 versions & 1 rubygems