Sha256: cebe8afdf17c67274605a22fa073eb3a14535af44dfc654908cdf23526538e48

Contents?: true

Size: 1.19 KB

Versions: 2

Compression:

Stored size: 1.19 KB

Contents

require "spec_helper"
require "hamster/hash"

RSpec.describe Hamster::Hash do
  describe "#<=" do
    [
      [{}, {}, true],
      [{"A" => 1}, {}, false],
      [{}, {"A" => 1}, true],
      [{"A" => 1}, {"A" => 1}, true],
      [{"A" => 1}, {"A" => 2}, false],
      [{"B" => 2}, {"A" => 1, "B" => 2, "C" => 3}, true],
      [{"A" => 1, "B" => 2, "C" => 3}, {"B" => 2}, false],
      [{"B" => 0}, {"A" => 1, "B" => 2, "C" => 3}, false],
    ].each do |a, b, expected|
      describe "for #{a.inspect} and #{b.inspect}" do
        it "returns #{expected}"  do
          expect(H[a] <= H[b]).to eq(expected)
        end
      end
    end
  end

  describe "#<" do
    [
      [{}, {}, false],
      [{"A" => 1}, {}, false],
      [{}, {"A" => 1}, true],
      [{"A" => 1}, {"A" => 1}, false],
      [{"A" => 1}, {"A" => 2}, false],
      [{"B" => 2}, {"A" => 1, "B" => 2, "C" => 3}, true],
      [{"A" => 1, "B" => 2, "C" => 3}, {"B" => 2}, false],
      [{"B" => 0}, {"A" => 1, "B" => 2, "C" => 3}, false],
    ].each do |a, b, expected|
      describe "for #{a.inspect} and #{b.inspect}" do
        it "returns #{expected}"  do
          expect(H[a] < H[b]).to eq(expected)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 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/hash/subset_spec.rb
hamster-3.0.0 spec/lib/hamster/hash/subset_spec.rb