Sha256: 153c5ac5ca9a2f01a668c2623f1acd0611b39d035187ef2b6f73878e8ae662f9

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

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

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 be_true
      end

      it "with no block returns true" do
        @set.all?.should be_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 be_true
        end

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

      end

      describe "with no block" do

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

        [nil, false].each do |value|

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

        end

      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamster-0.1.14 spec/hamster/set/all_spec.rb
hamster-0.1.13 spec/hamster/set/all_spec.rb
hamster-0.1.12 spec/hamster/set/all_spec.rb
hamster-0.1.11 spec/hamster/set/all_spec.rb