clickatell 0.8.1 → 0.8.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/History.txt +3 -0
- data/clickatell.gemspec +5 -6
- data/lib/clickatell/utility/options.rb +1 -1
- data/lib/clickatell/version.rb +1 -1
- data/spec/cli_options_spec.rb +30 -0
- metadata +6 -8
- data/spec/cli_options_test.rb +0 -26
- data/test/clickatell_api_test.rb +0 -94
data/History.txt
CHANGED
data/clickatell.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{clickatell}
|
8
|
-
s.version = "0.8.
|
8
|
+
s.version = "0.8.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Luke Redpath"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-09-09}
|
13
13
|
s.default_executable = %q{sms}
|
14
14
|
s.email = %q{luke@lukeredpath.co.uk}
|
15
15
|
s.executables = ["sms"]
|
@@ -40,7 +40,7 @@ Gem::Specification.new do |s|
|
|
40
40
|
"lib/core-ext/hash.rb",
|
41
41
|
"scripts/txt2html",
|
42
42
|
"spec/api_spec.rb",
|
43
|
-
"spec/
|
43
|
+
"spec/cli_options_spec.rb",
|
44
44
|
"spec/command_executor_spec.rb",
|
45
45
|
"spec/hash_ext_spec.rb",
|
46
46
|
"spec/response_spec.rb",
|
@@ -63,12 +63,11 @@ Gem::Specification.new do |s|
|
|
63
63
|
s.summary = %q{Ruby interface to the Clickatell SMS gateway service.}
|
64
64
|
s.test_files = [
|
65
65
|
"spec/api_spec.rb",
|
66
|
-
"spec/
|
66
|
+
"spec/cli_options_spec.rb",
|
67
67
|
"spec/command_executor_spec.rb",
|
68
68
|
"spec/hash_ext_spec.rb",
|
69
69
|
"spec/response_spec.rb",
|
70
|
-
"spec/spec_helper.rb"
|
71
|
-
"test/clickatell_api_test.rb"
|
70
|
+
"spec/spec_helper.rb"
|
72
71
|
]
|
73
72
|
|
74
73
|
if s.respond_to? :specification_version then
|
data/lib/clickatell/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/../lib/clickatell/utility'
|
3
|
+
|
4
|
+
describe "CLI options" do
|
5
|
+
|
6
|
+
context "when sending a message" do
|
7
|
+
it "should allow single recipients" do
|
8
|
+
options = Clickatell::Utility::Options.parse(%w{07944123456 testing})
|
9
|
+
options.recipient.should include("07944123456")
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should allow multiple, comma-separated recipients" do
|
13
|
+
options = Clickatell::Utility::Options.parse(%w{07944123456,07944123457 testing})
|
14
|
+
options.recipient.should include(*%w{07944123456 07944123457})
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should strip + symbols from the beginning of numbers" do
|
18
|
+
options = Clickatell::Utility::Options.parse(%w{+447944123456 testing})
|
19
|
+
options.recipient.should include("447944123456")
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "when checking balance" do
|
24
|
+
it "should not require a recipient" do
|
25
|
+
options = Clickatell::Utility::Options.parse(%w{-b})
|
26
|
+
options.recipient.should be_nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clickatell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 59
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 8
|
9
|
-
-
|
10
|
-
version: 0.8.
|
9
|
+
- 2
|
10
|
+
version: 0.8.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Luke Redpath
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-09-09 00:00:00 +01:00
|
19
19
|
default_executable: sms
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -51,7 +51,7 @@ files:
|
|
51
51
|
- lib/core-ext/hash.rb
|
52
52
|
- scripts/txt2html
|
53
53
|
- spec/api_spec.rb
|
54
|
-
- spec/
|
54
|
+
- spec/cli_options_spec.rb
|
55
55
|
- spec/command_executor_spec.rb
|
56
56
|
- spec/hash_ext_spec.rb
|
57
57
|
- spec/response_spec.rb
|
@@ -66,7 +66,6 @@ files:
|
|
66
66
|
- website/stylesheets/rdoc.css
|
67
67
|
- website/stylesheets/screen.css
|
68
68
|
- website/template.rhtml
|
69
|
-
- test/clickatell_api_test.rb
|
70
69
|
has_rdoc: true
|
71
70
|
homepage: http://clickatell.rubyforge.org
|
72
71
|
licenses: []
|
@@ -104,9 +103,8 @@ specification_version: 3
|
|
104
103
|
summary: Ruby interface to the Clickatell SMS gateway service.
|
105
104
|
test_files:
|
106
105
|
- spec/api_spec.rb
|
107
|
-
- spec/
|
106
|
+
- spec/cli_options_spec.rb
|
108
107
|
- spec/command_executor_spec.rb
|
109
108
|
- spec/hash_ext_spec.rb
|
110
109
|
- spec/response_spec.rb
|
111
110
|
- spec/spec_helper.rb
|
112
|
-
- test/clickatell_api_test.rb
|
data/spec/cli_options_test.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'shoulda'
|
3
|
-
require File.join(File.dirname(__FILE__), *%w[.. lib clickatell utility])
|
4
|
-
|
5
|
-
class CliOptionsTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
context "Sending a message" do
|
8
|
-
should "allow single recipients" do
|
9
|
-
options = Clickatell::Utility::Options.parse(%w{07944123456 testing})
|
10
|
-
assert_equal %w{07944123456}, options.recipient
|
11
|
-
end
|
12
|
-
|
13
|
-
should "allow multiple, comma-separated recipients" do
|
14
|
-
options = Clickatell::Utility::Options.parse(%w{07944123456,07944123457 testing})
|
15
|
-
assert_equal %w{07944123456 07944123457}, options.recipient
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context "Checking balance" do
|
20
|
-
should "not require a recipient" do
|
21
|
-
options = Clickatell::Utility::Options.parse(%w{-b})
|
22
|
-
assert_nil options.recipient
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
data/test/clickatell_api_test.rb
DELETED
@@ -1,94 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'clickatell/api'
|
3
|
-
|
4
|
-
class ClickatellApiTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
context "Clickatell::API" do
|
7
|
-
setup do
|
8
|
-
@client = mock('client')
|
9
|
-
@client.stubs(:session_id).returns('dummy_session_id')
|
10
|
-
|
11
|
-
@api = Clickatell::API.new(@client)
|
12
|
-
end
|
13
|
-
|
14
|
-
context "#ping" do
|
15
|
-
should "perform the ping command with the current session id" do
|
16
|
-
@client.expects(:perform_command).with('ping',
|
17
|
-
has_entry(:session_id => 'dummy_session_id')).returns(stub_response)
|
18
|
-
@api.ping
|
19
|
-
end
|
20
|
-
|
21
|
-
should "return true when successful" do
|
22
|
-
@client.stubs(:perform_command).with('ping', anything).returns(stub_response("OK:"))
|
23
|
-
assert @api.ping
|
24
|
-
end
|
25
|
-
|
26
|
-
should "return false when failed" do
|
27
|
-
@client.stubs(:perform_command).with('ping', anything).returns(stub_response("ERR:"))
|
28
|
-
assert !@api.ping
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "#send_message with a single recipient" do
|
33
|
-
should "perform the sendmsg command with the correct options" do
|
34
|
-
@client.expects(:perform_command).with('sendmsg',
|
35
|
-
has_entries(:to => '07999000000', :text => 'testing')).returns(stub_response)
|
36
|
-
|
37
|
-
@api.send_message('07999000000', 'testing')
|
38
|
-
end
|
39
|
-
|
40
|
-
should "allow a custom sender to be set" do
|
41
|
-
@client.expects(:perform_command).with('sendmsg',
|
42
|
-
has_entry(:from => 'SENDER')).returns(stub_response)
|
43
|
-
|
44
|
-
@api.send_message('07999000000', 'testing', :from => 'SENDER')
|
45
|
-
end
|
46
|
-
|
47
|
-
should "set the req_feat parameter when specifying a custom sender" do
|
48
|
-
@client.expects(:perform_command).with('sendmsg',
|
49
|
-
has_entry(:req_feat => '48')).returns(stub_response)
|
50
|
-
|
51
|
-
@api.send_message('07999000000', 'testing', :from => 'SENDER')
|
52
|
-
end
|
53
|
-
|
54
|
-
should "set the mobile originated flag if specified" do
|
55
|
-
@client.expects(:perform_command).with('sendmsg',
|
56
|
-
has_entry(:mo => '1')).returns(stub_response)
|
57
|
-
|
58
|
-
@api.send_message('07999000000', 'testing', :set_mobile_originated => true)
|
59
|
-
end
|
60
|
-
|
61
|
-
should "return a single message ID" do
|
62
|
-
@client.stubs(:perform_command).returns(stub_response(%{
|
63
|
-
ID: 99999123
|
64
|
-
}))
|
65
|
-
assert_equal %w{99999123}, @api.send_message('07999000000', 'testing')
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context "#send_message with multiple recipients" do
|
70
|
-
should "perform the sendmsg command with a comma-separated list of recipients" do
|
71
|
-
@client.expects(:perform_command).with('sendmsg',
|
72
|
-
has_entry(:to => '07999000000,07999000001,07999000002')).returns(stub_response)
|
73
|
-
|
74
|
-
@api.send_message(%w{07999000000 07999000001 07999000002}, 'testing')
|
75
|
-
end
|
76
|
-
|
77
|
-
should "return an array of message IDs" do
|
78
|
-
@client.stubs(:perform_command).returns(stub_response(%{
|
79
|
-
ID: 0000001
|
80
|
-
ID: 0000002
|
81
|
-
ID: 0000003
|
82
|
-
}))
|
83
|
-
expected = %w{0000001 0000002 0000003}
|
84
|
-
assert_equal expected, @api.send_message(%w{07999000000 07999000001 07999000002}, 'testing')
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
|
91
|
-
def stub_response(body = '', code = 200)
|
92
|
-
stub('Net::HTTP::Response', :code => 200, :body => body)
|
93
|
-
end
|
94
|
-
end
|