Skip to content

Validate chains of contracts within organizers #34

@michaelherold

Description

@michaelherold

My original vision for this gem was to build a way to validate that the the interactors that you compose with organizers form a valid chain of business logic. When I used interactors, I would end up writing a ton of integration tests to make sure the chain of logic all fit together and to protect against regressions.

I thought it would be cool to do something like this:

class PlaceOrder
  include Interactor::Organizer
  include Interactor::Contracts

  expects do
    required(:card).filled # used in step 2 but not step 1
  end

  promises do
    required(:order).filled
  end

  organize CreateOrder, ChargeCard, SendThankYou
end

# then, in a test support file
Interactor::Contracts.validate_organizers!

The validate_organizers! method would act like FactoryBot's linting capabilities. We could make it part of the test suite or we could make a Rake task out of it. Whatever feels like the best experience.

The idea is that, given the list of interactors passed to organize, we could compare the promises and expectations of the organized interactors plus the contracts of the organizer itself to check whether it's a valid organizer.

I'm happy to mentor anyone willing to take this on. I do not currently use interactors in my work, hence why I haven't implemented this myself. But for people who use the Interactor gem, I think this would be a major benefit.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions