Videos
Check out our tutorial video series.
Test Your User Sign-Up and Verification Process Automatically using Real Email Addresses with Ruby and MailSlurp API.
Ruby on Rails makes building and testing applications a breeze. But when it comes to user sign-up and email verification how do we test it? We can mock the email steps in tests or test it manually with our personal addresses but wouldn't it be better if we could test automatically with real email addresses? Imagine if we could smoke test this aspect of our app so that we know for sure that essential email related processes are behaving as we expect them to.
Luckily test email account services like MailSlurp provide an easy way to create real email addresses on demand during tests. We can use this email address to sign up a new user. We can then get the last email they received and extract a verification code from it. Lastly we can use that real verification code to verify the user. All in all MailSlurp can help us test the full user sign up process end-to-end using real email addresses.
Let's look at a real-world Ruby on Rails example. MailSlurp has an official Ruby client on RubyGems. We can add this to our Gemfile like so:
Let's imagine a ROR app with a user controller that lets users sign up with an email address. Before the user can take actions they must also verify their account. Many apps do this, typically by sending the new user a verification code that they must submit to the app before they can proceed as a full user. Let's imagine an app that behaves this way and how we might test it.
In our user sign up integration test we might do the following:
Here's what a Rails test might look like using RSpec
Unit tests are great but to determine if your app is truly functioning you need integration tests. Testing user sign up is usually tricky but with MailSlurp you can create unlimited private email address to send and receive real emails with. Check out mailslurp.com/developers/ for more information.
Check out our tutorial video series.
Email and SMS guides for automation and testing.
View github project code for multiple languages.
Latest posts from the MailSlurp team.
Test, build, and automate messaging with a free MailSlurp account.