Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@vladimirkl
Copy link
Contributor

@vladimirkl vladimirkl commented Mar 24, 2021

This PR adds support for adding aspects to top level suite in MutableRunnableSpec, which is always created automatically.
Alternate approach could be supplying aspects via additional constructor parameter, but this prevents us for using same object methods in aspects like before, after or others. And topSuite @ aspect1 @ aspect2... reads better.

@vladimirkl vladimirkl force-pushed the mutable-spec-aspects branch from 4e9a82e to 9493e56 Compare March 25, 2021 08:38
@fokot
Copy link
Contributor

fokot commented Mar 25, 2021

Interesting approach.
Also another approach would be to add it after the Spec

object MutableRunnableSpecSpec extends MutableRunnableSpec(Ref.make(0).toLayer) {
  ...
} @@ sequential @@ before(ZIO.service[Ref[Int]].flatMap(_.update(_ + 1)))

topSuite looks better to me than this or aspects in constructor.

@jdegoes
Copy link
Member

jdegoes commented Mar 29, 2021

I think the most discoverable option might be a constructor parameter, e.g.:

... extends MutableRunnableSpec(myLayer, myAspects) { 
}

Ping @adamgfraser

@vladimirkl
Copy link
Contributor Author

Constructor parameters have limitation - cannot use methods from same spec object. They are useful for complex aspects like before or after

@adamgfraser
Copy link
Contributor

I'm inclined to think the constructor argument is the way to go as well. Seems more discoverable and you could always factor out the definition of the aspects and any common functionality you wanted to reference into another object.

@vladimirkl vladimirkl force-pushed the mutable-spec-aspects branch 5 times, most recently from 8abbe0e to db0688c Compare March 31, 2021 15:51
@vladimirkl
Copy link
Contributor Author

@adamgfraser I updated PR to use constructor argument

adamgfraser
adamgfraser previously approved these changes Apr 2, 2021
Copy link
Contributor

@adamgfraser adamgfraser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@adamgfraser
Copy link
Contributor

Can you merge upstream changes so the new CI triggers?

@vladimirkl
Copy link
Contributor Author

@adamgfraser Done

@adamgfraser adamgfraser merged commit fdfcd74 into zio:master Apr 2, 2021
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.

4 participants