Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
prpetten opened this issue Feb 9, 2024 · 1 comment

Comments

@prpetten
Copy link

prpetten commented Feb 9, 2024

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
@michaelherold
Copy link
Owner

I'm open to the idea! Happy to accept a PR.

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

No branches or pull requests

2 participants