Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow running rspec in interactive mode #2796

Open
mrexox opened this issue Dec 11, 2020 · 2 comments
Open

Allow running rspec in interactive mode #2796

mrexox opened this issue Dec 11, 2020 · 2 comments

Comments

@mrexox
Copy link

mrexox commented Dec 11, 2020

Subject of the issue

There can be a situation when one small test is failing and you spend hours to make it work. But initialization can take so long, so it is about 30 seconds waiting for initialization and 1 second to execute the test. I wonder, what if rspec supported interactive mode, like waiting for file or files for input and running them interactively? I can prepare a PR for that if is is acceptable.

Your environment

  • Ruby version: 2.6.6
  • rspec-core version: 2.14.8

Steps to reproduce

  • Add a custom seeder to rspec that loads some data from a file into database.
  • Write a small test
  • Wait for a test to complete and see how long it takes to just seed the environment

Proposition

  • Add an -i, --interactive flag that allows running rspec in interactive mode when it loads the environment once and only runs needed tests
@pirj
Copy link
Member

pirj commented Dec 11, 2020

Do you use spring/bootsnap/guard? They can help.

Otherwise, you may take a look at this https://relishapp.com/rspec/rspec-core/v/3-9/docs/running-specs-multiple-times-with-different-runner-options-in-the-same-process

Pretty sure this will be a useful extension, but I'm not sure it's a common case. E.g. my current Rails project loads the env in under 2 seconds.

@JonRowe
Copy link
Member

JonRowe commented Dec 11, 2020

The problem with pinning your environment, is it won't be reloaded, its not as simple as "load your environment, run specs, await your command to run specs again" we would need to know what files changed, clear our the old code, reload those files, and then run specs again.

As @pirj points out this is an approach Rails has tried for many years to speed up its notoriously slow boot time and there are several solutions that have spun out from that, there isn't one solution because its really hard, and at best its a band aid and has numerous problems. That isn't something RSpec is interested in maintaining.

However. If you wanted to work on an api defining a "preload" hook, a "reload" hook, and a "trigger", then have an interactive mode that calls preload, runs specs, resets, then calls the reload hook when triggerd, I would not be against that.

But I don't want to maintain the magic of reloading code ourselves.

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

No branches or pull requests

3 participants