dry-rb / dry-transaction

Business transaction DSL
http://dry-rb.org/gems/dry-transaction
MIT License
468 stars 55 forks source link

Add test interface #98

Closed GustavoCaso closed 6 years ago

GustavoCaso commented 6 years ago

75

This adds a test interface that allows for injected operations to fully replace local defined operations and container base operations.

The idea behind this is that for testing porpuses is to be able to fully replace operations with injected ones, avoiding unwanted behavior in our tests.

My first idea was to add a class method to the transaction something like Transaction.enable_injection! but since the returning class after creating a transaction class is an anonymous class make it harder to add methods. I decided to use a wrapping module that injects this functionality by overwriting the resolve_operation method from the InstanceMethods module. I think is a good start for improving the library and help user test their transaction classes.

@timriley WDYT?

timriley commented 6 years ago

Resolved in #109. Internal operations can now be replaced via constructor DI just like external operations, no special modes required.