From aac23ea596a31c17b5dc6ea4c81ed5b12c14d58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Thu, 24 Oct 2019 19:24:22 +0200 Subject: [PATCH] Use a block to travel in time in specs If we don't use a block, if the spec fails the `travel_back` method isn't executed. --- spec/features/proposal_notifications_spec.rb | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/spec/features/proposal_notifications_spec.rb b/spec/features/proposal_notifications_spec.rb index 33b6bfac1..d2a25c1f6 100644 --- a/spec/features/proposal_notifications_spec.rb +++ b/spec/features/proposal_notifications_spec.rb @@ -420,17 +420,15 @@ describe "Proposal Notifications" do expect(page).to have_content "Your message has been sent correctly." - travel 3.days + 1.second + travel(3.days + 1.second) do + visit new_proposal_notification_path(proposal_id: proposal.id) + fill_in "Title", with: "Thank you again for supporting my proposal" + fill_in "Message", with: "Please share it again with others so we can make it happen!" + click_button "Send message" - visit new_proposal_notification_path(proposal_id: proposal.id) - fill_in "Title", with: "Thank you again for supporting my proposal" - fill_in "Message", with: "Please share it again with others so we can make it happen!" - click_button "Send message" - - expect(page).to have_content "Your message has been sent correctly." - expect(page).not_to have_content "You have to wait a minimum of 3 days between notifications" - - travel_back + expect(page).to have_content "Your message has been sent correctly." + expect(page).not_to have_content "You have to wait a minimum of 3 days between notifications" + end end end end