Day 23

Testing time-specific notifications

Ryan Strickler
Dec 22, 2016 · 3 min read

Worked on testing notifications for Prompt today. The main idea with this application is to deliver writing prompts in time for a specific window, in order to create a daily writing habit. Notifications working well and occurring at the appropriate times is a pretty important part of that. Maybe the most important part. So I need to get this right.

I started by writing out the basic idea of what I want to test:

For simplicity’s sake, I’m assuming that everyone has their prompt delivery time set to 6am. This is a long integration test that will do many things in succession and verify that nothing breaks.

To start, I create the user records and key times that are important:

Nothing too exciting here. Using fixtures for the user records and creating some times at 6am both today and tomorrow.

I’m updating the user records with the next time that a prompt will be sent for this user. I started off with the idea of tracking the last time that a prompt was sent, but this seems like it will work better because a user might update the time they want their prompts to be sent and it will be difficult derive that from the previous sent time in that case. This also makes it very easy to query the users who are ready to go.

I’m also checking that there are some test prompts set up to work with, in case the fixture data is changed some time in the future.

The most interesting part is checking the code at a certain time. I’m using Rails’ built-in travel_to function for this:

This sets the time to 5am on the current day, which is too early for our prompts to be sent. I’m planning on sending no earlier than 10 minutes before. So we “move” the time and check to see that no prompts are sent when the sending function is called.

This is as far as I got today, but once I get this part of the test passing, I’ll follow a similar pattern with the other times of interest and that should flesh out the time-sensitive sending portion of the app.


Excited to get this knocked out and get version one out soon. Not much time left before I need to ship!

Little King: Daily Log

Building something every day.

Ryan Strickler

Written by

Building something every day. Launching something new every 6 weeks. Writing about everything along the way.

Little King: Daily Log

Building something every day. Launching something new every 7 weeks. Writing about everything along the way.

Ryan Strickler

Written by

Building something every day. Launching something new every 6 weeks. Writing about everything along the way.

Little King: Daily Log

Building something every day. Launching something new every 7 weeks. Writing about everything along the way.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store