interactor-contracts
interactor-contracts copied to clipboard
Support for shoulda-matcher style rspec matcher for testing interactors with contracts
Rather than add a bunch of boilerplate tests for contract breaches, I was wondering if there was something similar to the shoulda-matchers
. https://github.com/thoughtbot/shoulda-matchers/tree/main
So for
class MyInteractor
include Interactor
include Interactor::Contracts
expects do
required(:argument1).filled
required(:argument2).filled
end
def call
#does stuff
end
end
We could have a spec
describe MyInteractor do
describe 'validations' do
it { should validate_presence_of(:argument1) }
it { should validate_presence_of(:argument2) }
end
end
I'm open to the idea! Happy to accept a PR.