Skip to content

Instantly share code, notes, and snippets.

@citrus
Created September 9, 2014 22:13
Show Gist options
  • Save citrus/cf08110c8519beecaf1a to your computer and use it in GitHub Desktop.
Save citrus/cf08110c8519beecaf1a to your computer and use it in GitHub Desktop.
RSpec helper for testing Twilio sms deliveries
module TwilioHelper
module TwilioMocker
def deliveries
@deliveries ||= []
end
def create(options)
deliveries << options
end
end
def self.included(base)
Twilio::REST::Messages.send(:include, TwilioMocker)
RSpec.configure do |config|
config.after(:each) do
TWILIO.account.messages.instance_variable_set("@deliveries", [])
end
end
end
def expect_sms_delivery(&block)
expect(block).to change(TWILIO.account.messages.deliveries, :length).by(1)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment