summaryrefslogtreecommitdiff
path: root/spec/family_tree_spec.rb
diff options
context:
space:
mode:
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