Today I Learned

Extract explaining variable by example

travel_to(Time.utc(2019, 1, 1)) do
 expect { form.save }.to change { CourtesyHoldDatesRange.count }.from(0).to(2)
 expect(CourtesyHoldDatesRange.all).to include(
   have_attributes(pms_room_id: 'parent-1', group_uid: 1546300800), # what the hell is that?
   have_attributes(pms_room_id: 'child-1', group_uid: 1546300800)
 )
end

vs

travel_to(Time.utc(2019, 1, 1)) do
 timestamp_at_2019_01_01 = 1546300800
 expect { form.save }.to change { CourtesyHoldDatesRange.count }.from(0).to(2)
 expect(CourtesyHoldDatesRange.all).to include(
   have_attributes(pms_room_id: 'parent-1', group_uid: timestamp_at_2019_01_01),
   have_attributes(pms_room_id: 'child-1', group_uid: timestamp_at_2019_01_01)
 )
end