[rspec-users] Skipping slow specs in Guard but running them from that file

Ash Moran ash.moran at patchspace.co.uk
Mon Aug 29 17:31:35 EDT 2011

Hi all

I'm trying to optimise my spec run time. I have 123 examples so far, which run in ~4.2 seconds on average. But 116 of those will run in ~0.18 seconds. So, obviously, I only want to run the slow ones when I change that code.

I've added `adapter: :slow` to the offending example group, which covers the whole of exactly one file.

I've added this to the top of ./Guardfile:

    ENV["GUARD"] = "true"

and this to my ./spec/spec_helper.rb:

    RSpec.configure do |config|
      config.filter_run(focus: true)
      config.filter_run_excluding(adapter: :slow) if GUARD
      config.run_all_when_everything_filtered = true

This is my terminal output:

Running: spec/bitcoin/data_access/satoshi/bdb_satoshi_wallet_repository_spec.rb
No examples matched {:focus=>true}. Running all.
No examples were matched. Perhaps {:adapter=>:slow} is excluding everything?
  0 examples:  100% |==========================================| Time: 00:00:00

Finished in 0.00028 seconds
0 examples, 0 failures

This is not what I expected `config.run_all_when_everything_filtered = true` but from the Relish docs it looks like I misunderstood.

Is this a bug, or a missing feature that could go into a future RSpec, or something that would not make sense anyway (i.e. `run_all_when_everything_filtered` really should only respect the tags from `filter_run`)?

And more pragmatically, is there any way I can achieve what I want now, i.e. have that one file's examples run but only when I save it?



More information about the rspec-users mailing list