Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
48 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
require "bundler/gem_tasks" | ||
Bundler::GemHelper.install_tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
require 'spec_helper' | ||
|
||
describe "ChinaSMS" do | ||
#let(:service) { :smsbao } | ||
#jlet(:service) { :chanyoo } | ||
let(:service) { :tui3 } | ||
let(:username) { 'saberma' } | ||
let(:password) { '666666' } | ||
subject { ChinaSMS } | ||
before { ChinaSMS.use service, username: 'saberma', password: password } | ||
let(:phone) { '13928452841' } | ||
let(:content) { '活动通知:深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。' } | ||
before { ChinaSMS.use service, username: username, password: password } | ||
describe "#use" do | ||
subject { ChinaSMS } | ||
its(:username) { should eql "saberma"} | ||
end | ||
describe "#to" do | ||
it 'should be success' do | ||
#result = subject.to('13928452841', '深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。【19屋】') | ||
result = subject.to('13928452841', '活动通知:深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。') | ||
puts result | ||
end | ||
subject { ChinaSMS.to(phone, content) } | ||
before { ChinaSMS::Service::Tui3.stub(:to).with(phone, content, username: username, password: password).and_return(success: true, code: 0) } | ||
its([:success]) { should eql true } | ||
its([:code]) { should eql 0 } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require 'spec_helper' | ||
|
||
describe "Tui3" do | ||
describe "#to" do | ||
let(:username) { 'saberma' } | ||
let(:password) { '666666' } | ||
let(:phone) { '13928452841' } | ||
let(:content) { '活动通知:深圳 Rubyist 活动时间变更到明天下午 7:00,请留意。' } | ||
before do | ||
stub_request(:post, "http://tui3.com/api/send/"). | ||
with(body: {k: password, t: phone, c: content, p: '1', r: 'json'}). | ||
to_return(body: { | ||
"err_code" => 0, | ||
"err_msg" => "操作成功!", | ||
"sms_count" => 1, | ||
"tick_ids" => "20076900", | ||
"remain_count" => 6, | ||
"server_time" => "2013-06-30 22:05:31" | ||
}) | ||
end | ||
subject { ChinaSMS::Service::Tui3.to phone, content, username: username, password: password } | ||
its([:success]) { should eql true } | ||
its([:code]) { should eql 0 } | ||
its([:message]) { should eql "操作成功!" } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
require 'webmock/rspec' | ||
require 'china_sms' | ||
|
||
RSpec.configure do |config| | ||
|