In the test for User#todos, the original code is:
it 'returns todos whose owner_email is the email instantiated with' do
create(:todo, description: 'Buy some eggs', owner_email: 'person@example.com')
create(:todo, description: 'Buy some milk', owner_email: 'other_person@example.com')
user = User.new('person@example.com')
expect(user.todos.length).to eq 1
expect(user.todos.first.description).to eq 'Buy some eggs'
end
Can I rewrite to code to:
person_todo = create(:todo, description: 'Buy some eggs', owner_email: 'person@example.com')
......
expect(user.todos).to eq [person_todo]
It seems more straightforward to me and it can pass the test. Or, am I overlooking something important?