Skip to content
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

Allow describe without requiring an argument #10974

Conversation

straight-shoota
Copy link
Member

The describe method of the spec DSL currently requires an argument for the description. The general idea behind that is probably, that it makes no sense to describe something without a description.

With spec's focus feature I've several times found myself in a situation where I want to run a couple of related examples in a spec file. Adding focus: true on each one is cumbersome, so I created a (temporary) example group with describe and added focus: true to that. But describe requires an argument with a description. For this focus-only example group I don't need a description, so could just be empty.

I'm proposing to add a default value to the description argument, to make this use case a bit friendlier. Now I'm no longer forced to pass in an empty description.

context is functionally identical to describe, so it also gets a default argument.

@asterite
Copy link
Member

Hm, it seems that works in RSpec too 🤷

Approved! 😄

@Fryguy
Copy link
Contributor

Fryguy commented Jul 21, 2021

Can a spec be added for this case? I can't look at the rest of the code at the moment, but I'm concerned that it will create deep description strings with "bonus" whitespace inside.

@straight-shoota
Copy link
Member Author

straight-shoota commented Jul 21, 2021

There are currently no specs for spec output. Adding that is a different topic (see #5671 for example).

And yes, this will probably add extra whitespace into spec descriptions. But that's a also a different issue. This behaviour is not introduced by this PR, it's already that way if I use describe nil {} or describe "" {} explicitly.

@straight-shoota straight-shoota added this to the 1.2.0 milestone Jul 22, 2021
@straight-shoota straight-shoota merged commit 6ba4429 into crystal-lang:master Jul 23, 2021
@straight-shoota straight-shoota deleted the feature/spec-describe-no-args branch July 23, 2021 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants