spec/sugar-high/array_spec.rb in sugar-high-0.4.3 vs spec/sugar-high/array_spec.rb in sugar-high-0.4.4

- old
+ new

@@ -3,10 +3,14 @@ describe "SugarHigh" do describe "Array ext" do describe '#to_symbols' do + it "should translate invalid array into empty array" do + [1, nil].to_symbols.should == [] + end + 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 @@ -21,19 +25,29 @@ describe '#to_symbols!' do it "should translate nested array of numbers and strings into symbols only array, excluding numbers" do x = [1, 'hello', 'blip', [3, "hello"]].to_symbols! x.should include :hello, :blip end + + it "should translate invalid array into empty array" do + x = [1, nil].to_symbols! + x.should == [] + 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 '#to_strings!' do + describe '#to_strings' do + it "should translate invalid array into empty array" do + x = [1, nil].to_strings! + x.should == [] + end + it "should translate nested array of numbers and strings into symbols only array, excluding numbers" do x = [1, 'blip', [3, "hello"]].to_strings! x.should == ['blip', 'hello'] end end @@ -47,9 +61,14 @@ nil.flat_uniq.should == [] end end describe '#flat_uniq!' do + it "should translate invalid array into empty array" do + x = [1, nil].to_strings! + x.should == [] + end + it "should flatten array, remove nils and make unique" do x = [1, 'blip', ['blip', nil, 'c'], nil] x.flat_uniq! x.should == [1, 'blip', 'c'] end