Code Monkey home page Code Monkey logo

smsmock's Introduction

SmsMock

Adds twilio-ruby RSpec tests for testing SMS interactions.

##Setup Add the smsmock gem to your Gemfile:

group :test do
  gem 'smsmock'
end

RSpec

In your spec_helper.rb file require the smsmocker.

require 'smsmock'

Example

require 'spec_helper'

describe SmsMock do

  before :each do
    @client = Twilio::REST::Client.new('','')
  end

  it 'add a message to SmsMock::Client' do
    @client.messages.create(to: '123981', body: 'abc123', from: '1291')
    expect(SmsMock::Client).to have_sent_messages
    expect(SmsMock::Client.messages.last).to have_body 'abc123'
    expect(SmsMock::Client.messages.last).to be_sent_from '1291'
    expect(SmsMock::Client.messages.last).to be_sent_to '123981'
  end
end

The following matchers can be used:

  # for SmsMock::Client
  expect(SmsMock::Client).to have_sent_messages
  expect(SmsMock::Client).to have_sent_messages 2
  expect(SmsMock::Client).to have_sent_message_to '123456'
  expect(SmsMock::Client).to have_sent_message_from '123456'
  expect(SmsMock::Client).to have_sent_message_with_body 'abc123'

  # with chaining:
  expect(SmsMock::Client).to have_sent_message_to('123456').and from('654321').and with_body('abc123')

  # for individual messages
  expect(SmsMock::Client.messages.last).to have_body 'abc123'
  expect(SmsMock::Client.messages.last).to be_sent_from '1291'
  expect(SmsMock::Client.messages.last).to be_sent_to '123981'

  # with chaining:
  expect(SmsMock::Client.messages.last).to be_sent_to('123456').and from('654321').and with_body('abc123')

smsmock's People

Contributors

scarhand avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.