File: add_descendant_spec.rb

package info (click to toggle)
ruby-descendants-tracker 0.0.4-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 212 kB
  • sloc: ruby: 86; makefile: 2
file content (26 lines) | stat: -rw-r--r-- 805 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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