Search code examples
rubytestingcucumberarubahighline

How to stub and mock interactive ruby app with Cucumber?


I have an interactive CLI app based on Highline gem. I can run it interactively for Cucumber tests using Aruba. But I can't using stubs and mocks, because Aruba starts my app as a child process. If I try to use Aruba::InProcess feature, it loses interactivity.

I have no idea any more. In what way can I testing such app?


Solution

  • Ok, I take that: Cucumber is not about stubs and mocks. And interactive CLI apps is, probably, the best example for it. So, while you need interactivity, Cucumber through Aruba starts your app in a child process. And the only way for affect it, I find, is environment variables usage. For example, by setting variable with values 'production'/'development'/'test' I can change configuration of my app to using test DB instead of production etc.