|
| 1 | +#!/bin/bash |
| 2 | +# ShellSpec tests for bash completion nospace integration |
| 3 | +# Tests that the bash completion function logic is correct |
| 4 | + |
| 5 | +Describe "Ruby Butler Bash Completion Nospace Integration" |
| 6 | + Include spec/support/helpers.sh |
| 7 | + |
| 8 | + Describe "compopt nospace behavior with directory completions" |
| 9 | + It "single directory completion does not add space (allows subdirectory navigation)" |
| 10 | + When run rb __bash_complete "rb -C sp" 9 |
| 11 | + The status should equal 0 |
| 12 | + The output should equal "spec/" |
| 13 | + The lines of output should equal 1 |
| 14 | + # Even with count=1, if it's a directory, nospace is applied |
| 15 | + End |
| 16 | + |
| 17 | + It "multiple directory completions do not add space" |
| 18 | + When run rb __bash_complete "rb -C spec/" 13 |
| 19 | + The status should equal 0 |
| 20 | + The line 1 of output should end with "/" |
| 21 | + The line 2 of output should end with "/" |
| 22 | + The line 3 of output should end with "/" |
| 23 | + # Multiple directories, nospace is applied |
| 24 | + End |
| 25 | + End |
| 26 | + |
| 27 | + Describe "completion script logic validation" |
| 28 | + It "generated script contains all_dirs flag" |
| 29 | + When run rb shell-integration bash |
| 30 | + The output should include "local all_dirs=true" |
| 31 | + End |
| 32 | + |
| 33 | + It "generated script applies nospace when all completions are directories" |
| 34 | + When run rb shell-integration bash |
| 35 | + # shellcheck disable=SC2016 |
| 36 | + The output should include 'if [ "$all_dirs" = true ]; then' |
| 37 | + The output should include "compopt -o nospace" |
| 38 | + End |
| 39 | + End |
| 40 | +End |
0 commit comments