Ash Moran
2011-Aug-29 21:31 UTC
[rspec-users] Skipping slow specs in Guard but running them from that file
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 end 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? Cheers Ash -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashmoran
Nikolay Sturm
2011-Aug-30 06:01 UTC
[rspec-users] Skipping slow specs in Guard but running them from that file
* Ash Moran [2011-08-30]:> 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 have a similar situation with the slow specs being integration specs in a special directory. I tagged all those example groups and setup two guards. The first is for unit tests and ignores all examples tagged ''integration'' and doesn''t watch spec/integration. The second guard just watches spec/integration and runs only examples tagged ''integration''. Haven''t used it much yet, though. cheers, Nikolay
Ash Moran
2011-Aug-30 10:29 UTC
[rspec-users] Skipping slow specs in Guard but running them from that file
On 30 Aug 2011, at 07:01, Nikolay Sturm wrote:> I have a similar situation with the slow specs being integration specs > in a special directory. I tagged all those example groups and setup two > guards. The first is for unit tests and ignores all examples tagged > ''integration'' and doesn''t watch spec/integration. The second guard just > watches spec/integration and runs only examples tagged ''integration''. > Haven''t used it much yet, though.I never thought of that! Yes, that could also work, probably better in fact. It just involves running multiple Guard processes, although there''s Terminitor[1] for that! At this point I didn''t want to separate my specs into unit/ and integration/ folders. One surprisingly major reason is that I live off the RSpec TextMate bundle''s Alternate File feature to swap between lib/ and spec/ files. It also makes writing the Guard matchers a lot easier (i.e. you don''t have to change anything). I may change that if I find I often want to locate files by their nature. Cheers Ash [1] https://rubygems.org/gems/terminitor -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashmoran
Nikolay Sturm
2011-Aug-30 13:45 UTC
[rspec-users] Skipping slow specs in Guard but running them from that file
* Ash Moran [2011-08-30]:> I never thought of that! Yes, that could also work, probably better in > fact. It just involves running multiple Guard processes, although > there''s Terminitor[1] for that!A single guard process is enough, it will start all guards defined in your Guardfile. cheers, Nikolay -- "It''s all part of my Can''t-Do approach to life." Wally
Ash Moran
2011-Aug-30 14:41 UTC
[rspec-users] Skipping slow specs in Guard but running them from that file
On 30 Aug 2011, at 14:45, Nikolay Sturm wrote:> A single guard process is enough, it will start all guards defined in > your Guardfile.I did not know that! I''m still new to Guard, a recent convert from Autotest. Thanks for the tip. Cheers Ash -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashmoran
Ash Moran
2011-Sep-09 12:09 UTC
[rspec-users] Skipping slow specs in Guard but running them from that file
On 30 Aug 2011, at 14:45, Nikolay Sturm wrote:> * Ash Moran [2011-08-30]: >> I never thought of that! Yes, that could also work, probably better in >> fact. It just involves running multiple Guard processes, although >> there''s Terminitor[1] for that! > > A single guard process is enough, it will start all guards defined in > your Guardfile.This just came in really handy. I''m helping out now and again with a new Rails project using Spork and Guard. We moved some code out into lib/ and set up a separate `guard ''rspec''` to only monitor lib/ and spec/lib/. Took a bit of jiggery-pokery to make it not use Spork and Rails but it works now, and is as fast as RSpec runs get. I''m probably late to the party with Guard, as I used AutoTest for years. But for the benefit of anyone new to either: if you''re not doing continuous testing, _you should be_*, and if you are, you should never be happy with how fast they run. They can always be faster. Always. Guard makes it much easier than AutoTest to tune the test runs, and does other cool stuff too. *It was David Chelimsky who said the exact same thing to me on this list, what- 5 or 6 years ago? One of the best pieces of advice I ever got. Funny how for all the new fangled technology we''ve had in the mean time (and for all I''ve learnt since), I''m still using the same basic development process I used back then? Ash -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashmoran
Ash Moran
2011-Nov-27 21:41 UTC
[rspec-users] Skipping slow specs in Guard but running them from that file
On 30 Aug 2011, at 14:45, Nikolay Sturm wrote:> * Ash Moran [2011-08-30]: >> I never thought of that! Yes, that could also work, probably better in >> fact. It just involves running multiple Guard processes, although >> there''s Terminitor[1] for that! > > A single guard process is enough, it will start all guards defined in > your Guardfile.Hi Nikolay Just reviving this old thread as I ran into problems with multiple RSpec guards[1] (patched now). Have you ever seen this behaviour? I forgot to write an acceptance test so as yet nobody believes me it happens :) Ash [1] https://github.com/guard/guard-rspec/issues/74 -- http://www.patchspace.co.uk/ http://www.linkedin.com/in/ashmoran