summaryrefslogtreecommitdiff
path: root/spec/family_tree_spec.rb
diff options
context:
space:
mode:
authorSzymon Szukalski <szymon@skas.io>2024-10-24 13:28:16 +1100
committerSzymon Szukalski <szymon@skas.io>2024-10-24 13:28:16 +1100
commit55475178a8c0e610103e37027cc0a7a387d72f91 (patch)
tree8ff4f02905758dfd9ae658d7e312877fc7f0c4ac /spec/family_tree_spec.rb
parent3824dda1f184158c8946f02a4f2d533a17e95cd4 (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_spec.rb')
-rw-r--r--spec/family_tree_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/family_tree_spec.rb b/spec/family_tree_spec.rb
new file mode 100644
index 0000000..2059a89
--- /dev/null
+++ b/spec/family_tree_spec.rb
@@ -0,0 +1,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