Sha256: 9d093d598ae286370f188616e027647d0025dd5710f3c78700de319148631729

Contents?: true

Size: 804 Bytes

Versions: 12

Compression:

Stored size: 804 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe DescendantsTracker, '#add_descendant' do
  subject { object.add_descendant(descendant) }

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

  it_should_behave_like 'a command method'

  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

12 entries across 10 versions & 4 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
grape-extra_validators-1.0.0 vendor/bundle/ruby/2.4.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
config_gems_initialization_aim-0.1.4 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
config_gems_initialization_aim-0.1.3 vendor/bundle/ruby/2.5.0/gems/config_gems_initialization_aim-0.1.1/vendor/bundle/ruby/2.5.0/gems/descendants_tracker-0.0.4/spec/unit/descendants_tracker/add_descendant_spec.rb
descendants_tracker-0.0.4 spec/unit/descendants_tracker/add_descendant_spec.rb
descendants_tracker-0.0.3 spec/unit/descendants_tracker/add_descendant_spec.rb
descendants_tracker-0.0.2 spec/unit/descendants_tracker/add_descendant_spec.rb