-
Notifications
You must be signed in to change notification settings - Fork 1
Rails plugin for sending sms messages via smsapi.pl
License
mzubala/sms_sender
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
SmsSender ========= This plugin aims to provide very easy way to send an sms from your Rails app. The service used for sending sms messages is Polish http://smsapi.pl. In order to use the plugin you have to sign up at http://smsapi.pl. They give you a few free smses, so you can test how the plugin works for you without paying. Installation ============= To install the plugin, just add it in your gemfile: gem "sms_sender" Configuration ============== All you need to do is add following lines in your config/application.rb: config.sms_sender_login="your login at smsapi.pl" config.sms_sender_password="your password at smsapi.pl" config.sms_sender_eco=1 Alternatively, if you don't want to send eco smses, you comment the last line and add: #config.sms_sender_eco=1 config.sms_sender_from="5555" You may also wish to send test requests to smsapi while you develop your app. I always use it development mode. Just add in config/development.rb: config.sms_sender_test=1 With this the plugin will send requests to smsapi, but you will not be charged and people will not get any messages. Usage ===== The plugin adds a method: send_sms(telephone, text) This method is available in all your controllers. When sth goes wrong it will raise SmsApiError, so it's wise to write: begin send_sms("666", "hello world") rescue SmsApiError => e logger.error "Sms api failed with error #{e.error_code}" .... other error handling code end Testing ======= When you run your tests the plugin does not send any requests to smsapi. Instead it uses a fake implementation of sender and gives you two extra assertions. In your tests you may write: assert_sms_sent "6666", "hello world" This will be passed if somewhere in your code there was a call send_sms "6666", "hellow world" Be careful though, assert_sms_sent will be passed once only. If you call it twice without a proper call to send_sms, it will fail. On the other hand you may want to check: assert_no_sms_sent That will be passed iff there was no calls to send_sms. Both assertions are added to Test::Unit::Assertions. They work in test/unit tests, as well as in RSpec and Cucumber. ====== Copyright (c) 2011 RocketMind Software, released under the MIT license.
About
Rails plugin for sending sms messages via smsapi.pl
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published