Sha256: 96db06ad27c79664572224d46dbc50ff5f03d683e6c7adf219e64275684b3c62

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

require 'hamster/set'

describe Hamster::Set do

  describe "#none?" do

    describe "when empty" do

      before do
        @set = Hamster.set
      end

      it "with a block returns true" do
        @set.none? {}.should be_true
      end

      it "with no block returns true" do
        @set.none?.should be_true
      end

    end

    describe "when not empty" do

      describe "with a block" do

        before do
          @set = Hamster.set("A", "B", "C", nil)
        end

        ["A", "B", "C", nil].each do |value|

          it "returns false if the block ever returns true (#{value.inspect})" do
            @set.none? { |item| item == value }.should be_false
          end

        end

        it "returns true if the block always returns false" do
          @set.none? { |item| item == "D" }.should be_true
        end

      end

      describe "with no block" do

        it "returns false if any value is truthy" do
          Hamster.set(nil, false, true, "A").none?.should be_false
        end

        it "returns true if all values are falsey" do
          Hamster.set(nil, false).none?.should be_true
        end

      end

    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hamster-0.1.19 spec/hamster/set/none_spec.rb
hamster-0.1.18 spec/hamster/set/none_spec.rb
hamster-0.1.17 spec/hamster/set/none_spec.rb
hamster-0.1.16 spec/hamster/set/none_spec.rb
hamster-0.1.15 spec/hamster/set/none_spec.rb