Project

sms_sender

0.0
No commit activity in last 3 years
No release in over 3 years
Sends sms messages using http://smsapi.pl
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme
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.