rspec-mode
rspec-mode copied to clipboard
Add the ability to run specs filtered by tags
This PR proposes to add the ability to run specs filtered by tag(s).
It adds four functions:
-
rspec-verify-tagged
: only verify the tag(s) in the current file -
rspec-verify-all-tagged
: only verify the tag(s) in the whole suite -
rspec-dired-verify-tagged
: only verify the tag(s) in the current dired scope -
rspec-dired-verify-single-tagged
: only verify the tag(s) in the currently marked files
It also adds the corresponding key bindings
The functions prompt the user for one or more tags following the rspec syntax and appends them to the rspec command.
See https://rspec.info/features/3-12/rspec-core/command-line/tag/
Hi!
Filtering by tags should indeed be a useful addition. Thanks.
Before I merge this, though, have you considered the following alterations:
- Instead of adding new commands, adding a prefix argument to the existing commands - so when called with
C-u
the command would read the list of tags to use. Or this it too slow for your intended usage? - Tags-specific input history - so when you run the command multiple times you can quickly switch to the previous input, but limited to the previous entered tags, not just any strings that were read by previous commands. That can work through an explicit call to
read-string
inside the(interactive ...)
form. - If 1 is a no-go, and new commands are really needed, how about we put them on a separate submap, rather than having three new characters to memorize? Then
rspec-verify-tagged
would by default be on C-c , t v.
Thanks for taking the time to review this, and thanks for your input, which I believe improves the PR. 🙏
I don't think I want to go for 1. I feel it is too slow indeed, when coding / running tests, I want commands to be straightforward and get out of the way, so I decided to go for 2.
So I have added a rspec-tags-history
variable. Each new tag is added to the list, which is persisted in-between sessions if savehist-mode
is on.
I also decided to rename functions from -tagged
to verify-tags-*
-- this avoids confusion in dired mode with dired -tagged
functions, and is clearer too, IMHO.
I finally added the g
submap (C-c , t
clashes with rspec-toggle-spec-and-target
) for all tagged functions.