-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Discussion: 'tags' experiment #1
Comments
I don't know if this is the right location, but the https://github.com/JustinRyanH/experiments/blob/master/tags/src/main.rs |
The point of my version was to not give the actual types/tags semantic meaning. They’re no more than a set of names, limited to a predefined set of possible values. Combined with logic for inclusive as well as exclusive filterung we should be able to provide all options one might need. |
Not convinced by the need of tagging as the state of rspec right now. Maybe in a year, but for now it doesn't strike me as something needed. Maybe wait for someone who has a need for it ? |
Hey @mackwic,
I'd like to hear you views on the prospect adding type-safe tagging to rspec (assuming that we decide that we want to support tagging to begin with).
Pretty much all BDD frameworks out there support some form of through tagging:
Generalized Tags:
[String : Bool]
, what would be a…Map<String, bool>
in Rust.std::set<std::string>
, what would be a…Set<String>
in Rust.std::vector<struct { std::string, bool }>
, what would be aVec<(String, bool)>
in Rust.The benefit us making tags string-based is the obvious one of extensibility. With string-based extensibility comes a cost however: it's hard to catch typos.
Specialized Functions:
Apart from Catch they also all provide API method variants along the lines of
fdescribe
("focus describe") oridescribe
("ignore describe").I'd prefer to not go this route as it simply doesn't scale and can easily be generalized through proper tagging.
Rust Rspec
How I envision rspec's tagging is by providing a carefully chosen set of batteries-included tags, like this:
Which then, assuming an existing test scenario defined like this …
… would be used like this …
… causing only
scenario : suite : context B
to be executed, when run with--skip="ignore"
.If the default set of tags is not enough for one's needs then by simply specifying a custom type
T: TagsTrait
…… which then could be filtered for through
--filter="lorem, ipsum"
The big benefit here is two-fold:
tags: Tag::INGORE
instead oftags: Tag::IGNORE
would trigger a compile-time error.--filter="ingore"
instead of--filter="ignore"
would trigger a run-time error.Both is possible by having type
Tag
define a closed set of allowed tags, which still remains open for extension through custom types.Caveat:
To make tagging ergonomic we would basically be forced to migrate to a use of macros à la
suite!(…)
instead ofctx.suite(…)
. I would however see this as a feature, not a bug, as it also greatly improves extensibility through support for optional arguments. I don't expect optional function/method arguments to lang in stable Rust (or even nightly) any time soon, given the current focus on async/await, NLL, RLS, etc.The text was updated successfully, but these errors were encountered: