diff options
| author | Szymon Szukalski <szymon@skas.io> | 2024-10-24 11:41:23 +1100 |
|---|---|---|
| committer | Szymon Szukalski <szymon@skas.io> | 2024-10-24 11:41:23 +1100 |
| commit | c1dcd5f91ff082025cbba195af7ed938ce217667 (patch) | |
| tree | 16b512b2c5d955c416b0429bfdd8c73753ba72a1 | |
| parent | 4b6c5ce0cd6b29e0b0842f38b7f9e0f3d5a9d60d (diff) | |
Add CLI::validate_arguments tests
| -rw-r--r-- | spec/cli_spec.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/spec/cli_spec.rb b/spec/cli_spec.rb index 4799ff0..0062c1c 100644 --- a/spec/cli_spec.rb +++ b/spec/cli_spec.rb @@ -38,4 +38,36 @@ RSpec.describe CLI do end end end + + describe '#validate_arguments' do + context 'when no arguments are provided' do + it 'prints usage message and exits' do + expect do + CLI.new([]) + end.to output(%r{Usage: family_tree <path/to/actions.txt>}).to_stdout.and raise_error(SystemExit) + end + end + + context 'when an invalid file path is provided' do + it 'prints error message and exits' do + expect do + CLI.new([invalid_file_path]) + end.to output(/Error: The file 'non_existent_file.txt' does not exist./).to_stdout.and raise_error(SystemExit) + end + end + + context 'when a valid file path is provided' do + it 'does not print any message' do + expect do + CLI.new([valid_file_path]) + end.not_to output.to_stdout + end + + it 'does not raise any errors' do + expect do + CLI.new([valid_file_path]) + end.not_to raise_error + end + end + end end |
