I'm looking to challenge myself by integrating and testing JavaScript code within a Ruby environment. My main goal is to utilize Ruby to set up the database, interact with it using my JavaScript model, and verify the JavaScript state without resorting to mocking.
While attempting to load my client libraries into a v8 context, I encountered various issues with therubyracer such as 'window not defined' and 'userAgent not defined' errors.
In my efforts to test my JavaScript code, I've explored using headless browsers. However, they lack the necessary Ruby context required for these specific scenarios.
My current hypothesis suggests that I may need to integrate a browser or DOM simulator into a v8 context, but I am unsure about available libraries for this task. Do you have any alternative suggestions or insights?
How can I successfully achieve this integration and testing process?