Sha256: 1f5b1c7edc6e5b707574736a6815634a7939870cc67c45e8d6425dd3af489c19

Contents?: true

Size: 1.34 KB

Versions: 18

Compression:

Stored size: 1.34 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Sinclair::EqualsChecker do
  describe '#yard' do
    describe '#match?' do
      it 'regular usage' do
        checker = Sinclair::EqualsChecker.new(:name, :age)

        model1 = SampleModel.new(name: 'jack', age: 21)
        model2 = SampleModel.new(name: 'rose', age: 23)

        expect(checker.match?(model1, model2)).to be_falsey
      end

      it 'similar models' do
        checker = Sinclair::EqualsChecker.new(:name, :age)

        model1 = SampleModel.new(name: 'jack', age: 21)
        model2 = SampleModel.new(name: 'jack', age: 21)

        expect(checker.match?(model1, model2)).to be_truthy
      end

      it 'different classes' do
        checker = Sinclair::EqualsChecker.new(:name, :age)

        model1 = SampleModel.new(name: 'jack', age: 21)
        model2 = OtherModel.new(name: 'jack', age: 21)

        expect(checker.match?(model1, model2)).to be_falsey
      end
    end

    describe '#add' do
      it 'adding fields to equal checker' do
        checker = Sinclair::EqualsChecker.new(:name)

        model1 = SampleModel.new(name: 'jack', age: 21)
        model2 = SampleModel.new(name: 'jack', age: 22)

        expect(checker.match?(model1, model2)).to be_truthy

        checker.add(:age)

        expect(checker.match?(model1, model2)).to be_falsey
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
sinclair-2.1.1 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-2.1.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-2.0.1 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-2.0.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.16.3 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.16.2 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.16.1 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.16.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.15.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.14.2 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.14.1 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.14.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.13.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.12.1 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.12.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.11.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.10.0 spec/integration/yard/sinclair/equals_checker_spec.rb
sinclair-1.9.0 spec/integration/yard/sinclair/equals_checker_spec.rb