[rspec-users] Test execution time filtering

Mike Jr n00spam at comcast.net
Tue Aug 9 19:23:37 EDT 2011


As I understand it, RSpec runs in two passes.  The first pass reads
your code and invokes factory methods to generate instances of example-
group and example subclasses.  The second pass then invokes these
generated instance to run your test.

RSpec filters (via RSpec.configure) are set and operate during the
first pass.  The determination if a particular describe or it block is
to be skipped is determined before the first test is executed in the
second pass.  Even if I were to use a lambda in the filter (see
http://blog.davidchelimsky.net/2010/06/14/filtering-examples-in-rspec-2/
) this would execute in the first pass.

This is well and good.  Why generate test code that will be skipped?

But a sophisticated test will make decisions in mid test.  If a
certain test condition occurs, set a singleton hash and then have
later tests condition their processing on that hash.  In my tests,
these if statements are within the it blocks so that they execute
during the second pass.

It sure would be less clutter if the describe and it statements
supported a filter that is evaluated in the second pass.

Or have I missed some existing feature? (Oh please be true!)

--Thank you,
--R.J. Ekim


More information about the rspec-users mailing list