Created
September 9, 2014 22:13
-
-
Save citrus/cf08110c8519beecaf1a to your computer and use it in GitHub Desktop.
RSpec helper for testing Twilio sms deliveries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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