china_sms 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/china_sms.rb +5 -1
- data/lib/china_sms/version.rb +1 -1
- data/spec/china_sms_spec.rb +19 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5451fdea00e162bca4570ec3e03d6e8c1a7d9585
|
4
|
+
data.tar.gz: 982919da3acb9039d0f674e41f47778fa1da9c9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 119821e27f6959a1b17a48eacecce1fa00f17d9180bfe0118944c5d150935fcc461669d66fa44e130dfc0a9a0f8249cebb89240ff93e6227dc7a146e29cd0134
|
7
|
+
data.tar.gz: 6c91a813cf3f8b38e68b2a285273a1f8df88acb714741c7bcafb5a7d9605adb7debf27f013ce3faa9c9becff4ee21448d194416e11a2343153fc52e66e2faeb0
|
data/lib/china_sms.rb
CHANGED
@@ -21,6 +21,10 @@ module ChinaSMS
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def to(receiver, content)
|
24
|
-
@service.to receiver, content, username: @username, password: @password
|
24
|
+
@service.to receiver, content, username: @username, password: @password if @service
|
25
|
+
end
|
26
|
+
|
27
|
+
def clear
|
28
|
+
@service = @username = @password = nil
|
25
29
|
end
|
26
30
|
end
|
data/lib/china_sms/version.rb
CHANGED
data/spec/china_sms_spec.rb
CHANGED
@@ -7,15 +7,25 @@ describe "ChinaSMS" do
|
|
7
7
|
let(:password) { '666666' }
|
8
8
|
let(:phone) { '13928452841' }
|
9
9
|
let(:content) { '活动通知:深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。' }
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
context 'with service' do
|
11
|
+
before { ChinaSMS.use service, username: username, password: password }
|
12
|
+
describe "#use" do
|
13
|
+
subject { ChinaSMS }
|
14
|
+
its(:username) { should eql "saberma"}
|
15
|
+
end
|
16
|
+
describe "#to" do
|
17
|
+
subject { ChinaSMS.to(phone, content) }
|
18
|
+
before { ChinaSMS::Service::Tui3.stub(:to).with(phone, content, username: username, password: password).and_return(success: true, code: 0) }
|
19
|
+
its([:success]) { should eql true }
|
20
|
+
its([:code]) { should eql 0 }
|
21
|
+
end
|
14
22
|
end
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
23
|
+
context 'without service' do
|
24
|
+
before { ChinaSMS.clear }
|
25
|
+
describe '#to' do
|
26
|
+
it 'should be ignore' do
|
27
|
+
ChinaSMS.to(phone, content)
|
28
|
+
end
|
29
|
+
end
|
20
30
|
end
|
21
31
|
end
|