ambethia / recaptcha

ReCaptcha helpers for ruby apps
http://github.com/ambethia/recaptcha
MIT License
1.96k stars 439 forks source link

Gem yields 500 Internal Server Error during tests #435

Open xanadiu opened 7 months ago

xanadiu commented 7 months ago

Problem

Despite the following readme statement

By default, reCAPTCHA is skipped in "test" and "cucumber" env.

I discovered that the Gem can cause "Completed 500 Internal Server Error" entries in test.log. This occurs when the environment variable RECAPTCHA_SITE_KEY is not set, independent of its value.

That happened to me during CI jobs where only minimal environment variables were defined. Only after providing an empty site key environment variable the tests succeeded.

Expected behaviour

It would be great if the Gem really and cleanly is skipped in test environments without the need of (empty) environment variables.

System information

grosser commented 7 months ago

PR welcome ... do you have the backtrace ?

xanadiu commented 7 months ago

I did not yet investigate the Gem internals, so I have no starting point for a PR.

Concerning the error or unexpected behaviour: how can I generate a backtrace? My observation is that the log only contains "Completed 500 Internal Server Error" without further context info, even with config.log_level = :debug.

grosser commented 7 months ago

could go into the gem bundle open and add a raise where it does the request or check the code for where the site key is checked and change things there until the test works (locally)