sms_box 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 91354a659de5fdd4d98e73dbc1694bd6c6d6794a
4
+ data.tar.gz: ca6ba8e8096ab84a75a4620d3dce0d0bbbe8a280
5
+ SHA512:
6
+ metadata.gz: fe56ffb54de11a8b4ab01492573998a986bfb3b16a4ee947490f7942a2cc53d92d5cb862b547c6d5b7d5fa5faae1681c242bac0799916b831e380d935dc85d15
7
+ data.tar.gz: a56137e6b2d7d4c683c977bd9d15ab302f11cb66ce593e92fbfa8bb400183f5abf1c61a1e3cabfd0d5bc3f10a6426ef0f829a1e98f035a1a0d424eac4ea4c6af
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
@@ -0,0 +1,6 @@
1
+ # CHANGELOG
2
+
3
+ ## v0.1.0 - 2013.05.01
4
+
5
+ * Generic XMLRequest and XMLResponse implementation
6
+ * Implemented WEBSEND request and response (with multiReceiver)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sms_box.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Sebastian de Castelberg
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,75 @@
1
+ # SmsBox
2
+
3
+ mnc smsBox® v6.4 -- HTTP XML API client
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'sms_box'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install sms_box
18
+
19
+ ## Usage
20
+
21
+ ### Generic Usage
22
+
23
+ Load and SMSBox
24
+
25
+ require 'sms_box'
26
+ client = SMSBox.client 'http://pro.smsbox.ch:8047/Pro/sms/xml',
27
+ {
28
+ :username => 'myuser',
29
+ :password => 'mypass'
30
+ }
31
+
32
+ Client can be configured within a block
33
+
34
+ client = SMSBox.client 'http://pro.smsbox.ch:8047/Pro/sms/xml' do |c|
35
+ c.username = 'myuser'
36
+ c.password = 'mypass'
37
+ end
38
+
39
+ To send a request, a Request object needs to be instantiated and passed
40
+ to `client.request`
41
+
42
+ request = SMSBox::WebsendRequest.new.tap do |r|
43
+ r.service = 'TEST'
44
+ r.text = 'This is a test message.'
45
+ r.receivers = [
46
+ '+41790000001',
47
+ '+41790000002',
48
+ '+41790000003',
49
+ ]
50
+ end
51
+ res = client.request request
52
+
53
+ The bang method `request!` can be used to automatically raise an
54
+ `SMSBox::RequestException` when request failed.
55
+
56
+ res = client.request! request # raises SMSBox::RequestException when response.error? == true
57
+
58
+ The status of the request can be checked on the response object
59
+
60
+ res.success?
61
+ # or
62
+ res.error?
63
+ # The error type is stored as string in res.error
64
+
65
+ ### Implemented Requests
66
+
67
+ * WEBSEND (with multiReceiver)
68
+
69
+ ## Contributing
70
+
71
+ 1. Fork it
72
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
73
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
74
+ 4. Push to the branch (`git push origin my-new-feature`)
75
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,20 @@
1
+ require "sms_box/version"
2
+ require "sms_box/response_exception"
3
+ require "sms_box/xml_request"
4
+ require "sms_box/xml_response"
5
+ require "sms_box/websend_request"
6
+ require "sms_box/websend_response"
7
+ require "sms_box/client"
8
+
9
+ module SMSBox
10
+ def self.client url, opts = {}
11
+ Client.new.tap do |client|
12
+ client.url = url
13
+ opts.each do |key, value|
14
+ m = "#{key}="
15
+ client.send(m, value) if client.respond_to?(m)
16
+ end
17
+ yield(client) if block_given?
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,34 @@
1
+ require 'sms_box/xml_request'
2
+ require 'sms_box/xml_response'
3
+
4
+ require 'rest-client'
5
+
6
+ module SMSBox
7
+ class Client
8
+
9
+ attr_accessor :url
10
+ attr_accessor :username, :password
11
+
12
+ def request!(request)
13
+ response = request(request)
14
+ if response.error?
15
+ raise ResponseException.new(response.error, response)
16
+ end
17
+ response
18
+ end
19
+
20
+ def request(request)
21
+ unless request.is_a? XMLRequest
22
+ raise "Invalid request"
23
+ end
24
+
25
+ request.username = username
26
+ request.password = password
27
+ xml = RestClient.post url, request.to_xml, :content_type => "text/xml"
28
+ response = XMLResponse.from_xml(xml)
29
+ response.request = request
30
+ response
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,12 @@
1
+ module SMSBox
2
+ class ResponseException < Exception
3
+ attr_accessor :error
4
+ attr_accessor :response
5
+
6
+ def initialize(error, response)
7
+ super(error)
8
+ self.response = response
9
+ end
10
+
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ module SMSBox
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,33 @@
1
+ require 'nokogiri'
2
+
3
+ module SMSBox
4
+ class WebsendRequest < XMLRequest
5
+ attr_accessor :username
6
+ attr_accessor :password
7
+ attr_accessor :service
8
+ attr_accessor :text
9
+ attr_accessor :receivers
10
+
11
+ def initialize
12
+ self.receivers = []
13
+ end
14
+
15
+ def command
16
+ 'WEBSEND'
17
+ end
18
+
19
+ def decorate_xml(xml)
20
+ xml.SMSBoxXMLRequest do |root|
21
+ super(root)
22
+ root.parameters do |parameters|
23
+ receivers.each do |r|
24
+ parameters.multiReceiver r
25
+ end
26
+ parameters.service service
27
+ parameters.text_ text
28
+ end
29
+ xml
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,18 @@
1
+ module SMSBox
2
+ class WebsendResponse < XMLResponse
3
+
4
+ attr_accessor :receiver_status
5
+
6
+ def initialize
7
+ super
8
+ self.receiver_status = []
9
+ end
10
+
11
+ def command_data=(command_nodeset)
12
+ super
13
+ self.receiver_status = command_nodeset.xpath('receiver').map do |receiver|
14
+ { :receiver => receiver.text, :status => receiver[:status] }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ require 'nokogiri'
2
+
3
+ module SMSBox
4
+ class XMLRequest
5
+ attr_accessor :username
6
+ attr_accessor :password
7
+
8
+ def command
9
+ raise NotImplementedError.new 'XMLRequest needs to be subclassed'
10
+ end
11
+
12
+ def decorate_xml(root)
13
+ root.username username
14
+ root.password password
15
+ root.command command
16
+ root
17
+ end
18
+
19
+ def to_xml
20
+ builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
21
+ decorate_xml(xml)
22
+ end
23
+ builder.to_xml
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,60 @@
1
+ require 'nokogiri'
2
+ require 'active_support/inflector'
3
+ require 'active_support/core_ext/object'
4
+
5
+ module SMSBox
6
+ class XMLResponse
7
+ attr_accessor :request
8
+ attr_accessor :command
9
+ attr_accessor :requestUid
10
+ attr_accessor :error
11
+ attr_accessor :command_data
12
+
13
+ def error?
14
+ error.present?
15
+ end
16
+
17
+ def success?
18
+ not error?
19
+ end
20
+
21
+ def initialize
22
+ if self.instance_of? XMLResponse
23
+ raise 'XMLResponse needs to be subclassed'
24
+ end
25
+ end
26
+
27
+ def self.from_xml(xml_string)
28
+ doc = Nokogiri::XML(xml_string)
29
+ command = doc.xpath('//SMSBoxXMLReply/command')
30
+ command_name = command.attr('name').text
31
+ res = instantize(command_name)
32
+ res.command = command_name
33
+ res.command_data = command
34
+ res.requestUid = doc.xpath('//SMSBoxXMLReply/requestUid').first.text
35
+ error = doc.xpath('//SMSBoxXMLReply/error')
36
+ unless error.empty?
37
+ res.error = error.attr('type').text
38
+ end
39
+ res
40
+ end
41
+
42
+ def self.instantize(command)
43
+ klass = nil
44
+ begin
45
+ class_name = "SMSBox::#{command.downcase.camelize}Response"
46
+ klass = class_name.camelize.constantize
47
+ rescue NameError => e
48
+ raise NotImplementedError.new("'#{command}' not implemented")
49
+ rescue Exception => e
50
+ raise "'#{command}' could not be instantiated"
51
+ end
52
+
53
+ unless klass < XMLResponse
54
+ raise "'#{command}' not a SMSBox::XMLResponse"
55
+ end
56
+ klass.new
57
+ end
58
+
59
+ end
60
+ end
@@ -0,0 +1,28 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'sms_box/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "sms_box"
8
+ gem.version = SMSBox::VERSION
9
+ gem.authors = ["Sebastian de Castelberg"]
10
+ gem.email = ["developers@screenconcept.ch"]
11
+ gem.description = %q{Ruby API client for the MNC smsBox® v6.4 -- HTTP XML API}
12
+ gem.summary = %q{smsBox® HTTP XML API ruby client}
13
+ gem.homepage = "http://github.com/screenconcept/sms_box"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency 'nokogiri'
21
+ gem.add_dependency 'rest-client'
22
+ gem.add_dependency 'activesupport'
23
+
24
+ gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency 'equivalent-xml'
26
+ gem.add_development_dependency 'pry'
27
+ gem.add_development_dependency 'awesome_print'
28
+ end
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ module SMSBox
4
+ describe WebsendRequest do
5
+ let :request do
6
+ WebsendRequest.new.tap do |r|
7
+ r.service = 'TEST'
8
+ r.text = 'This is a test message.'
9
+ r.receivers = [
10
+ '+41790000001',
11
+ '+41790000002',
12
+ '+41790000003',
13
+ ]
14
+ end
15
+ end
16
+
17
+ let :client do
18
+ ::SMSBox.client('http://smsgateway', {
19
+ :username => 'myuser',
20
+ :password => 'mypass'
21
+ })
22
+ end
23
+
24
+ before :each do
25
+ RestClient.should_receive(:post) do |url, xml, opts|
26
+ actual_request = Nokogiri.XML(xml)
27
+ expected_request = Nokogiri.XML(WEBSEND_REQUEST)
28
+ actual_request.should be_equivalent_to(expected_request)
29
+ url.should == 'http://smsgateway'
30
+ opts.should == { :content_type => "text/xml" }
31
+ end.and_return(WEBSEND_RESPONSE)
32
+ end
33
+
34
+ it 'simulates a end-to-end WEBSEND Request' do
35
+ res = client.request(request)
36
+ res
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,18 @@
1
+ require 'sms_box'
2
+ require 'equivalent-xml'
3
+ require 'nokogiri'
4
+
5
+ Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
6
+
7
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
8
+ RSpec.configure do |config|
9
+ config.treat_symbols_as_metadata_keys_with_true_values = true
10
+ config.run_all_when_everything_filtered = true
11
+ config.filter_run :focus
12
+
13
+ # Run specs in random order to surface order dependencies. If you find an
14
+ # order dependency and want to debug it, you can fix the order by providing
15
+ # the seed, which is printed after each run.
16
+ # --seed 1234
17
+ config.order = 'random'
18
+ end
@@ -0,0 +1,26 @@
1
+ module SMSBox
2
+ WEBSEND_REQUEST = '<?xml version="1.0" encoding="UTF-8" ?>
3
+ <SMSBoxXMLRequest>
4
+ <username>myuser</username>
5
+ <password>mypass</password>
6
+ <command>WEBSEND</command>
7
+ <parameters>
8
+ <multiReceiver>+41790000001</multiReceiver>
9
+ <multiReceiver>+41790000002</multiReceiver
10
+ <multiReceiver>+41790000003</multiReceiver>
11
+ <service>TEST</service>
12
+ <text>This is a test message.</text>
13
+ </parameters>
14
+ </SMSBoxXMLRequest>'
15
+
16
+ WEBSEND_RESPONSE = '<?xml version="1.0" encoding="UTF-8" ?>
17
+ <SMSBoxXMLReply>
18
+ <ok/>
19
+ <command name="WEBSEND">
20
+ <receiver status="ok">+41790000001</receiver>
21
+ <receiver status="ok">+41790000002</receiver>
22
+ <receiver status="ok">+41790000003</receiver>
23
+ </command>
24
+ <requestUid>xml9677322</requestUid>
25
+ </SMSBoxXMLReply>'
26
+ end
@@ -0,0 +1,92 @@
1
+ require 'spec_helper'
2
+
3
+ module SMSBox
4
+ class DummyResponse < XMLResponse; end
5
+
6
+ describe Client do
7
+ describe '#factory' do
8
+
9
+ context 'when block given' do
10
+ it 'can be configured with a block' do
11
+ client = SMSBox.client 'url' do |c|
12
+ c.username = 'username'
13
+ end
14
+ client.username.should == 'username'
15
+ end
16
+ end
17
+
18
+ context 'when options given' do
19
+ it 'can be configured with a hash' do
20
+ client = SMSBox.client 'url', { username: 'username' }
21
+ client.username.should == 'username'
22
+ end
23
+ end
24
+ end
25
+
26
+ describe '#request' do
27
+ let :client do
28
+ SMSBox.client 'url'
29
+ end
30
+
31
+ context 'with invalid parameter' do
32
+ it 'raises exception' do
33
+ expect{ client.request 'foo' }.to raise_error(/Invalid request/)
34
+ end
35
+ end
36
+
37
+ context 'with valid request' do
38
+ before :each do
39
+ RestClient.should_receive(:post).with(
40
+ 'url',
41
+ request.to_xml,
42
+ :content_type => "text/xml"
43
+ ).and_return('response')
44
+ XMLResponse.should_receive(:from_xml).
45
+ with('response').
46
+ and_return(DummyResponse.new)
47
+ end
48
+
49
+ let :request do
50
+ WebsendRequest.new
51
+ end
52
+
53
+ let :response do
54
+ client.request(request)
55
+ end
56
+
57
+ it 'returns a XMLResponse object' do
58
+ response.should be_a(XMLResponse)
59
+ end
60
+
61
+ it 'contains a reference to the request in response' do
62
+ response.request.should be(request)
63
+ end
64
+ end
65
+ end
66
+
67
+ describe '#request!' do
68
+ let :client do
69
+ SMSBox.client 'url'
70
+ end
71
+
72
+ context 'when request succeeded' do
73
+ it 'returns response' do
74
+ response = WebsendResponse.new
75
+ client.should_receive(:request).and_return(response)
76
+ client.request!(WebsendRequest.new).should be response
77
+ end
78
+ end
79
+
80
+ context 'when request failed' do
81
+ it 'raises ResponseException' do
82
+ response = WebsendResponse.new.tap do |res|
83
+ res.error = 'My Error'
84
+ end
85
+ client.should_receive(:request).and_return(response)
86
+ expect { client.request!(WebsendRequest.new) }.to raise_error(ResponseException, /My Error/)
87
+ end
88
+ end
89
+ end
90
+ end
91
+ end
92
+
@@ -0,0 +1,58 @@
1
+ require 'spec_helper'
2
+
3
+ REQUEST = '<?xml version="1.0" encoding="UTF-8" ?>
4
+ <SMSBoxXMLRequest>
5
+ <username>USERNAME</username>
6
+ <password>PASSWORD</password>
7
+ <command>WEBSEND</command>
8
+ <parameters>
9
+ <multiReceiver>234234234</multiReceiver>
10
+ <multiReceiver>123123123</multiReceiver>
11
+ <service>SERVICE</service>
12
+ <text>TEXT</text>
13
+ </parameters>
14
+ </SMSBoxXMLRequest>'
15
+
16
+ module SMSBox
17
+
18
+ describe WebsendRequest do
19
+ describe '#initialize' do
20
+ let :request do
21
+ WebsendRequest.new.tap do |r|
22
+ r.username = 'USERNAME'
23
+ r.password = 'PASSWORD'
24
+ r.service = 'SERVICE'
25
+ r.text = 'TEXT'
26
+ r.receivers = []
27
+ end
28
+ end
29
+
30
+ it 'initializes the object' do
31
+ request.username.should == 'USERNAME'
32
+ request.password.should == 'PASSWORD'
33
+ request.service.should == 'SERVICE'
34
+ request.text.should == 'TEXT'
35
+ request.receivers.should == []
36
+ end
37
+ end
38
+
39
+ describe '#to_xml' do
40
+ let :request do
41
+ WebsendRequest.new.tap do |r|
42
+ r.username = 'USERNAME'
43
+ r.password = 'PASSWORD'
44
+ r.service = 'SERVICE'
45
+ r.text = 'TEXT'
46
+ r.receivers = ['234234234', '123123123']
47
+ end
48
+ end
49
+
50
+ it 'renders xml' do
51
+ actual_request = Nokogiri.XML(request.to_xml)
52
+ expected_request = Nokogiri.XML(REQUEST)
53
+ actual_request.should be_equivalent_to(expected_request)
54
+ end
55
+ end
56
+ end
57
+
58
+ end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ module SMSBox
4
+ describe WebsendResponse do
5
+
6
+ describe '#command_data=' do
7
+ let :response do
8
+ doc = Nokogiri::XML(WEBSEND_RESPONSE)
9
+ WebsendResponse.new.tap do |res|
10
+ res.command_data = doc.xpath('//SMSBoxXMLReply/command')
11
+ end
12
+ end
13
+
14
+ it 'stores the receiver status hash' do
15
+ response.receiver_status.should == [
16
+ { :receiver => '+41790000001', :status => 'ok' },
17
+ { :receiver => '+41790000002', :status => 'ok' },
18
+ { :receiver => '+41790000003', :status => 'ok' }
19
+ ]
20
+ end
21
+ end
22
+
23
+ end
24
+ end
@@ -0,0 +1,86 @@
1
+ require 'spec_helper'
2
+
3
+ DUMMY_RESPONSE_OK = '<?xml version="1.0" encoding="UTF-8" ?>
4
+ <SMSBoxXMLReply>
5
+ <ok/>
6
+ <command name="DUMMY"></command>
7
+ <requestUid>xml9677322</requestUid>
8
+ </SMSBoxXMLReply>'
9
+
10
+ DUMMY_RESPONSE_ERROR = '<?xml version="1.0" encoding="UTF-8" ?>
11
+ <SMSBoxXMLReply>
12
+ <error type="ERROR_TYPE"/>
13
+ <command name="DUMMY"></command>
14
+ <requestUid>xml9677322</requestUid>
15
+ </SMSBoxXMLReply>'
16
+
17
+ module SMSBox
18
+ class BrokenResponse; end
19
+ class DummyResponse < XMLResponse; end
20
+
21
+ describe XMLResponse do
22
+ describe '#initialize' do
23
+ it 'raises exception when initializing base class' do
24
+ expect{ XMLResponse.new }.to raise_error(/XMLResponse needs to be subclassed/)
25
+ end
26
+ end
27
+
28
+ describe '#from_xml' do
29
+ it 'sets the requestUid' do
30
+ XMLResponse.from_xml(DUMMY_RESPONSE_OK).requestUid.should == 'xml9677322'
31
+ end
32
+
33
+ context 'on success' do
34
+ it 'success? returns true' do
35
+ XMLResponse.from_xml(DUMMY_RESPONSE_OK).success?.should be_true
36
+ end
37
+ end
38
+
39
+ context 'on error' do
40
+ it 'error? returns true' do
41
+ XMLResponse.from_xml(DUMMY_RESPONSE_ERROR).error?.should be_true
42
+ end
43
+
44
+ it 'error returns the error type' do
45
+ XMLResponse.from_xml(DUMMY_RESPONSE_ERROR).error.should == 'ERROR_TYPE'
46
+ end
47
+ end
48
+
49
+ context 'with response class specific data' do
50
+ it 'calls command_data= with payload' do
51
+ XMLResponse.from_xml(DUMMY_RESPONSE_OK).command_data.should be_a Nokogiri::XML::NodeSet
52
+ end
53
+ end
54
+ end
55
+
56
+ describe '#instantize' do
57
+ context 'with invalid class name' do
58
+ it 'raises exception' do
59
+ expect{ XMLResponse.instantize(nil) }.to raise_error(
60
+ NotImplementedError, /not implemented/
61
+ )
62
+ expect{ XMLResponse.instantize('') }.to raise_error(
63
+ NotImplementedError, /not implemented/
64
+ )
65
+ expect{ XMLResponse.instantize('foo bar') }.to raise_error(
66
+ NotImplementedError, /not implemented/
67
+ )
68
+ end
69
+ end
70
+
71
+ context 'when class is not subclass of XMLResponse' do
72
+ it 'raises exception' do
73
+ expect{ XMLResponse.instantize('BROKEN') }.to raise_error(
74
+ /not a SMSBox::XMLResponse/
75
+ )
76
+ end
77
+ end
78
+
79
+ context 'with valid command' do
80
+ it 'instantiates and returns response' do
81
+ XMLResponse.instantize('DUMMY').should be_a(DummyResponse)
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sms_box
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Sebastian de Castelberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: equivalent-xml
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: awesome_print
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Ruby API client for the MNC smsBox® v6.4 -- HTTP XML API
112
+ email:
113
+ - developers@screenconcept.ch
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .rspec
120
+ - CHANGELOG.md
121
+ - Gemfile
122
+ - LICENSE.txt
123
+ - README.md
124
+ - Rakefile
125
+ - lib/sms_box.rb
126
+ - lib/sms_box/client.rb
127
+ - lib/sms_box/response_exception.rb
128
+ - lib/sms_box/version.rb
129
+ - lib/sms_box/websend_request.rb
130
+ - lib/sms_box/websend_response.rb
131
+ - lib/sms_box/xml_request.rb
132
+ - lib/sms_box/xml_response.rb
133
+ - sms_box.gemspec
134
+ - spec/integration/sms_box/websend_request_spec.rb
135
+ - spec/spec_helper.rb
136
+ - spec/support/sms_box/fixtures.rb
137
+ - spec/unit/sms_box/client_spec.rb
138
+ - spec/unit/sms_box/websend_request_spec.rb
139
+ - spec/unit/sms_box/websend_response_spec.rb
140
+ - spec/unit/sms_box/xml_response_spec.rb
141
+ homepage: http://github.com/screenconcept/sms_box
142
+ licenses: []
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.0.3
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: smsBox® HTTP XML API ruby client
164
+ test_files:
165
+ - spec/integration/sms_box/websend_request_spec.rb
166
+ - spec/spec_helper.rb
167
+ - spec/support/sms_box/fixtures.rb
168
+ - spec/unit/sms_box/client_spec.rb
169
+ - spec/unit/sms_box/websend_request_spec.rb
170
+ - spec/unit/sms_box/websend_response_spec.rb
171
+ - spec/unit/sms_box/xml_response_spec.rb