Sha256: af16ecd36f5c73a9bbf6d40507cddc81eeafbc18195e50823ff50cceb19d6d29

Contents?: true

Size: 977 Bytes

Versions: 5

Compression:

Stored size: 977 Bytes

Contents

require "spec_helper"

describe HashDiff do
  describe ".diff" do
    subject { described_class.diff left, right }

    let(:left) {
      { foo: "bar" }
    }
    let(:right) {
      { foo: "bar2" }
    }

    it { expect(subject).to eq({ foo: ['bar', 'bar2']}) }
  end

  describe ".left_diff" do
    subject { described_class.left_diff left, right }

    let(:left) {
      { foo: "bar" }
    }
    let(:right) {
      { foo: "bar2" }
    }

    it { expect(subject).to eq({ foo: 'bar2' }) }
  end

  describe ".right_diff" do
    subject { described_class.right_diff left, right }

    let(:left) {
      { foo: "bar" }
    }
    let(:right) {
      { foo: "bar2" }
    }

    it { expect(subject).to eq({ foo: 'bar' }) }
  end

  describe ".patch!" do
    before { described_class.patch! }

    it "patches #diff to Hash" do
      expect({}).to respond_to(:diff)
    end

    it "leaves Object alone" do
      expect(Object.new).not_to respond_to(:diff)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
hash_diff-1.1.1 spec/hash_diff_spec.rb
hash_diff-1.1.0 spec/hash_diff_spec.rb
hash_diff-1.0.0 spec/hash_diff_spec.rb
hash_diff-0.8.0 spec/hash_diff_spec.rb
hash_diff-0.7.0 spec/hash_diff_spec.rb