twiliocapybaraminitestauthy

Possible to get the content of sms message (including verification code) sent by authy in a test?


I have an app that sends an SMS with a verification code to users during signup.

I send it by doing the following:

Authy::API.request_sms(:id => user.authy_id)

I was wondering if it is possible to see the exact content of this SMS (along with the verification code) during my testing, so that I could just directly put the code into the input field when I run my capybara signup test.


Solution

  • Twilio developer evangelist here.

    We are dealing with this query over on GitHub here, but I thought I would add my answer here in case it helps others.

    Unfortunately the API does not expose the code or the text of the message sent to the user.

    However, I wouldn't recommend testing third party services, even as part of your end to end testing. Given the reliance on a network in order to call the API, that you'd be testing a third party library (this one) and the fact that this would trigger an SMS in real life, it doesn't lend itself to good tests.

    Instead I would mock the API response for both the sending and verifying part of the test.