nexmo 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/nexmo.rb +1 -1
- data/nexmo.gemspec +1 -1
- data/spec/nexmo_spec.rb +33 -10
- metadata +6 -6
data/lib/nexmo.rb
CHANGED
data/nexmo.gemspec
CHANGED
data/spec/nexmo_spec.rb
CHANGED
@@ -8,27 +8,50 @@ describe Nexmo::Client do
|
|
8
8
|
@client = Nexmo::Client.new('key', 'secret')
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
describe 'http method' do
|
12
|
+
it 'should return a Net::HTTP object that uses SSL' do
|
13
|
+
@client.http.must_be_instance_of(Net::HTTP)
|
14
|
+
@client.http.use_ssl?.must_equal(true)
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
|
-
|
16
|
-
|
18
|
+
describe 'headers method' do
|
19
|
+
it 'should return a hash' do
|
20
|
+
@client.headers.must_be_kind_of(Hash)
|
21
|
+
end
|
17
22
|
end
|
18
23
|
|
19
|
-
describe '
|
20
|
-
|
24
|
+
describe 'send_message method' do
|
25
|
+
before do
|
26
|
+
@headers = {'Content-Type' => 'application/x-www-form-urlencoded'}
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should make the correct http call return a successful response if the first message status equals 0' do
|
21
30
|
http_response = stub(:body => '{"messages":[{"status":0,"message-id":"id"}]}')
|
22
31
|
|
23
32
|
data = 'from=ruby&to=number&text=Hey%21&username=key&password=secret'
|
24
33
|
|
25
|
-
|
26
|
-
|
27
|
-
@client.http.expects(:post).with('/sms/json', data, headers).returns(http_response)
|
34
|
+
@client.http.expects(:post).with('/sms/json', data, @headers).returns(http_response)
|
28
35
|
|
29
36
|
response = @client.send_message({from: 'ruby', to: 'number', text: 'Hey!'})
|
30
37
|
|
31
|
-
|
38
|
+
response.success?.must_equal(true)
|
39
|
+
response.failure?.must_equal(false)
|
40
|
+
response.message_id.must_equal('id')
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should return a failure response if the first message status does not equal 0' do
|
44
|
+
http_response = stub(:body => '{"messages":[{"status":2,"error-text":"Missing from param"}]}')
|
45
|
+
|
46
|
+
data = 'to=number&text=Hey%21&username=key&password=secret'
|
47
|
+
|
48
|
+
@client.http.expects(:post).with('/sms/json', data, @headers).returns(http_response)
|
49
|
+
|
50
|
+
response = @client.send_message({to: 'number', text: 'Hey!'})
|
51
|
+
|
52
|
+
response.success?.must_equal(false)
|
53
|
+
response.failure?.must_equal(true)
|
54
|
+
response.error.to_s.must_equal('Missing from param (status=2)')
|
32
55
|
end
|
33
56
|
end
|
34
57
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexmo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &3707430 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.5'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *3707430
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: mocha
|
27
|
-
requirement: &
|
27
|
+
requirement: &3707100 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *3707100
|
36
36
|
description: A simple wrapper for the Nexmo API
|
37
37
|
email:
|
38
38
|
- mail@timcraft.com
|