smart_sms 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ae8bc61edbbcbc8ae6fdb4e185d1ec9b96d49dd7
4
- data.tar.gz: 5cf87b214f8541f14a99ad9a6a6e7ad5249c7432
3
+ metadata.gz: 3569350a7e3da1867a4cb90fd0c1dd1cf120adb6
4
+ data.tar.gz: 5c712a0e4a500ec1b8568d41b1bdfba2d4e34c60
5
5
  SHA512:
6
- metadata.gz: 929a55ac72a38ff5cbfab959ca8c3fcbefa75ef6f7cd2094c0601810c3d909b57afb7eb6755644bc7d1b80f8e4b8d87cc29beaa6d7585281f1d7783fe6b67e8b
7
- data.tar.gz: 56190a364c5fa08f8c938ae206a4d62e64243e827e608963ce0a07d8b6a7a52d2b14d1fdd4784e9519a4f9a7436dfa5db5a197a22d5aed72ca3b172d84781857
6
+ metadata.gz: 46a33be40d5698125a8112051cfdbfdcf9f0d9a56fb25f3222f09c7515f02fb45501086d451c0be602e3ac20bf7e854934e728bb6eb9ba689d9a81daa6e62b2e
7
+ data.tar.gz: 727df1af981327fcd5d35d5b4ae13ad0d8e09028616e79b19176d3164419907d37adbfdb1cc23facee31d6001b4c6c60a13f1e6e4a90c2efc8ab14982700e34e
@@ -0,0 +1,21 @@
1
+ --- !ruby/object:RDoc::Options
2
+ encoding: UTF-8
3
+ static_path: []
4
+ rdoc_include:
5
+ - "./lib"
6
+ charset: UTF-8
7
+ exclude:
8
+ - './spec'
9
+ hyperlink_all: true
10
+ line_numbers: true
11
+ main_page:
12
+ markup: markdown
13
+ output_decoration: true
14
+ page_dir:
15
+ search_index: true
16
+ show_hash: false
17
+ tab_width: 8
18
+ template_stylesheets: []
19
+ title:
20
+ visibility: :private
21
+ webcvs:
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- smart_sms (0.1.0)
4
+ smart_sms (0.1.1)
5
5
  activerecord (>= 3.0, < 5.0)
6
6
  activesupport (>= 3.0, < 5.0)
7
7
 
@@ -77,19 +77,31 @@ GEM
77
77
  rake (>= 0.8.7)
78
78
  thor (>= 0.18.1, < 2.0)
79
79
  rake (10.3.1)
80
- rspec-core (2.14.8)
81
- rspec-expectations (2.14.5)
82
- diff-lcs (>= 1.1.3, < 2.0)
83
- rspec-mocks (2.14.6)
84
- rspec-rails (2.14.2)
80
+ rdoc (4.1.1)
81
+ json (~> 1.4)
82
+ rspec-core (3.1.7)
83
+ rspec-support (~> 3.1.0)
84
+ rspec-expectations (3.1.2)
85
+ diff-lcs (>= 1.2.0, < 2.0)
86
+ rspec-support (~> 3.1.0)
87
+ rspec-its (1.1.0)
88
+ rspec-core (>= 3.0.0)
89
+ rspec-expectations (>= 3.0.0)
90
+ rspec-mocks (3.1.3)
91
+ rspec-support (~> 3.1.0)
92
+ rspec-rails (3.1.0)
85
93
  actionpack (>= 3.0)
86
- activemodel (>= 3.0)
87
94
  activesupport (>= 3.0)
88
95
  railties (>= 3.0)
89
- rspec-core (~> 2.14.0)
90
- rspec-expectations (~> 2.14.0)
91
- rspec-mocks (~> 2.14.0)
96
+ rspec-core (~> 3.1.0)
97
+ rspec-expectations (~> 3.1.0)
98
+ rspec-mocks (~> 3.1.0)
99
+ rspec-support (~> 3.1.0)
100
+ rspec-support (3.1.2)
92
101
  safe_yaml (1.0.3)
102
+ sdoc (0.4.0)
103
+ json (~> 1.8)
104
+ rdoc (~> 4.0, < 5.0)
93
105
  slop (3.5.0)
94
106
  sprockets (2.12.1)
95
107
  hike (~> 1.2)
@@ -122,7 +134,9 @@ DEPENDENCIES
122
134
  pry
123
135
  rails (>= 3.1.0)
124
136
  rake
125
- rspec-rails
137
+ rspec-its (>= 1.0.0)
138
+ rspec-rails (>= 3.0.0)
139
+ sdoc
126
140
  smart_sms!
127
141
  sqlite3
128
142
  webmock (~> 1.17.0)
data/README.md CHANGED
@@ -244,15 +244,18 @@ SmartSMS::Template.destroy 3252
244
244
  ``` ruby
245
245
 
246
246
  # 生成随机校验码
247
- # 三个选项:
248
- # simple: 6位随机数字, 默认
249
- # middle: 6位随机字母, 数字组合
250
- # complex: 8位随机字母, 数字, 特殊字符组合
251
-
252
- SmartSMS::VerificationCode.random # => "141068"
247
+ # 四个选项:
248
+ # short: 4位随机数字
249
+ # simple: 6位随机数字, 默认
250
+ # middle: 6位随机字母, 数字组合
251
+ # complex: 8位随机字母, 数字, 特殊字符组合
252
+
253
+ SmartSMS::VerificationCode.random # => "1708"
254
+ SmartSMS::VerificationCode.random :short # => "141068"
253
255
  SmartSMS::VerificationCode.random :middle # => "xey7id"
254
256
  SmartSMS::VerificationCode.random :complex # => "x+rkag6a"
255
257
 
258
+ SmartSMS::VerificationCode.short # => "1708"
256
259
  SmartSMS::VerificationCode.simple # => "141068"
257
260
  SmartSMS::VerificationCode.middle # => "xey7id"
258
261
  SmartSMS::VerificationCode.complex # => "x+rkag6a"
@@ -269,12 +272,8 @@ SmartSMS::VerificationCode.complex # => "x+rkag6a"
269
272
 
270
273
  ## LICENCE
271
274
 
272
- MIT
275
+ [MIT](https://github.com/lyfeyaj/smart_sms/blob/master/LICENSE)
273
276
 
274
277
  ## 作者
275
278
 
276
279
  [Felix Liu](https://github.com/lyfeyaj)
277
-
278
- ## TODO
279
-
280
- + 增加测试用例覆盖率
@@ -14,7 +14,9 @@ before running this command
14
14
  EOF
15
15
 
16
16
  def create_migration_file
17
- add_smart_sms_migration('create_smart_sms_messages') if SmartSMS.config.store_sms_in_local
17
+ return unless SmartSMS.config.store_sms_in_local
18
+ add_smart_sms_migration('create_smart_sms_messages')
19
+ add_smart_sms_migration('add_uid_to_smart_sms_messages')
18
20
  end
19
21
 
20
22
  def self.next_migration_number(dirname)
@@ -0,0 +1,6 @@
1
+ class AddUidToSmartSmsMessages < ActiveRecord::Migration
2
+ def change
3
+ add_column :smart_sms_messages, :uid, :string
4
+ add_index :smart_sms_messages, :uid
5
+ end
6
+ end
@@ -7,14 +7,17 @@ module SmartSMS
7
7
  module_function
8
8
 
9
9
  # 获取用户信息
10
+ #
10
11
  def info
11
12
  Request.post 'user/get.json'
12
13
  end
13
14
 
14
15
  # 设置用户信息
15
- # emergency_contact: 紧急联系人
16
- # emergency_mobile: 紧急联系人手机号
17
- # alarm_balance: 短信余额提醒阈值。一天只提示一次
16
+ #
17
+ # * emergency_contact: 紧急联系人
18
+ # * emergency_mobile: 紧急联系人手机号
19
+ # * alarm_balance: 短信余额提醒阈值。一天只提示一次
20
+ #
18
21
  def set(options = {})
19
22
  Request.post 'user/set.json', options
20
23
  end
@@ -20,30 +20,30 @@ module SmartSMS
20
20
  #
21
21
  class Configuration #:nodoc:
22
22
  include ActiveSupport::Configurable
23
- config_accessor :api_key # 授权 API KEY
24
- config_accessor :api_version # API 的版本, 当前仅有v1
25
- config_accessor :template_id # 指定发送信息时使用的模板
26
- config_accessor :template_value # 用于指定信息文本中的可替换内容, 数组形势: [:code, :company]
27
- config_accessor :page_num # 获取信息时, 指定默认的页数
28
- config_accessor :page_size # 获取信息时, 一页包含信息数量
29
- config_accessor :company # 默认公司名称
30
- config_accessor :expires_in # 短信验证过期时间
31
- config_accessor :default_interval # 查询短信时的默认时间段: end_time - start_time
32
- config_accessor :store_sms_in_local # 是否存储SMS信息在本地: true or false
23
+ config_accessor :api_key # 授权 API KEY
24
+ config_accessor :api_version # API 的版本, 当前仅有v1
25
+ config_accessor :template_id # 指定发送信息时使用的模板
26
+ config_accessor :template_value # 用于指定信息文本中的可替换内容, 数组形势: [:code, :company]
27
+ config_accessor :page_num # 获取信息时, 指定默认的页数
28
+ config_accessor :page_size # 获取信息时, 一页包含信息数量
29
+ config_accessor :company # 默认公司名称
30
+ config_accessor :expires_in # 短信验证过期时间
31
+ config_accessor :default_interval # 查询短信时的默认时间段: end_time - start_time
32
+ config_accessor :store_sms_in_local # 是否存储SMS信息在本地: true or false
33
33
  config_accessor :verification_code_algorithm # :simple, :middle, :complex
34
34
  end
35
35
 
36
36
  configure do |config|
37
- config.api_key = nil
38
- config.api_version = :v1
39
- config.template_id = '2'
40
- config.template_value = [:code, :company]
41
- config.page_num = 1
42
- config.page_size = 20
43
- config.company = '云片网'
44
- config.expires_in = 1.hour
45
- config.default_interval = 1.day
46
- config.store_sms_in_local = false
37
+ config.api_key = nil
38
+ config.api_version = :v1
39
+ config.template_id = '2'
40
+ config.template_value = [:code, :company]
41
+ config.page_num = 1
42
+ config.page_size = 20
43
+ config.company = '云片网'
44
+ config.expires_in = 1.hour
45
+ config.default_interval = 1.day
46
+ config.store_sms_in_local = false
47
47
  config.verification_code_algorithm = :simple
48
48
  end
49
49
  end
@@ -13,12 +13,13 @@ module SmartSMS
13
13
  module ClassMethods
14
14
 
15
15
  # 在您的Model里面声明这个方法, 以添加SMS短信验证功能
16
- # moible_column: mobile 绑定的字段, 用于发送短信
17
- # verification_column: 验证绑定的字段, 用于判断是否已验证
16
+ #
17
+ # * moible_column: mobile 绑定的字段, 用于发送短信, 默认 :phone
18
+ # * verification_column: 验证绑定的字段, 用于判断是否已验证, 默认 :verified_at
18
19
  #
19
20
  # Options:
20
- # :class_name 自定义的Message类名称. 默认是 `::SmartSMS::Message`
21
- # :messages 自定义的Message关联名称. 默认是 `:versions`.
21
+ # * :class_name 自定义的Message类名称. 默认是 `::SmartSMS::Message`
22
+ # * :messages 自定义的Message关联名称. 默认是 `:messages`.
22
23
  #
23
24
  def has_sms_verification(moible_column = :phone, verification_column = :verified_at, options = {})
24
25
  send :include, InstanceMethods
@@ -41,7 +42,7 @@ module SmartSMS
41
42
  class_attribute :message_class_name
42
43
  self.message_class_name = options[:class_name] || '::SmartSMS::Message'
43
44
 
44
- if ::ActiveRecord::VERSION::MAJOR >= 4 # Rails 4 里面, `has_many` 声明中定义order lambda的语法
45
+ if ::ActiveRecord::VERSION::MAJOR >= 4 # Rails 4 `has_many` 中定义order lambda的新语法
45
46
  has_many messages_association_name,
46
47
  -> { order('send_time ASC') },
47
48
  class_name: message_class_name,
@@ -57,8 +58,10 @@ module SmartSMS
57
58
  end
58
59
 
59
60
  # Instance methods
61
+ #
60
62
  module InstanceMethods
61
63
  # 非安全verify!方法, 验证成功后会存储成功的结果到数据表中
64
+ #
62
65
  def verify!(code)
63
66
  result = verify code
64
67
  if result
@@ -1,11 +1,19 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module SmartSMS
4
- # This will generate fake sms
4
+ # Module that contains methods to generate fake message
5
5
  #
6
6
  module FakeSMS
7
7
  module_function
8
8
 
9
+ # This will generate fake sms with all necessary attributes
10
+ #
11
+ # Options:
12
+ #
13
+ # * mobile: mobile number
14
+ # * code: verification code
15
+ # * company: assigned company, format is【company】
16
+ #
9
17
  def build_fake_sms(mobile, code, company)
10
18
  {
11
19
  'sid' => SecureRandom.uuid,
@@ -2,11 +2,13 @@ require 'securerandom'
2
2
 
3
3
  module SmartSMS
4
4
  # This module provides some methods to generate random verification code
5
+ #
5
6
  # Algorithm:
6
- # short: Generate short code with 4 numbers
7
- # simple: Generate simple code with 6 numbers
8
- # middle: Generate middle complex code of 6 charactors with mixed numbers and letters
9
- # complex: Generate complex code of 8 charactors with mixed numbers, letters or special charactors
7
+ #
8
+ # * short: Generate short code with 4 numbers
9
+ # * simple: Generate simple code with 6 numbers
10
+ # * middle: Generate middle complex code of 6 charactors with mixed numbers and letters
11
+ # * complex: Generate complex code of 8 charactors with mixed numbers, letters or special charactors
10
12
  module VerificationCode
11
13
  module_function
12
14
 
@@ -10,12 +10,14 @@ module SmartSMS
10
10
  DATETIME_FORMAT = '%Y-%m-%d %H:%M:%S'
11
11
 
12
12
  # 发送短信到手机, 默认使用模板发送, 提供通用接口支持
13
- # phone: 需要接受短信的手机号码
14
- # content: 短信验证内容
13
+ #
14
+ # * phone: 需要接受短信的手机号码
15
+ # * content: 短信验证内容
15
16
  #
16
17
  # Options:
17
- # :method 如若要使用通用短信接口, 需要 :method => :general
18
- # :tpl_id 选择发送短信的模板, 默认是2
18
+ #
19
+ # * method 如若要使用通用短信接口, 需要 :method => :general
20
+ # * tpl_id 选择发送短信的模板, 默认是2
19
21
  def deliver(phone, content, options = {})
20
22
  if options[:method] == :general
21
23
  Request.post 'sms/send.json', mobile: phone, text: content, extend: options[:extend]
@@ -38,10 +40,13 @@ module SmartSMS
38
40
  find_messages 'sms/get.json', options
39
41
  end
40
42
 
43
+ # 查询黑名单词语, 用于预先测试可能无法通过审核的模板
44
+ #
41
45
  def get_black_word(text = '')
42
46
  Request.post 'sms/get_black_word.json', text: text
43
47
  end
44
48
 
49
+ # 查询用户回复的短信, 参见 `find_messages` 方法
45
50
  def get_reply(options = {})
46
51
  find_messages 'sms/get_reply.json', options
47
52
  end
@@ -49,11 +54,12 @@ module SmartSMS
49
54
  private
50
55
 
51
56
  # 批量查短信, 参数:
52
- # start_time: 短信提交开始时间
53
- # end_time: 短信提交结束时间
54
- # page_num: 页码,从1开始
55
- # page_size: 每页个数,最大100个
56
- # mobile: 接收短信的手机号
57
+ #
58
+ # * start_time: 短信提交开始时间
59
+ # * end_time: 短信提交结束时间
60
+ # * page_num: 页码,从1开始
61
+ # * page_size: 每页个数,最大100个
62
+ # * mobile: 接收短信的手机号
57
63
  #
58
64
  def find_messages(api, options = {})
59
65
  options[:end_time] = Time.now if options[:end_time].blank?
@@ -65,6 +71,9 @@ module SmartSMS
65
71
  Request.post api, options
66
72
  end
67
73
 
74
+ # 解析日期时间
75
+ # 格式可以是 `2014-05-01 08:40:20`, 也可以是Time类型
76
+ #
68
77
  def parse_time(time = '')
69
78
  if time.present? && time.is_a?(Time)
70
79
  time.strftime DATETIME_FORMAT
@@ -75,6 +84,8 @@ module SmartSMS
75
84
  end
76
85
  end
77
86
 
87
+ # 生成信息发送内容
88
+ #
78
89
  def parse_content(options = {})
79
90
  options[:code] ||= ''
80
91
  options[:company] ||= SmartSMS.config.company
@@ -4,6 +4,6 @@ module SmartSMS
4
4
  class Message < ::ActiveRecord::Base
5
5
  self.table_name = 'smart_sms_messages'
6
6
  belongs_to :smsable, polymorphic: true
7
- attr_accessible :sid, :mobile, :send_time, :text, :code, :send_status, :report_status, :fee, :user_receive_time, :error_msg if SmartSMS.active_record_protected_attributes?
7
+ attr_accessible :sid, :uid, :mobile, :send_time, :text, :code, :send_status, :report_status, :fee, :user_receive_time, :error_msg if SmartSMS.active_record_protected_attributes?
8
8
  end
9
9
  end
@@ -5,6 +5,8 @@ require 'active_support/json'
5
5
  module SmartSMS
6
6
  # Module that manage requests
7
7
  module Request
8
+ # Method that use `Net::HTTP.post_form` to perform `POST` action
9
+ #
8
10
  def post(api, options = {})
9
11
  options[:apikey] = SmartSMS.config.api_key
10
12
  uri = URI.join(base_url, api)
@@ -12,6 +14,8 @@ module SmartSMS
12
14
  result res.body
13
15
  end
14
16
 
17
+ # Method that use `Net::HTTP.get` to perform `GET` action
18
+ #
15
19
  def get(api, options = {})
16
20
  options[:apikey] = SmartSMS.config.api_key
17
21
  uri = URI.join(base_url, api)
@@ -20,6 +24,8 @@ module SmartSMS
20
24
 
21
25
  private
22
26
 
27
+ # Method that parse JSON to Hash
28
+ #
23
29
  def result(body)
24
30
  begin
25
31
  ActiveSupport::JSON.decode body
@@ -32,6 +38,7 @@ module SmartSMS
32
38
  end
33
39
  end
34
40
 
41
+ # Base uri for yunpian API
35
42
  def base_url
36
43
  "http://yunpian.com/#{SmartSMS.config.api_version}/"
37
44
  end
@@ -7,7 +7,8 @@ module SmartSMS
7
7
 
8
8
  # 取默认模板
9
9
  # Options:
10
- # tpl_id: 指定tpl_id时返回tpl_id对应的默认模板. 未指定时返回所有默认模板
10
+ #
11
+ # * tpl_id: 指定tpl_id时返回tpl_id对应的默认模板. 未指定时返回所有默认模板
11
12
  #
12
13
  def find_default(tpl_id = '')
13
14
  Request.post 'tpl/get_default.json', tpl_id: tpl_id
@@ -15,7 +16,8 @@ module SmartSMS
15
16
 
16
17
  # 取自定义模板
17
18
  # Options:
18
- # tpl_id: 指定tpl_id时返回tpl_id对应的自定义模板. 未指定时返回所有自定义模板
19
+ #
20
+ # * tpl_id: 指定tpl_id时返回tpl_id对应的自定义模板. 未指定时返回所有自定义模板
19
21
  #
20
22
  def find(tpl_id = '')
21
23
  Request.post 'tpl/get.json', tpl_id: tpl_id
@@ -1,3 +1,3 @@
1
1
  module SmartSMS
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
@@ -24,10 +24,12 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_development_dependency 'bundler', ['>= 1.0.0']
26
26
  s.add_development_dependency 'rake', ['>= 0']
27
- s.add_development_dependency 'rspec-rails', ['>= 0']
27
+ s.add_development_dependency 'rspec-rails', ['>= 3.0.0']
28
+ s.add_development_dependency 'rspec-its', ['>= 1.0.0']
28
29
  s.add_development_dependency 'database_cleaner', ['~> 1.2.0']
29
30
  s.add_development_dependency 'webmock', ['~> 1.17.0']
30
31
  s.add_development_dependency 'rails', ['>= 3.1.0']
31
32
  s.add_development_dependency 'sqlite3', ['>= 0']
32
33
  s.add_development_dependency 'pry', ['>= 0']
34
+ s.add_development_dependency 'sdoc', ['>= 0']
33
35
  end
@@ -23,6 +23,7 @@ class CreateAllTables < ActiveRecord::Migration
23
23
 
24
24
  create_table :smart_sms_messages do |t|
25
25
  t.string :sid
26
+ t.string :uid
26
27
  t.string :mobile
27
28
  t.datetime :send_time
28
29
  t.text :text
@@ -35,6 +36,7 @@ class CreateAllTables < ActiveRecord::Migration
35
36
  t.belongs_to :smsable, polymorphic: true
36
37
  end
37
38
  add_index :smart_sms_messages, :sid
39
+ add_index :smart_sms_messages, :uid
38
40
  add_index :smart_sms_messages, [:smsable_id, :smsable_type]
39
41
  end
40
42
  end
@@ -18,8 +18,8 @@ describe 'SmartSMS::HasSmsVerification' do
18
18
  before { user.verify! verification_code }
19
19
 
20
20
  it 'should be verified' do
21
- expect { user.verify! verification_code }.to be_true
22
- expect(user.reload.verified?).to be_true
21
+ expect(user.verify! verification_code).to be_truthy
22
+ expect(user.reload.verified?).to be_truthy
23
23
  end
24
24
 
25
25
  it 'should have right verification code' do
@@ -46,7 +46,7 @@ describe 'SmartSMS::HasSmsVerification' do
46
46
 
47
47
  it 'should not be verified' do
48
48
  expect(user.verify!('kfdsfd')).to be_nil
49
- expect(user.reload.verified?).to be_false
49
+ expect(user.reload.verified?).to be_falsey
50
50
  end
51
51
 
52
52
  it 'should not have right verification code' do
@@ -79,8 +79,8 @@ describe 'SmartSMS::HasSmsVerification' do
79
79
  before { account.verify! verification_code }
80
80
 
81
81
  it 'should be verified' do
82
- expect { account.verify! verification_code }.to be_true
83
- expect(account.reload.verified?).to be_true
82
+ expect(account.verify! verification_code).to be_truthy
83
+ expect(account.reload.verified?).to be_truthy
84
84
  end
85
85
 
86
86
  it 'should have right verification code' do
@@ -111,7 +111,7 @@ describe 'SmartSMS::HasSmsVerification' do
111
111
 
112
112
  it 'should not be verified' do
113
113
  expect(account.verify!('kfdsfd')).to be_nil
114
- expect(account.reload.verified?).to be_false
114
+ expect(account.reload.verified?).to be_falsey
115
115
  end
116
116
 
117
117
  it 'should not have right verification code' do
@@ -152,8 +152,8 @@ describe 'SmartSMS::HasSmsVerification' do
152
152
  before { user.verify verification_code }
153
153
 
154
154
  it 'should be verified' do
155
- expect { user.verify verification_code }.to be_true
156
- expect(user.reload.verified?).to be_false
155
+ expect(user.verify verification_code).to be_truthy
156
+ expect(user.reload.verified?).to be_falsey
157
157
  end
158
158
 
159
159
  it 'should have right verification code' do
@@ -167,7 +167,7 @@ describe 'SmartSMS::HasSmsVerification' do
167
167
  it 'should not be verified by using expired verification code' do
168
168
  user.verified_at = nil
169
169
  user.save
170
- expect(user.verify(user.messages.first.code)).to be_false
170
+ expect(user.verify(user.messages.first.code)).to be_falsey
171
171
  end
172
172
 
173
173
  it 'should be the latest_message' do
@@ -179,8 +179,8 @@ describe 'SmartSMS::HasSmsVerification' do
179
179
  before { user.verify 'kfdsfd' }
180
180
 
181
181
  it 'should not be verified' do
182
- expect(user.verify('kfdsfd')).to be_false
183
- expect(user.reload.verified?).to be_false
182
+ expect(user.verify('kfdsfd')).to be_falsey
183
+ expect(user.reload.verified?).to be_falsey
184
184
  end
185
185
 
186
186
  it 'should not have right verification code' do
@@ -194,7 +194,7 @@ describe 'SmartSMS::HasSmsVerification' do
194
194
  it 'should not be verified by using expired verification code' do
195
195
  user.verified_at = nil
196
196
  user.save
197
- expect(user.verify(user.messages.first.code)).to be_false
197
+ expect(user.verify(user.messages.first.code)).to be_falsey
198
198
  end
199
199
 
200
200
  it 'should be the latest_message' do
@@ -213,8 +213,8 @@ describe 'SmartSMS::HasSmsVerification' do
213
213
  before { account.verify verification_code }
214
214
 
215
215
  it 'should be verified' do
216
- expect { account.verify verification_code }.to be_true
217
- expect(account.reload.verified?).to be_false
216
+ expect(account.verify verification_code).to be_truthy
217
+ expect(account.reload.verified?).to be_falsey
218
218
  end
219
219
 
220
220
  it 'should have right verification code' do
@@ -228,7 +228,7 @@ describe 'SmartSMS::HasSmsVerification' do
228
228
  it 'should not be verified by using expired verification code' do
229
229
  account.confirmed_at = nil
230
230
  account.save
231
- expect(user.verify(account.messages.first.code)).to be_false
231
+ expect(user.verify(account.messages.first.code)).to be_falsey
232
232
  end
233
233
 
234
234
  it 'should be the latest_message' do
@@ -244,8 +244,8 @@ describe 'SmartSMS::HasSmsVerification' do
244
244
  before { account.verify 'kfdsfd' }
245
245
 
246
246
  it 'should not be verified' do
247
- expect(account.verify('kfdsfd')).to be_false
248
- expect(account.reload.verified?).to be_false
247
+ expect(account.verify('kfdsfd')).to be_falsey
248
+ expect(account.reload.verified?).to be_falsey
249
249
  end
250
250
 
251
251
  it 'should not have right verification code' do
@@ -259,7 +259,7 @@ describe 'SmartSMS::HasSmsVerification' do
259
259
  it 'should not be verified by using expired verification code' do
260
260
  account.confirmed_at = nil
261
261
  account.save
262
- expect(account.verify(account.messages.first.code)).to be_false
262
+ expect(account.verify(account.messages.first.code)).to be_falsey
263
263
  end
264
264
 
265
265
  it 'should be the latest_message' do
@@ -242,7 +242,7 @@ describe SmartSMS do
242
242
  'sms_reply' => [
243
243
  {
244
244
  'id' => nil,
245
- 'mobile' => '15121000465',
245
+ 'mobile' => phone,
246
246
  'text' => '哈哈',
247
247
  'reply_time' => '2014-05-08 12:03:16',
248
248
  'extend' => '11642'
@@ -256,5 +256,6 @@ describe SmartSMS do
256
256
  its(['msg']) { should eq 'OK' }
257
257
  its(:keys) { should include 'sms_reply' }
258
258
  its(['sms_reply']) { should_not be_empty }
259
+ its(['sms_reply', 0, 'mobile']) { should eq phone }
259
260
  end
260
261
  end
@@ -8,6 +8,7 @@ require 'rubygems'
8
8
  require 'bundler/setup'
9
9
  # Bundler.require
10
10
 
11
+ require 'rspec/its'
11
12
  require 'webmock/rspec'
12
13
 
13
14
  require 'smart_sms'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smart_sms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - lyfeyaj
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-08 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -84,14 +84,28 @@ dependencies:
84
84
  requirements:
85
85
  - - ">="
86
86
  - !ruby/object:Gem::Version
87
- version: '0'
87
+ version: 3.0.0
88
88
  type: :development
89
89
  prerelease: false
90
90
  version_requirements: !ruby/object:Gem::Requirement
91
91
  requirements:
92
92
  - - ">="
93
93
  - !ruby/object:Gem::Version
94
- version: '0'
94
+ version: 3.0.0
95
+ - !ruby/object:Gem::Dependency
96
+ name: rspec-its
97
+ requirement: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: 1.0.0
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: 1.0.0
95
109
  - !ruby/object:Gem::Dependency
96
110
  name: database_cleaner
97
111
  requirement: !ruby/object:Gem::Requirement
@@ -162,6 +176,20 @@ dependencies:
162
176
  - - ">="
163
177
  - !ruby/object:Gem::Version
164
178
  version: '0'
179
+ - !ruby/object:Gem::Dependency
180
+ name: sdoc
181
+ requirement: !ruby/object:Gem::Requirement
182
+ requirements:
183
+ - - ">="
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ type: :development
187
+ prerelease: false
188
+ version_requirements: !ruby/object:Gem::Requirement
189
+ requirements:
190
+ - - ">="
191
+ - !ruby/object:Gem::Version
192
+ version: '0'
165
193
  description: A smart sms verification tool
166
194
  email:
167
195
  - lyfeyaj@gmail.com
@@ -170,6 +198,7 @@ extensions: []
170
198
  extra_rdoc_files: []
171
199
  files:
172
200
  - ".gitignore"
201
+ - ".rdoc_options"
173
202
  - ".travis.yml"
174
203
  - Gemfile
175
204
  - Gemfile.lock
@@ -178,6 +207,7 @@ files:
178
207
  - Rakefile
179
208
  - lib/generators/smart_sms/config_generator.rb
180
209
  - lib/generators/smart_sms/install_generator.rb
210
+ - lib/generators/smart_sms/templates/add_uid_to_smart_sms_messages.rb
181
211
  - lib/generators/smart_sms/templates/create_smart_sms_messages.rb
182
212
  - lib/generators/smart_sms/templates/smart_sms_config.rb
183
213
  - lib/smart_sms.rb
@@ -225,7 +255,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
255
  version: '0'
226
256
  requirements: []
227
257
  rubyforge_project:
228
- rubygems_version: 2.2.2
258
+ rubygems_version: 2.4.3
229
259
  signing_key:
230
260
  specification_version: 4
231
261
  summary: A smart sms verification tool used in China and integrate with yunpian.com