Sha256: 1ef2d7c143f7af509c1c30900a1f08358cfc56d0713777ad037d3929faad3a4d

Contents?: true

Size: 835 Bytes

Versions: 3

Compression:

Stored size: 835 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 self" do
        expect(delete).to eq(mutable)
      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 self" do
        expect(delete).to eq(mutable)
      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_spec.rb
hamster-3.0.0 spec/lib/hamster/experimental/mutable_set/delete_spec.rb
hamster-2.0.0 spec/lib/hamster/experimental/mutable_set/delete_spec.rb