diff options
| author | Szymon Szukalski <szymon@skas.io> | 2024-10-24 13:28:16 +1100 |
|---|---|---|
| committer | Szymon Szukalski <szymon@skas.io> | 2024-10-24 13:28:16 +1100 |
| commit | 55475178a8c0e610103e37027cc0a7a387d72f91 (patch) | |
| tree | 8ff4f02905758dfd9ae658d7e312877fc7f0c4ac /spec/family_tree_manager_spec.rb | |
| parent | 3824dda1f184158c8946f02a4f2d533a17e95cd4 (diff) | |
Define FamilyTree
- Implemented basic FamilyTree which will hold all the people and perform actions on them
- Updated the FamilyTree Manager to create an instance of the FamilyTree
- Updated the FamilyTreeManager to call the add_child and query_hierarchy methods on the FamilyTree
- Update tests
Diffstat (limited to 'spec/family_tree_manager_spec.rb')
| -rw-r--r-- | spec/family_tree_manager_spec.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/spec/family_tree_manager_spec.rb b/spec/family_tree_manager_spec.rb index d3d21f1..a1161ae 100644 --- a/spec/family_tree_manager_spec.rb +++ b/spec/family_tree_manager_spec.rb @@ -4,10 +4,15 @@ require_relative '../lib/family_tree_manager' RSpec.describe FamilyTreeManager do let(:family_tree_manager) { FamilyTreeManager.instance } + let(:family_tree) { instance_double(FamilyTree) } + + before do + family_tree_manager.instance_variable_set(:@family_tree, family_tree) + end describe '#initialize' do - it 'initialises the family_members hash' do - expect(family_tree_manager.instance_variable_get(:@family_members)).to eq({}) + it 'creates a family tree' do + expect(family_tree_manager.instance_variable_get(:@family_tree)).to eq(family_tree) end end @@ -15,6 +20,11 @@ RSpec.describe FamilyTreeManager do it 'is defined' do expect(family_tree_manager).to respond_to(:add_child) end + + it 'calls add_child on the family tree' do + expect(family_tree).to receive(:add_child).with('Child', 'Mother', 'Father') + family_tree_manager.add_child('Child', 'Mother', 'Father') + end end describe '#query_hierarchy' do |
