Sha256: db72b8d7edcf2abbaf8ec103cd046de05646174e2de9401bee96ddd50cdf2862

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

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

require 'hamster/set'

describe Hamster::Set do

  describe "#all?" do

    describe "when empty" do

      before do
        @set = Hamster.set
      end

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

      it "with no block returns true" do
        @set.all?.should == true
      end

    end

    describe "when not empty" do

      describe "with a block" do

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

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

        it "returns false if the block ever returns false" do
          @set.all? { |item| item == "D" }.should == false
        end

      end

      describe "with no block" do

        it "returns true if all values are truthy" do
          Hamster.set(true, "A").all?.should == true
        end

        [nil, false].each do |value|

          it "returns false if any value is #{value.inspect}" do
            Hamster.set(value, true, "A").all?.should == false
          end

        end

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamster-0.1.23 spec/hamster/set/all_spec.rb
hamster-0.1.22 spec/hamster/set/all_spec.rb
hamster-0.1.21 spec/hamster/set/all_spec.rb
hamster-0.1.20 spec/hamster/set/all_spec.rb