cats-effect-testing icon indicating copy to clipboard operation
cats-effect-testing copied to clipboard

Upgrade specs2

Open etorreborre opened this issue 4 years ago • 6 comments

This PR uses specs2-5.x for Scala 3 and specs2-4.x for Scala 2. Both versions support the new MacrotaskExecutor execution context.

etorreborre avatar Sep 08 '21 22:09 etorreborre

Note that the PR will be updated with specs2-5.0.0 when an official version will be released.

etorreborre avatar Sep 08 '21 22:09 etorreborre

@etorreborre thanks for moving so fast on these PRs! I think to release we'll have to make a separate module and/or a version bump ... in which case, instead of emphasizing source compatibility, aren't there several improvements we can make to the implementation to take advantage of new specs2 v5 features? @djspiewak mentioned that at least CatsResource could be reworked.

armanbilge avatar Sep 09 '21 02:09 armanbilge

Yeah I think we almost need to split this away as a separate project. The problem is that version 4 is Scala 2 only, while version 5 is Scala 3 only, and they aren't source compatible so I'm pretty leery about trying to do a version switch like what is in this PR. However, going Scala 3 only is a big jump, and it probably makes sense to do that in a Specs2-specific module.

So maybe we need a specs2-cats-effect? Arguably that's a better approach anyway given the nature of this kind of interop.

Also yes, definitely, the Resource support can be made dramatically nicer if fragments are always async now!

djspiewak avatar Sep 09 '21 03:09 djspiewak

I already extracted a specs2-cats project with the matchers which were depending on cats data types: https://github.com/etorreborre/specs2-cats. Maybe I can move over the rest of the cats-effect testing support for specs2?

About resources, I added a Resource trait in specs2. It has the advantage of being able to keep resources available across several specifications executions. So you can make a trait allocating / releasing resources, inherit it in several specifications, and use the same resource whether you execute one specification or several.

etorreborre avatar Sep 09 '21 07:09 etorreborre

I already extracted a specs2-cats project with the matchers which were depending on cats data types: https://github.com/etorreborre/specs2-cats. Maybe I can move over the rest of the cats-effect testing support for specs2?

That sounds great! I didn't realize specs2-cat also includes matches for IO, in which case this sounds like the perfect home. I'd be happy to help out with this, and also add a cross-build for JS.

armanbilge avatar Sep 09 '21 11:09 armanbilge

@armanbilge fantastic, please do :-)

etorreborre avatar Sep 09 '21 11:09 etorreborre