Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a block to travel in time in specs #3797

Merged
merged 1 commit into from
Oct 24, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
  • Loading branch information
javierm committed Oct 24, 2019
commit aac23ea596a31c17b5dc6ea4c81ed5b12c14d58a
20 changes: 9 additions & 11 deletions spec/features/proposal_notifications_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,17 +420,15 @@

expect(page).to have_content "Your message has been sent correctly."

travel 3.days + 1.second

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
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"

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