Sha256: a892f950277f3d6462dd0a779d005da05723fd343de5a8a8c9bf2bf629b81a50

Contents?: true

Size: 710 Bytes

Versions: 2

Compression:

Stored size: 710 Bytes

Contents

require "spec_helper"
require "hamster/hash"

describe Hamster::Hash do
  let(:hash) { described_class.new("A" => "aye", "B" => "bee", "C" => "see", nil => "NIL") }

  describe "#slice" do
    let(:slice) { hash.slice(*values) }

    context "with all keys present in the Hash" do
      let(:values) { ["B", nil] }

      it "returns the sliced values" do
        expect(slice).to eq(described_class.new("B" => "bee", nil => "NIL"))
      end
    end

    context "with keys aren't present in the Hash" do
      let(:values) { ["B", "A", 3] }

      it "returns the sliced values of the matching keys" do
        expect(slice).to eq(described_class.new("A" => "aye", "B" => "bee"))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hamster-1.0.1.pre.rc2 spec/hamster/hash/slice_spec.rb
hamster-1.0.1.pre.rc.1 spec/hamster/hash/slice_spec.rb