Skip to content

Support for shoulda-matcher style rspec matcher for testing interactors with contracts #39

@prpetten

Description

@prpetten

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions