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

Add extra scopes for BehaviorSpec #593

Merged

Conversation

LeoColman
Copy link
Member

@LeoColman LeoColman commented Jan 18, 2019

To improve BehaviorSpec customizability, this commit adds extra scopes to BehaviorSpec. As discussed, users can concatenate And indefinitely, but it's ok. As And is optional to complete a test. This behavior is also observed in FreeSpec, as it can concatenate infinite test scopes too.

To do that, Given and And/When contexts received a new possibility of scoping, And. There are some variations of it, to build tests correctly: GivenAndContext and WhenAndContext. All of these are optional to use.

Fixes #562

@LeoColman LeoColman force-pushed the feature/562-accept-and-inside-when-scope-and-then-scope branch from 32afbe5 to 99418c7 Compare January 18, 2019 12:43
@LeoColman
Copy link
Member Author

Added docs

@sksamuel
Copy link
Member

TestType.Test cannot (or should not) be nested inside other's.
They should be used for leaves only.
So I think allow 'and' everywhere but inside the 'Then' ?

@LeoColman
Copy link
Member Author

I was thinking about it. I think the correct TestType would be TEST_AND_CONTAINER, but I remember that you couldn't use it because it is bugged in Gradle.

What I had to do there is that Then can be either a final test or a scope for And. The tests are working, and I only did this instead of Container so the IDE would mark it as a test, not a container.

Perhaps there's another way?

@LeoColman
Copy link
Member Author

And what are the rules for TestType.TEST to not be nested inside another one? I know it's counterintuitive when you read it, but are there cases that it wouldn't work?

@LeoColman
Copy link
Member Author

As this is an intended feature from Gradle, could we add this anyways and mark it for fixing when gradle fixes its issue?

@sksamuel
Copy link
Member

sksamuel commented Jan 18, 2019

In theory you can nest TEST inside TEST_AND_CONTAINER, but it's all broken in gradle and they haven't fixed it in over a year. I guess other features take priority, although I would have thought working test support would be high priority in build tool. At this rate they might not fix it until 2020 so we can't rely on it working any time soon.

Anyway, just don't use TEST inside TEST, so remove 'and' from within 'then'.

@LeoColman
Copy link
Member Author

That's a bummer.
I will remove it, but will let it commented for whenever gradle does it's thing.

@LeoColman
Copy link
Member Author

Nvm, comments are very ugly.

To improve BehaviorSpec customizability, this commit adds extra scopes to BehaviorSpec. As discussed, users can concatenate `And` indefinitely, but it's ok. As `And` is optional to complete a test. This behavior is also observed in `FreeSpec`, as it can concatenate infinite test scopes too.

To do that, Given and And/When contexts received a new possibility of scoping, `And`. There are some variations of it, to build tests correctly: GivenAndContext and WhenAndContext. All of these are optional to use.

Fixes #562
@LeoColman LeoColman force-pushed the feature/562-accept-and-inside-when-scope-and-then-scope branch from 99418c7 to 462667c Compare January 18, 2019 14:33
@LeoColman
Copy link
Member Author

Should be good to go.

@LeoColman LeoColman merged commit ce9c13a into master Jan 18, 2019
@LeoColman LeoColman deleted the feature/562-accept-and-inside-when-scope-and-then-scope branch January 18, 2019 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants