Project

sms-spec

0.03
No commit activity in last 3 years
No release in over 3 years
There's a lot of open issues
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 Spec

Build Status Code Climate

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-spec gem to Gemfile:

group :test do
  gem "sms-spec"
end

RSpec

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

require "sms_spec"

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

SmsSpec.driver = :"twilio-ruby" #this can be any available sms-spec 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_spec"
require "sms_spec/cucumber"

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

rails generate sms_spec: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