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

shouldContainAll #100

Closed
AndreasVolkmann opened this issue Apr 25, 2018 · 3 comments
Closed

shouldContainAll #100

AndreasVolkmann opened this issue Apr 25, 2018 · 3 comments
Assignees

Comments

@AndreasVolkmann
Copy link
Collaborator

I think we are missing the shouldContainAll type of extensions.

This one covers my current use case:
infix fun String.shouldContainAll(items: Iterable<CharSequence>): List<CharSequence> = items.map(::shouldContain)

Instead of:

ids.forEach {
    sql shouldContain it.toString()
}

This should be possible:
sql shouldContainAll ids.map(Int::toString)

But this should also apply to Iterables.
listOf(1) shouldNotContainAll listOf(4)

@AndreasVolkmann AndreasVolkmann self-assigned this Apr 25, 2018
@AndreasVolkmann
Copy link
Collaborator Author

@MarkusAmshove I just realized how annoying it is to write tests for both the backtick and non-backtick version.
It's basically copy paste, but both versions have to be maintained even though they use the same logic.

Wouldn't it be better if we had a Spek wrapper that took an Iterable of functions and then ran the specified tests for each of them?

Just an idea, which could reduce the test code size by half.
It's also really annoying to have so many files in the IDE.

@MarkusAmshove
Copy link
Owner

@AndreasVolkmann I feel you 😃

The intent was to use the tests as a kind of documentation of usage at first, but the number of assertions really exploded after the initial release.

It's okay for me if you don't write the backtick tests, because Spek will be removed in the future (atleast for most of the assertions which are platform independent) and I'll migrate the tests to kotlin.test.

@MarkusAmshove
Copy link
Owner

I've published 1.37, which contains this change ✔️

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

No branches or pull requests

2 participants