Sha256: 4caad7c4bc72d3cfcdc29df5ffdcb264ff8a32c70a527336d6cfb0ab140fb4e2
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
# encoding: utf-8 require_relative "../../../lib/rango/ext/enumerable" describe Enumerable do describe "#none?" do describe "withtout block" do it "should be true for empty collections " do Array.new.should be_none Hash.new.should be_none end it "should returns true for collections with just nils and false" do [nil].should be_none [false].should be_none [false, nil].should be_none end it "should returns false if collections contains some objects" do [1].should_not be_none {one: 1, two: 2}.should_not be_none {key: nil, other: false}.should_not be_none end end describe "with block" do describe "for array" do it "should returns false if all iteractions returns true" do array = Array.new(3) { Array.new } array.none? { |item| item.empty? }.should be_false end it "should returns true if all iteractions returns false" do array = Array.new(3) { [1] } array.none? { |item| item.empty? }.should be_true end end describe "for hash" do it "should returns false if all iteractions returns true" do hash = {key: Array.new, another: Hash.new, last: Array.new} hash.none? { |key, value| value.empty? }.should be_false end it "should returns true if all iteractions returns false" do hash = {key: [1], another: [2], last: [nil]} hash.none? { |item| item.empty? }.should be_true end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rango-0.0.4 | spec/rango/ext/enumerable_spec.rb |