Sha256: dcdb4c545119306033393eeb7a6cd24c285cebc58ef3f689db92084ef7b9152a

Contents?: true

Size: 802 Bytes

Versions: 1

Compression:

Stored size: 802 Bytes

Contents

require 'spec_helper'

describe Virtus::DescendantsTracker, '#inherited' do
  subject { object.inherited(descendant) }

  let(:described_class) { Class.new { extend Virtus::DescendantsTracker } }
  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 ]).
      to([ descendant, object ])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
virtus-0.0.4 spec/unit/virtus/descendants_tracker/inherited_spec.rb