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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user