[rspec-users] Test execution time filtering
dchelimsky at gmail.com
Tue Aug 16 07:44:34 EDT 2011
On Aug 9, 2011, at 6:23 PM, Mike Jr wrote:
> 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
> ) 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.
RSpec is built around the premise that each example is run in its own environment, and that one should not depend on the outcome of another. This is not unique to RSpec, btw. It's how all of the unit testing frameworks of which I am aware work.
> 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!)
Nope. You have not missed something. You're just trying to put a square peg into a round hole.
> --Thank you,
> --R.J. Ekim
More information about the rspec-users