summaryrefslogtreecommitdiff
path: root/spec/family_tree_spec.rb
blob: 2059a89bb6d02565656c3f11255ac35e0f66388f (plain)
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# frozen_string_literal: true

require_relative '../lib/family_tree'

RSpec.describe FamilyTree do
  describe '#initialize' do
    it 'creates an empty array' do
      family_tree = FamilyTree.new
      expect(family_tree.instance_variable_get(:@people)).to eq([])
    end
  end

  describe '#add_child' do
    it 'is defined' do
      family_tree = FamilyTree.new
      expect(family_tree).to respond_to(:add_child)
    end

    it 'prints the params' do
      family_tree = FamilyTree.new
      expect do
        family_tree.add_child('Child', 'Mother', 'Father')
      end.to output("Adding Child with params: Child, Mother, Father\n").to_stdout
    end
  end

  describe '#query_hierarchy' do
    it 'is defined' do
      family_tree = FamilyTree.new
      expect(family_tree).to respond_to(:query_hierarchy)
    end

    it 'prints the params' do
      family_tree = FamilyTree.new
      expect do
        family_tree.query_hierarchy('Child')
      end.to output("Querying Hierarcy with params: Child\n").to_stdout
    end
  end
end