Sha256: 9cc9b09502e8c28fff312187e4b35fae410d88ce835e10944da950b8bcfe8d87

Contents?: true

Size: 1.42 KB

Versions: 3

Compression:

Stored size: 1.42 KB

Contents

require "spec_helper"

describe Hash do
  subject(:hash) { {a: 1, b: 2} }

  describe "#with_indifferent_equality" do
    subject(:with_indifferent_equality) { hash.with_indifferent_equality }

    specify { expect(with_indifferent_equality).to_not equal hash }
  end

  describe "#==" do
    subject(:call) { hash == other }

    context "with normal hashes" do
      context "with different keys" do
        let(:other) { {"a" => 1, "b" => 2} }

        specify { expect(call).to be_false }
      end

      context "with the same keys" do
        let(:other) { hash.dup }

        specify { expect(call).to be_true }
      end
    end

    context "with two indifferent hashes" do
      let(:hash) { {a: 1, b: 2}.with_indifferent_equality }

      context "with different keys" do
        let(:other) { {"a" => 1, "b" => 2}.with_indifferent_equality }

        specify { expect(call).to be_true }
      end

      context "with the same keys" do
        let(:other) { {a: 1, b: 2}.with_indifferent_equality }

        specify { expect(call).to be_true }
      end
    end

    context "with one indifferent hash" do
      context "with different keys" do
        let(:other) { {"a" => 1, "b" => 2}.with_indifferent_equality }

        specify { expect(call).to be_true }
      end

      context "with the same keys" do
        let(:other) { {a: 1, b: 2}.with_indifferent_equality }

        specify { expect(call).to be_true }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tfg_support-1.1.1 spec/tfg/support/core_ext/hash/with_indifferent_equality_spec.rb
tfg_support-1.0.1 spec/tfg/support/core_ext/hash/with_indifferent_equality_spec.rb
tfg_support-1.0.0 spec/tfg/support/core_ext/hash/with_indifferent_equality_spec.rb