|
| 1 | +#!/bin/bash |
| 2 | +# ShellSpec tests for directory completion nospace behavior |
| 3 | +# Tests that bash completion for directories behaves correctly with trailing slashes |
| 4 | + |
| 5 | +Describe "Ruby Butler Directory Completion Nospace" |
| 6 | + Include spec/support/helpers.sh |
| 7 | + |
| 8 | + Describe "bash completion script behavior" |
| 9 | + It "should add space after completing a partial directory name (allows next argument)" |
| 10 | + # When completing "rb -C sp<TAB>" -> "rb -C spec/ " |
| 11 | + # Bash SHOULD add a space because user might want to continue with next arg |
| 12 | + # The completion function detects $cur doesn't end with / yet |
| 13 | + |
| 14 | + Skip "Manual test: source completion, type 'rb -C sp' then TAB" |
| 15 | + |
| 16 | + # Expected: "rb -C spec/ " (with space) |
| 17 | + # This allows: "rb -C spec/ run" or other commands |
| 18 | + End |
| 19 | + |
| 20 | + It "should NOT add space when navigating within directory path (allows subdirectory completion)" |
| 21 | + # When completing "rb -C spec/<TAB>" -> suggests subdirs |
| 22 | + # Bash should NOT add space because $cur ends with / |
| 23 | + # This allows continued navigation: "rb -C spec/commands/<TAB>" |
| 24 | + |
| 25 | + Skip "Manual test: source completion, type 'rb -C spec/' then TAB" |
| 26 | + |
| 27 | + # Expected: suggests "spec/behaviour/", "spec/commands/", "spec/support/" |
| 28 | + # Then "rb -C spec/commands/" (no space) allows further TAB completion |
| 29 | + End |
| 30 | + End |
| 31 | + |
| 32 | + Describe "completion output correctness" |
| 33 | + It "outputs directory names with trailing slash" |
| 34 | + When run rb __bash_complete "rb -C sp" 9 |
| 35 | + The output should include "spec/" |
| 36 | + End |
| 37 | + |
| 38 | + It "outputs subdirectories with full path and trailing slash" |
| 39 | + When run rb __bash_complete "rb -C spec/" 13 |
| 40 | + The output should include "spec/behaviour/" |
| 41 | + The output should include "spec/commands/" |
| 42 | + The output should include "spec/support/" |
| 43 | + End |
| 44 | + End |
| 45 | +End |
0 commit comments