Skip to content

Fix empty AICHAT_API_KEY fallback in integration specs#57

Merged
raghubetina merged 1 commit intomainfrom
rb-fix-empty-aichat-key-fallback
Mar 2, 2026
Merged

Fix empty AICHAT_API_KEY fallback in integration specs#57
raghubetina merged 1 commit intomainfrom
rb-fix-empty-aichat-key-fallback

Conversation

@raghubetina
Copy link
Contributor

Summary

Fixes a bug in the integration test setup introduced in PR #56.

The previous test setup used:

  • ENV["AICHAT_API_KEY"] || ENV["OPENAI_API_KEY"]

In Ruby, an empty string is truthy, so when AICHAT_API_KEY="", tests
would incorrectly use the empty key instead of falling back.

What changed

  • Updated spec/integration/ai_chat_integration_spec.rb API key setup to
    treat empty AICHAT_API_KEY as missing before fallback.
  • Applied this in both places:
    • custom env-var test setup (CUSTOM_OPENAI_KEY assignment)
    • direct api_key: test setup

Why

This aligns integration test setup with runtime behavior, where empty
AICHAT_API_KEY should fall back to OPENAI_API_KEY.

Verification

  • bundle exec standardrb spec/integration/ai_chat_integration_spec.rb
  • bundle exec rspec spec/integration/ai_chat_integration_spec.rb:227

Both passed locally.

In integration API key tests,

treats empty strings as present and skips fallback.

Use explicit empty checks before falling back to OPENAI_API_KEY

for custom env-var and direct api_key test setup.

This aligns test setup with runtime behavior and addresses the

PR #56 review finding.
@raghubetina raghubetina merged commit c283f8c into main Mar 2, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant