0.0
No commit activity in last 3 years
No release in over 3 years
SMS Spec gives you an RSpec DSL and Cucumber steps to test SMS interactions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

~> 3.1
 Project Readme

sms-unit-test

Build Status

This is a hard maintained fork of the sporadically maintained sms-spec. Unlike that gem, I hope to provide it a home with maintenance releases as necessary.

PRs are welcome, as are additional maintainers.

An RSpec DSL and Cucumber steps to test SMS interactions with your Ruby on Rails application.

Currently this gem only supports testing SMS messaging using the twilio-ruby and lookout-clickatell gem.

Setup

Add the sms-unit-test gem to Gemfile:

group :test do
  gem "sms-unit-test"
end

RSpec

Configure a driver and include helper and matcher methods in the spec_helper.rb:

require "sms_unit_test"

Spec::Runner.configure do |config|
  config.include(SmsUnitTest::Helpers)
  config.include(SmsUnitTest::Matchers)
end

SmsUnitTest.driver = :"twilio-ruby" #this can be any available sms-unit-test driver

Usage

describe "alarm notifications" do
  subject(:job) { AlarmNotificationJob.new }

  context "via sms" do
    let!(:subscription) { FactoryGirl.create :alarm_subscription_sms }

    it "delivers an alarm notification" do
      job.perform

      open_last_text_message_for(subscription.recipient)
      expect(current_text_message.body).to eq("Yo")
    end
  end
end

Cucumber

Add the following to env.rb:

require "sms_unit_test"
require "sms_unit_test/cucumber"

This loads the sms_unit_test RSpec helpers into your cucumber wold. Then, run the following to generate the text_messsage_steps.rb file:

rails generate sms_unit_test:steps

Usage

Feature: Registering via SMS

  In order to use our application
  As a user
  I want to be able to register with any mobile phone

  Scenario: A user submits their phone number for registration
    Given I am on the homepage
    And I fill in "What is your phone number?" with "6165552345"
    When I press "Register"

    Then I should see "Thank You"
    And "6165552345" opens the text message
    And I should see "Thank you for registering. To confirm your subscript reply YES." in the text message body