Sha256: 844d95f9d4f5c5264eff86afccc7e24bf9b6a3aa3851a4a24138afab91099824

Contents?: true

Size: 1.03 KB

Versions: 9

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe Virtus::Equalizer::Methods, '#==' do
  subject { object == other }

  let(:object) { described_class.new }

  let(:described_class) do
    Class.new do
      include Virtus::Equalizer::Methods

      def cmp?(comparator, other)
        !!(comparator and other)
      end
    end
  end

  context 'with the same object' do
    let(:other) { object }

    it { should be(true) }

    it 'is symmetric' do
      should eql(other == object)
    end
  end

  context 'with an equivalent object' do
    let(:other) { object.dup }

    it { should be(true) }

    it 'is symmetric' do
      should eql(other == object)
    end
  end

  context 'with an equivalent object of a subclass' do
    let(:other) { Class.new(described_class).new }

    it { should be(true) }

    it 'is symmetric' do
      should eql(other == object)
    end
  end

  context 'with an object of another class' do
    let(:other) { Class.new.new }

    it { should be(false) }

    it 'is symmetric' do
      should eql(other == object)
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

Version Path
virtus-0.5.5 spec/unit/virtus/equalizer/methods/equal_value_spec.rb
virtus-0.5.4 spec/unit/virtus/equalizer/methods/equal_value_spec.rb
virtus-0.5.3 spec/unit/virtus/equalizer/methods/equal_value_spec.rb
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/spec/unit/virtus/equalizer/methods/equal_value_spec.rb
virtus-0.5.2 spec/unit/virtus/equalizer/methods/equal_value_spec.rb
virtus-0.5.1 spec/unit/virtus/equalizer/methods/equal_value_spec.rb
virtus-0.5.0 spec/unit/virtus/equalizer/methods/equal_value_spec.rb
virtus-0.4.2 spec/unit/virtus/equalizer/methods/equal_value_spec.rb
virtus-0.4.1 spec/unit/virtus/equalizer/methods/equal_value_spec.rb