describe 'the `ai` suggestion strategy' do let(:options) { ["ZSH_AUTOSUGGEST_STRATEGY=(ai history)"] } let(:before_sourcing) do -> { session.run_command('curl() { if [[ "$*" == *"max-time"* ]]; then cat < { session.run_command('curl() { return 1 }') } end it 'falls through to next strategy' do with_history('git status') do session.send_string('git st') wait_for { session.content }.to eq('git status') end end end context 'when API returns HTTP error' do let(:options) { ["ZSH_AUTOSUGGEST_AI_API_KEY=test-key", "ZSH_AUTOSUGGEST_STRATEGY=(ai history)"] } let(:before_sourcing) do -> { session.run_command('curl() { if [[ "$*" == *"max-time"* ]]; then cat < { session.run_command('curl() { if [[ "$*" == *"max-time"* ]]; then cat < { session.run_command('curl() { if [[ "$*" == *"max-time"* ]]; then cat < { session.run_command('curl() { if [[ "$*" == *"max-time"* ]]; then cat < { session.run_command('curl() { return 1 }') } end it 'uses history when AI fails' do with_history('git status --long') do session.send_string('git st') wait_for { session.content }.to eq('git status --long') end end end end