Sha256: 31ad15d4c47ce483ffdde681feb289978f40a8a34698d65ead0ad5597c3cf03a

Contents?: true

Size: 839 Bytes

Versions: 3

Compression:

Stored size: 839 Bytes

Contents

require "spec_helper"
require "hamster/experimental/mutable_set"

describe Hamster::MutableSet do
  let(:mutable) { Hamster::MutableSet[*values] }

  describe "#delete?" do
    let(:values) { %w[A B C] }
    let(:delete?) { mutable.delete?(value) }


    context "with an existing value" do
      let(:value) { "B" }

      it "returns true" do
        expect(delete?).to be(true)
      end

      it "modifies the set to remove the value" do
        delete?
        expect(mutable).to eq(Hamster::MutableSet["A", "C"])
      end
    end

    context "with a non-existing value" do
      let(:value) { "D" }

      it "returns false" do
        expect(delete?).to be(false)
      end

      it "preserves the original values" do
        delete?
        expect(mutable).to eq(Hamster::MutableSet["A", "B", "C"])
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/hamster-3.0.0/spec/lib/hamster/experimental/mutable_set/delete_qm_spec.rb
hamster-3.0.0 spec/lib/hamster/experimental/mutable_set/delete_qm_spec.rb
hamster-2.0.0 spec/lib/hamster/experimental/mutable_set/delete_qm_spec.rb