Sha256: 3f74a9e89d86822d2731e15f45470b59db3d2f5b02b258afce34db5beea0c9ce
Contents?: true
Size: 1.5 KB
Versions: 2
Compression:
Stored size: 1.5 KB
Contents
require "spec_helper" require "hamster/vector" describe Hamster::Vector do let(:vector) { Hamster.vector(*values) } describe "#exist?" do let(:exist?) { vector.exist?(&block) } context "when created with no values" do let(:values) { [] } context "with a block" do let(:block) { ->(item) { item + 1 } } it "returns false" do expect(exist?).to be(false) end end context "with a block" do let(:block) { nil } it "returns false" do expect(exist?).to be(false) end end end context "when created with values" do let(:values) { ["A", "B", 3, nil] } context "with a block that returns true" do let(:block) { ->(item) { item == 3 } } it "returns true" do expect(exist?).to be(true) end end context "with a block that doesn't return true" do let(:block) { ->(item) { item == "D" } } it "returns false" do expect(exist?).to be(false) end end context "without a block" do let(:block) { nil } context "with some values that are truthy" do let(:values) { [nil, false, "B"] } it "returns true" do expect(exist?).to be(true) end end context "with all values that are falsey" do let(:values) { [nil, false] } it "returns false" do expect(exist?).to be(false) end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
hamster-1.0.1.pre.rc2 | spec/lib/hamster/vector/exist_spec.rb |
hamster-1.0.1.pre.rc.1 | spec/lib/hamster/vector/exist_spec.rb |