Rspec comparing two fields to a single value

expect(t.target_owner_id || t.creator_id).to eq user.id

Any idea how to do this with rspec?

My solution:
expect(t.target_owner_id == user.id || t.creator_id == user.id).to eq true

Similar, bit more readable but extra parentheses are ugly:

expect(user.id == (t.target_owner_id || t.creator_id)).to eq true

expect([t.target_owner_id , t.creator_id]).to include user.id

1 Like

Thanks Dan!