File: inherited_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-- 716 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, '#inherited' do
  subject { Class.new(object) }

  let!(:object)    { Class.new(superklass).extend(self.class.described_class) }
  let(:superklass) { Class.new                                                }

  it 'delegates to the superclass #inherited method' do
    superklass.should_receive(:inherited) do |descendant|
      expect(descendant).to be_instance_of(Class)
      expect(descendant.ancestors).to include(object)
    end
    subject
  end

  it 'adds the descendant' do
    expect(object.descendants).to include(subject)
  end

  it 'sets up descendants in the child class' do
    expect(subject.descendants).to eql([])
  end
end