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

Refactor IOMatchers to add Generic #707

Merged
merged 1 commit into from Sep 14, 2018
Merged

Refactor IOMatchers to add Generic #707

merged 1 commit into from Sep 14, 2018

Conversation

diesalbla
Copy link
Contributor

Description of changes

We split the IOMatchers trait to make it independent from IO.

  • We extract a generic RuntimedMatchers trait, which is generic on the effect type F[_], and has most methods from IOMatchers.
  • The generic RuntimedMatchers defines two methods, that act as placeholders for IO.timeout and IO.unsafeRunSync.
  • To the RunTimedMatchers trait, we add an inner TimedMatcher class, that has most of the logic from the IOMatcher class. This class has methods, akin to checkIOWithDuration and checkIO, but with different names.

Having moved most of the logic to RuntimedMatchers, the IOMatcher becomes just a specific instance of RunTimedMatchers[IO], and the two methods just call the IO methods.

  • We keep an IOMatcher inner class inside IOMatchers, for compatibility. This class keeps the two checkIOWithDuration and checkIO methods above.

Related tickets

  • This changes were first proposed in a Pull Request to http4s, which contains a copy of IOMatchers.
  • A proposal to generalise some methods of cats.effect.IO was made and discussed in this issue. Nevertheless, since no appropriate type-class at present, declaring abstract methods in RuntimedMatchers is the next best.

We split the IOMatchers trait to make it independent from IO.
- We extract a generic `RuntimedMatchers` trait, which is generic on
  the effect type `F[_]`, and has most methods from `IOMatchers`.
- The generic `RuntimedMatchers` defines two methods, that act as
  placeholders for `IO.timeout` and `IO.unsafeRunSync`.
- To the `RunTimedMatchers` trait, we add an inner `TimedMatcher`
  class, that has most of the logic from the `IOMatcher` class.
  This class has methods, akin to `checkIOWithDuration` and
  `checkIO`, but with different names.

Having moved most of the logic to `RuntimedMatchers`, the `IOMatcher`
becomes just a specific instance of `RunTimedMatchers[IO]`, and the
two methods just call the IO methods.

- We keep an `IOMatcher` inner class inside `IOMatchers`, for
  compatibility. This class keeps the two `check` methods above.
@etorreborre
Copy link
Owner

This makes sense, thanks.

@etorreborre etorreborre merged commit 2df4728 into etorreborre:master Sep 14, 2018
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