summaryrefslogtreecommitdiff
path: root/spec/action_file_executor_spec.rb
diff options
context:
space:
mode:
authorSzymon Szukalski <szymon@skas.io>2024-10-25 01:19:25 +1100
committerSzymon Szukalski <szymon@skas.io>2024-10-25 01:19:25 +1100
commitfa50df797d8fcb1e3636683cf2ff1582f35bc181 (patch)
treed5a68c46854fcfecf548e0f13a438bc01f8e490c /spec/action_file_executor_spec.rb
parenta89fa6a27bb0e2b9797dd01052aaf22b38296821 (diff)
Implement extended relationships
- Support uncle, aunt, in-law, son, daughter relationships
Diffstat (limited to 'spec/action_file_executor_spec.rb')
-rw-r--r--spec/action_file_executor_spec.rb20
1 files changed, 11 insertions, 9 deletions
diff --git a/spec/action_file_executor_spec.rb b/spec/action_file_executor_spec.rb
index ce2fa11..1d97f6b 100644
--- a/spec/action_file_executor_spec.rb
+++ b/spec/action_file_executor_spec.rb
@@ -31,7 +31,7 @@ RSpec.describe ActionFileExecutor do
it 'prints an error message and exits' do
expect do
ActionFileExecutor.new(invalid_file_path)
- end.to output("Error: The file 'non_existent_file.txt' does not exist.\n").to_stdout.and raise_error(SystemExit)
+ end.to output("Error: The file 'non_existent_file.txt' does not exist.\n").to_stderr.and raise_error(SystemExit)
end
end
end
@@ -39,11 +39,11 @@ RSpec.describe ActionFileExecutor do
describe '#execute_actions' do
context 'with a valid file' do
before do
- tempfile.write("ADD_CHILD \"Mother's Name\" \"Child's Name\"\n")
+ tempfile.write("ADD_CHILD \"Mother's Name\" \"Child's Name\" Male\n")
tempfile.write("# A comment\n")
tempfile.write("\n")
tempfile.write("INVALID ACTION\n")
- tempfile.write("GET_RELATIONSHIP \"Mother's Name\" \"Child's Name\"\n")
+ tempfile.write("GET_RELATIONSHIP \"Mother's Name\" \"Son\"\n")
tempfile.rewind
end
@@ -60,7 +60,7 @@ RSpec.describe ActionFileExecutor do
allow(action_file_executor).to receive(:execute_action)
action_file_executor.execute_actions
- expect(action_file_executor).to have_received(:execute_action).exactly(3).times
+ expect(action_file_executor).to have_received(:execute_action).exactly(2).times
end
end
end
@@ -95,23 +95,25 @@ RSpec.describe ActionFileExecutor do
context 'with the ADD_CHILD action' do
it 'calls the add_child method on FamilyTree' do
action_file_executor = ActionFileExecutor.new(tempfile.path)
- action_file_executor.send(:execute_action, 'ADD_CHILD', ["Mother's Name", "Child's Name"])
+ action_file_executor.send(:execute_action, 'ADD_CHILD', ["Mother's Name", "Child's Name", 'Male'])
+ expect(family_tree).to have_received(:add_child).with("Mother's Name", "Child's Name", 'Male')
end
end
context 'with the GET_RELATIONSHIP action' do
it 'calls the get_relationship method on FamilyTree' do
action_file_executor = ActionFileExecutor.new(tempfile.path)
- action_file_executor.send(:execute_action, 'GET_RELATIONSHIP', ["Child's Name", 'Maternal-Uncle'])
+ action_file_executor.send(:execute_action, 'GET_RELATIONSHIP', ["Mother's Name", 'Son'])
+ expect(family_tree).to have_received(:get_relationship).with("Mother's Name", 'Son')
end
end
context 'with an unsupported action' do
- it 'prints an error message' do
+ it 'does nothing' do
+ action_file_executor = ActionFileExecutor.new(tempfile.path)
expect do
- action_file_executor = ActionFileExecutor.new(tempfile.path)
action_file_executor.send(:execute_action, 'ADD_MOTHER', ["Child's Name", "Mother's Name"])
- end.to output("Ignoring unsupported action: [ADD_MOTHER]\n").to_stdout
+ end.not_to raise_error
end
end
end