Sha256: 8645bace105f332fcc07250cb36764bd880b701f003deba74d59d32ac2d147d9

Contents?: true

Size: 727 Bytes

Versions: 3

Compression:

Stored size: 727 Bytes

Contents

require "spec_helper"
require "hamster/deque"

describe Hamster::Deque do
  describe "#clear" do
    [
      [],
      ["A"],
      %w[A B C],
    ].each do |values|
      context "on #{values}" do
        let(:deque) { D[*values] }

        it "preserves the original" do
          deque.clear
          deque.should eql(D[*values])
        end

        it "returns an empty deque" do
          deque.clear.should equal(D.empty)
        end
      end
    end
  end

  context "from a subclass" do
    it "returns an instance of the subclass" do
      subclass = Class.new(Hamster::Deque)
      instance = subclass.new([1,2])
      instance.clear.should be_empty
      instance.clear.class.should be(subclass)
    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/deque/clear_spec.rb
hamster-3.0.0 spec/lib/hamster/deque/clear_spec.rb
hamster-2.0.0 spec/lib/hamster/deque/clear_spec.rb