Sha256: d13dbcebeb462d2809ce114a9b38445eceaa3653281ff7889d1d7994cb394458

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

  let(:described_class) { Attribute::Integer       }
  let(:object)          { described_class.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(described_class).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) { described_class.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.4 spec/unit/veritas/attribute/comparable/comparable_spec.rb