Sha256: 400a9abb8caac71286137df782225bd810bde94bdad9d1f0f03b416e707e9e60

Contents?: true

Size: 1006 Bytes

Versions: 5

Compression:

Stored size: 1006 Bytes

Contents

shared_examples_for "a value object" do

  describe "==" do
    subject{ object == other }

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

      it{ should be_true }
    end

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

      it{ should be_true }
    end

    context 'with a different' do
      let(:other){ another_object }

      it{ should be_false }
    end
  end

  describe "eql?" do
    subject{ object.eql?(other) }

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

      it{ should be_true }
    end

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

      it{ should be_true }
    end

    context 'with a different' do
      let(:other){ another_object }

      it{ should be_false }
    end
  end

  describe "hash" do

    it 'stays the same when dupped' do
      object.hash.should eq(object.dup.hash)
    end

    it 'is not equal to the other one' do
      object.hash.should_not eq(another_object.hash)
    end
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
domain-1.0.0 spec/shared/a_value_object.rb
domain-1.0.0.rc4 spec/shared/a_value_object.rb
domain-1.0.0.rc3 spec/shared/a_value_object.rb
domain-1.0.0.rc2 spec/shared/a_value_object.rb
domain-1.0.0.rc1 spec/shared/a_value_object.rb