Sha256: 6a68aa4bccc5dc021d379064422661e5b98dc618e9596efec2d9679071dede92

Contents?: true

Size: 812 Bytes

Versions: 16

Compression:

Stored size: 812 Bytes

Contents

require 'spec_helper'

describe Virtus::DescendantsTracker, '#add_descendant' do
  subject { object.add_descendant(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

16 entries across 16 versions & 2 rubygems

Version Path
fragrant-0.0.5 vendor/bundle/ruby/1.9.1/gems/virtus-0.5.2/spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.5.2 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.5.1 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.5.0 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.4.2 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.4.1 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.4.0 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.3.0 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.2.0 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.1.0 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.0.10 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.0.9 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.0.8 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.0.7 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.0.6 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb
virtus-0.0.5 spec/unit/virtus/descendants_tracker/add_descendant_spec.rb