Sha256: d2c7f0cc8a4fac5b55e26406191eab79759302d0ad66bd036412d043861db568

Contents?: true

Size: 1.1 KB

Versions: 1

Compression:

Stored size: 1.1 KB

Contents

require 'spec_helper'

describe 'Veritas::Attribute::Comparable#comparable?' do
  subject { object.comparable?(other) }

  let(:klass)  { Attribute::Integer }
  let(:object) { klass.new(:id)     }

  context 'when the other attribute is the same type' do
    let(:other) { object.dup }

    it { should be(true) }

    it 'is symmetric' do
      should == other.comparable?(object)
    end
  end

  context 'when the other attribute is a different class' do
    let(:other) { Attribute::String.new(:different) }

    it { should be(false) }

    it 'is not be symmetric' do
      expect {
        other.comparable?(object)
      }.to raise_error(NoMethodError)
    end
  end

  context 'when the other attribute is a descendant type' do
    let(:other) { Class.new(klass).new(:descendant) }

    it { should be(true) }

    it 'is symmetric' do
      should == other.comparable?(object)
    end
  end

  context 'when the other attribute shares a common type' do
    let(:other) { klass.superclass.new(:ancestor) }

    it { should be(true) }

    it 'is symmetric' do
      should == other.comparable?(object)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
veritas-0.0.2 spec/unit/veritas/attribute/comparable/comparable_spec.rb