RSpec have_attributes

atribute のチェックは have_attributes で簡潔に記述できる。

# BAD
it 'has correct attributes' do
  expect(user.name).to eq 'john'
  expect(user.age).to eq 20
  expect(user.email).to eq 'john@ruby.com'
  expect(user.gender).to eq 'male'
  expect(user.country).to eq 'us'
end

# GOOD
it 'has correct attributes' do
  expect(user).to have_attributes(
    name: 'john',
    age: 20,
    email: 'john@ruby.com',
    gender: 'male',
    country: 'us',
  )
end
[9 tips to improve RSpec maintainability by Duong Nguyen The Startup Jun, 2020 Medium](https://medium.com/swlh/9-tips-to-write-better-rspec-5569b45fb1a1)