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

Allow matchers in expected value in with_data chain #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

wildfiler
Copy link

What is the current behavior?

In have_relationship.with_data you can pass only actual values, it doesn't work with other matches.

What is the new behavior?

Add support for matches to have_relationship.with_data to allow write more customizable expectations, like expecting all records to have some type, or expecting to have record with some id, ignoring others:

doc = {
  'relationships' => {
    'comments' => {
      'data' => [
        { 'id' => '1', 'type' => 'comment' },
        { 'id' => '2', 'type' => 'comment' }
      ]
    }
  }
}

expect(doc).to have_relationship('comments').with_data(all(have_type('comment')))
expect(doc).to have_relationship('comments').with_data(include(have_id('1')))

Checklist

Please make sure the following requirements are complete:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been reviewed and added / updated if needed (for bug fixes /
    features)
  • All automated checks pass (CI/CD)

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

Successfully merging this pull request may close these issues.

1 participant