Skip to content

Instantly share code, notes, and snippets.

@ahmad19
Last active August 3, 2022 14:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmad19/cb9ee0f859499d7a00bafd8a4e0309dc to your computer and use it in GitHub Desktop.
Save ahmad19/cb9ee0f859499d7a00bafd8a4e0309dc to your computer and use it in GitHub Desktop.
RSpec matchers cheatsheet
# To match only few attributes of an object
# have_attributes
expect(person).to have_attributes(:name => "Jim", :age => 32)
# To match attributes of a collection
expect(notes)
.to match_array([
have_attributes(
notable_id: talent.id,
title: 'resume.pdf'
),
have_attributes(
notable_id: talent.id,
title: 'company_prospects.xlsx'
)
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment