Skip to content

Conversation

@NateBarnes
Copy link
Member

@NateBarnes NateBarnes commented Apr 8, 2020

Ok, here's v2 of the work to improve the testability of handlers. This extracts the Outbound functions of the chat backend into a behaviour, then implements that behavior into a SlackOutbound module. This allows us to create a Spy of this Behaviour to capture outbound replies. I've updated the internal tests of the handler helpers, and then added a few tests for some of the internal handlers to reflect the new style. I've also created some macros to make it easier for people to implement the most common flows in by using Alice.Handlers.Case.

I also updated alice_roller in a separate branch so you can see what tests look like in a third party handler as well: https://github.com/NateBarnes/alice_roller/blob/testing-refactor/test/alice/handlers/roller_test.exs

I believe this should resolve #47 . Let me know what y'all think though

@NateBarnes NateBarnes marked this pull request as draft April 10, 2020 19:28
@NateBarnes NateBarnes marked this pull request as ready for review April 11, 2020 01:46
Copy link
Member

@adamzaninovich adamzaninovich left a comment

Choose a reason for hiding this comment

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

I love how this turned out! Can't wait to use it to actually test all these handlers with zero coverage!

Here are a few things I saw.

Copy link
Member

@adamzaninovich adamzaninovich left a comment

Choose a reason for hiding this comment

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

You might want to run the formatter, but other than that it looks good to me.

@NateBarnes
Copy link
Member Author

Ok, formatter has been run, ran credo while I was at it, and wrote a bunch of documentation for the new modules and methods.

Copy link
Member

@adamzaninovich adamzaninovich left a comment

Choose a reason for hiding this comment

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

Looks great!

@adamzaninovich adamzaninovich merged commit 967c7e2 into alice-bot:master Apr 11, 2020
@NateBarnes NateBarnes deleted the testing-handlers branch April 11, 2020 17:52
@tielur
Copy link
Member

tielur commented Apr 13, 2020

❤️

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.

Make it easier to test handlers

3 participants