Sha256: bf13f89478959f729c4469a5f97618cb9d41a22f98dd7ef0b78ab2d9d3e2e291

Contents?: true

Size: 736 Bytes

Versions: 4

Compression:

Stored size: 736 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Attribute, '.inherited' do
  subject { object.inherited(descendant) }

  let(:object)     { Class.new(described_class) }
  let(:descendant) { Class.new                  }

  it { should equal(object) }

  it 'prepends the class to the descendants' do
    object.descendants << original = Class.new
    expect { subject }.to change { object.descendants.dup }.
      from([ original ]).
      to([ descendant, original ])
  end

  it 'prepends the class to the superclass descendants' do
    expect { subject }.to change { object.superclass.descendants.dup }.
      from([ object ].concat(@original_descendants)).
      to([ descendant, object ].concat(@original_descendants))
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
veritas-0.0.7 spec/unit/veritas/attribute/class_methods/inherited_spec.rb
veritas-0.0.6 spec/unit/veritas/attribute/class_methods/inherited_spec.rb
veritas-0.0.5 spec/unit/veritas/attribute/class_methods/inherited_spec.rb
veritas-0.0.4 spec/unit/veritas/attribute/class_methods/inherited_spec.rb