rspec-expectations
rspec-expectations copied to clipboard
Slow sequential And
Subject of the issue
It appears that if And compounds are sequential then tests are running for a long time. Eg.:
expect('qwe').
to include('asd').
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd')).
and(include('asd'))
this is running on my computer for 15 seconds, and each additional condition doubles the previous duration.
It's not a problem with nested and:
expect('qwe').
to include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd').
and include('asd')
This is instant. But I prefer the previous sequential approach as it doesn't increase nesting level.
Your environment
- Ruby version: 2.6.3
- rspec-expectations version: 3.10.1