jpmobile 5.0.0 → 5.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -3
  3. data/.rubocop.yml +123 -0
  4. data/CONTRIBUTING.md +16 -14
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +198 -0
  7. data/README.md +409 -0
  8. data/Rakefile +9 -9
  9. data/circle.yml +14 -0
  10. data/jpmobile.gemspec +9 -10
  11. data/lib/jpmobile.rb +6 -5
  12. data/lib/jpmobile/datum_conv.rb +35 -35
  13. data/lib/jpmobile/docomo_guid.rb +7 -8
  14. data/lib/jpmobile/email.rb +12 -12
  15. data/lib/jpmobile/emoticon.rb +85 -76
  16. data/lib/jpmobile/emoticon/au.rb +1284 -1284
  17. data/lib/jpmobile/emoticon/conversion_table.rb +3905 -3906
  18. data/lib/jpmobile/emoticon/docomo.rb +252 -252
  19. data/lib/jpmobile/emoticon/google.rb +9 -9
  20. data/lib/jpmobile/emoticon/softbank.rb +471 -471
  21. data/lib/jpmobile/emoticon/unicode.rb +9 -9
  22. data/lib/jpmobile/emoticon/z_combine.rb +20 -23
  23. data/lib/jpmobile/encoding.rb +1 -1
  24. data/lib/jpmobile/fallback_view_selector.rb +2 -3
  25. data/lib/jpmobile/filter.rb +44 -47
  26. data/lib/jpmobile/helpers.rb +38 -38
  27. data/lib/jpmobile/hook_action_view.rb +7 -7
  28. data/lib/jpmobile/hook_test_request.rb +0 -1
  29. data/lib/jpmobile/lookup_context.rb +1 -2
  30. data/lib/jpmobile/mail.rb +156 -134
  31. data/lib/jpmobile/mailer.rb +4 -4
  32. data/lib/jpmobile/mobile/abstract_mobile.rb +62 -36
  33. data/lib/jpmobile/mobile/android.rb +0 -1
  34. data/lib/jpmobile/mobile/android_tablet.rb +0 -1
  35. data/lib/jpmobile/mobile/au.rb +40 -28
  36. data/lib/jpmobile/mobile/black_berry.rb +0 -1
  37. data/lib/jpmobile/mobile/ddipocket.rb +1 -2
  38. data/lib/jpmobile/mobile/docomo.rb +47 -36
  39. data/lib/jpmobile/mobile/emobile.rb +1 -2
  40. data/lib/jpmobile/mobile/google_emoticon.rb +1 -1
  41. data/lib/jpmobile/mobile/ipad.rb +0 -1
  42. data/lib/jpmobile/mobile/iphone.rb +0 -1
  43. data/lib/jpmobile/mobile/smart_phone.rb +0 -1
  44. data/lib/jpmobile/mobile/softbank.rb +24 -20
  45. data/lib/jpmobile/mobile/tablet.rb +0 -1
  46. data/lib/jpmobile/mobile/unicode_emoticon.rb +15 -15
  47. data/lib/jpmobile/mobile/vodafone.rb +0 -1
  48. data/lib/jpmobile/mobile/willcom.rb +7 -7
  49. data/lib/jpmobile/mobile/windows_phone.rb +0 -1
  50. data/lib/jpmobile/path_set.rb +1 -1
  51. data/lib/jpmobile/position.rb +30 -14
  52. data/lib/jpmobile/rack/filter.rb +4 -4
  53. data/lib/jpmobile/rack/mobile_carrier.rb +0 -1
  54. data/lib/jpmobile/rack/params_filter.rb +7 -6
  55. data/lib/jpmobile/rails.rb +3 -4
  56. data/lib/jpmobile/request_with_mobile.rb +9 -6
  57. data/lib/jpmobile/resolver.rb +23 -17
  58. data/lib/jpmobile/session/active_record_store.rb +7 -9
  59. data/lib/jpmobile/session/mem_cache_store.rb +7 -9
  60. data/lib/jpmobile/sinatra.rb +1 -1
  61. data/lib/jpmobile/trans_sid.rb +15 -20
  62. data/lib/jpmobile/util.rb +61 -77
  63. data/lib/jpmobile/version.rb +1 -1
  64. data/lib/tasks/jpmobile_tasks.rake +35 -28
  65. data/spec/rack/jpmobile/android_spec.rb +5 -5
  66. data/spec/rack/jpmobile/au_spec.rb +74 -59
  67. data/spec/rack/jpmobile/black_berry_spec.rb +5 -5
  68. data/spec/rack/jpmobile/docomo_spec.rb +77 -64
  69. data/spec/rack/jpmobile/emoticon_spec.rb +137 -121
  70. data/spec/rack/jpmobile/filter_spec.rb +149 -128
  71. data/spec/rack/jpmobile/iphone_spec.rb +9 -8
  72. data/spec/rack/jpmobile/mobile_by_ua_spec.rb +22 -21
  73. data/spec/rack/jpmobile/params_filter_spec.rb +104 -96
  74. data/spec/rack/jpmobile/softbank_spec.rb +49 -42
  75. data/spec/rack/jpmobile/willcom_spec.rb +22 -18
  76. data/spec/rack/jpmobile/windows_phone.rb +5 -5
  77. data/spec/rack_helper.rb +9 -8
  78. data/spec/spec_helper.rb +5 -6
  79. data/spec/unit/decorated_mail_spec.rb +8 -9
  80. data/spec/unit/email_spec.rb +44 -44
  81. data/spec/unit/emoticon_spec.rb +57 -58
  82. data/spec/unit/encoding_spec.rb +35 -36
  83. data/spec/unit/is_carrier_spec.rb +49 -49
  84. data/spec/unit/mail_spec.rb +153 -143
  85. data/spec/unit/mobile/iphone_spec.rb +6 -7
  86. data/spec/unit/receive_mail_spec.rb +172 -173
  87. data/spec/unit/spec_helper.rb +6 -6
  88. data/spec/unit/util_spec.rb +125 -46
  89. data/spec/unit/valid_ip_spec.rb +35 -35
  90. data/spec/unit/variants_spec.rb +18 -19
  91. data/test/rails/overrides/Gemfile +54 -0
  92. data/test/rails/overrides/Gemfile.jpmobile +1 -2
  93. data/test/rails/overrides/app/controllers/admin/top_controller.rb +1 -1
  94. data/test/rails/overrides/app/controllers/docomo_guid_base_controller.rb +1 -1
  95. data/test/rails/overrides/app/controllers/filter_controller_base.rb +14 -6
  96. data/test/rails/overrides/app/controllers/hankaku_input_filter_controller.rb +1 -1
  97. data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
  98. data/test/rails/overrides/app/controllers/template_path_controller.rb +1 -2
  99. data/test/rails/overrides/app/controllers/trans_sid_base_controller.rb +18 -10
  100. data/test/rails/overrides/app/controllers/trans_sid_metal_controller.rb +0 -1
  101. data/test/rails/overrides/app/mailers/decorated_mailer.rb +3 -4
  102. data/test/rails/overrides/app/mailers/mobile_mailer.rb +5 -6
  103. data/test/rails/overrides/app/mailers/normal_mailer.rb +2 -3
  104. data/test/rails/overrides/autotest/discover.rb +2 -2
  105. data/test/rails/overrides/config/initializers/jpmobile_generator.rb +2 -2
  106. data/test/rails/overrides/config/routes.rb +95 -2
  107. data/test/rails/overrides/db/migrate/001_add_sessions_table.rb +2 -2
  108. data/test/rails/overrides/db/migrate/20100824062306_create_users.rb +1 -1
  109. data/test/rails/overrides/spec/controllers/docomo_guid_spec.rb +24 -25
  110. data/test/rails/overrides/spec/controllers/helpers_spec.rb +88 -88
  111. data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +9 -9
  112. data/test/rails/overrides/spec/controllers/template_path_spec.rb +19 -19
  113. data/test/rails/overrides/spec/features/admin/top_spec.rb +7 -7
  114. data/test/rails/overrides/spec/features/filter_spec.rb +101 -102
  115. data/test/rails/overrides/spec/helpers/helpers_spec.rb +4 -4
  116. data/test/rails/overrides/spec/mailers/decorated_mailer_spec.rb +12 -12
  117. data/test/rails/overrides/spec/mailers/mobile_mailer_spec.rb +209 -194
  118. data/test/rails/overrides/spec/mailers/normal_mailer_spec.rb +10 -10
  119. data/test/rails/overrides/spec/rails_helper.rb +1 -1
  120. data/test/rails/overrides/spec/requests/docomo_spec.rb +13 -13
  121. data/test/rails/overrides/spec/requests/emobile_spec.rb +19 -19
  122. data/test/rails/overrides/spec/requests/pc_spec.rb +6 -6
  123. data/test/rails/overrides/spec/requests/softbank_emulator_spec.rb +6 -6
  124. data/test/rails/overrides/spec/requests/template_path_spec.rb +60 -60
  125. data/test/rails/overrides/spec/requests/trans_sid_spec.rb +89 -89
  126. data/test/sinatra/test/filter_test.rb +10 -11
  127. data/tools/e4u_conv.rb +0 -1
  128. metadata +18 -14
  129. data/README +0 -0
  130. data/README.rdoc +0 -308
@@ -4,20 +4,20 @@ require 'rspec/its'
4
4
  $LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lib')))
5
5
  require 'jpmobile'
6
6
  begin
7
- require File.dirname(__FILE__)+'/../../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
7
+ require File.dirname(__FILE__) + '/../../vendor/jpmobile-ipaddresses/lib/jpmobile-ipaddresses'
8
8
  rescue LoadError
9
- puts "IP Address test requires jpmobile-ipaddresses module"
9
+ puts 'IP Address test requires jpmobile-ipaddresses module'
10
10
  end
11
11
  begin
12
- require File.dirname(__FILE__)+'/../../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
12
+ require File.dirname(__FILE__) + '/../../vendor/jpmobile-terminfo/lib/jpmobile-terminfo'
13
13
  rescue LoadError
14
- puts "Terminal display information test requires jpmobile-terminfo module"
14
+ puts 'Terminal display information test requires jpmobile-terminfo module'
15
15
  end
16
16
 
17
17
  RSpec.configure do |config|
18
- config.filter_run :focus => true
18
+ config.filter_run focus: true
19
19
  config.run_all_when_everything_filtered = true
20
20
  config.color = true
21
- config.filter_run_excluding :broken => true
21
+ config.filter_run_excluding broken: true
22
22
  # config.full_backtrace = true
23
23
  end
@@ -1,4 +1,3 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
3
2
  require 'stringio'
4
3
  require 'nkf'
@@ -7,62 +6,78 @@ describe Jpmobile::Util do
7
6
  include Jpmobile::Util
8
7
 
9
8
  describe 'utf8_to_sjis' do
10
- it "utf8_to_sjis で変換できない文字列が含んでいた場合?に変換される" do
11
- expect(utf8_to_sjis("اللغة العربية")).to eq(sjis("????? ???????"))
9
+ it 'utf8_to_sjis で変換できない文字列が含んでいた場合?に変換される' do
10
+ expect(utf8_to_sjis('اللغة العربية')).to eq(sjis('????? ???????'))
12
11
  end
13
12
 
14
- it "utf8_to_sjis ですべての改行コードが CRLF に変更されること" do
13
+ it 'utf8_to_sjis ですべての改行コードが CRLF に変更されること' do
15
14
  expect(utf8_to_sjis("UTF8\rSAMPLE\nTEXT\r\n")).to eq(sjis("UTF8\r\nSAMPLE\r\nTEXT\r\n"))
16
15
  end
17
16
 
18
- it "U+FFE3が0x8150に変換されること" do
19
- expect(utf8_to_sjis([0xffe3].pack("U"))).to eq(sjis("\x81\x50"))
17
+ it 'U+FFE3が0x8150に変換されること' do
18
+ expect(utf8_to_sjis([0xffe3].pack('U'))).to eq(sjis("\x81\x50"))
20
19
  end
21
20
 
22
- it "U+203Eが0x8150に変換されること" do
23
- expect(utf8_to_sjis([0x203e].pack("U"))).to eq(sjis("\x81\x50"))
21
+ it 'U+203Eが0x8150に変換されること' do
22
+ expect(utf8_to_sjis([0x203e].pack('U'))).to eq(sjis("\x81\x50"))
24
23
  end
25
24
 
26
- it "U+2014が0x815Cに変換されること" do
27
- expect(utf8_to_sjis([0x2014].pack("U"))).to eq(sjis("\x81\x5C"))
25
+ it 'U+2014が0x815Cに変換されること' do
26
+ expect(utf8_to_sjis([0x2014].pack('U'))).to eq(sjis("\x81\x5C"))
28
27
  end
29
28
 
30
- it "U+2212が0x817Cに変換されること" do
31
- expect(utf8_to_sjis([0x2212].pack("U"))).to eq(sjis("\x81\x7C"))
29
+ it 'U+2212が0x817Cに変換されること' do
30
+ expect(utf8_to_sjis([0x2212].pack('U'))).to eq(sjis("\x81\x7C"))
32
31
  end
33
32
 
34
- it "utf8_to_sjis で変換できない文字列が含んでいた場合?に変換される" do
35
- expect(utf8_to_jis("اللغة العربية")).to eq(jis("????? ???????"))
33
+ it 'utf8_to_sjis で変換できない文字列が含んでいた場合?に変換される' do
34
+ expect(utf8_to_jis('اللغة العربية')).to eq(jis('????? ???????'))
35
+ end
36
+
37
+ it 'frozenでも通過すること' do
38
+ expect { utf8_to_jis('漢字'.freeze) }.not_to raise_error
36
39
  end
37
40
  end
38
41
 
39
42
  describe 'sjis_to_utf8' do
40
- it "0x8150がU+FFE3に変換されること" do
41
- expect(sjis_to_utf8(sjis("\x81\x50"))).to eq([0xffe3].pack("U"))
43
+ it '0x8150がU+FFE3に変換されること' do
44
+ expect(sjis_to_utf8(sjis("\x81\x50"))).to eq([0xffe3].pack('U'))
42
45
  end
43
46
 
44
- it "sjis_to_utf8 ですべての改行コードが LF に変更されること" do
47
+ it 'sjis_to_utf8 ですべての改行コードが LF に変更されること' do
45
48
  expect(sjis_to_utf8("SJIS\rSAMPLE\nTEXT\r\n")).to eq(utf8("SJIS\nSAMPLE\nTEXT\n"))
46
49
  end
50
+
51
+ it 'frozenでも通過すること' do
52
+ expect { sjis_to_utf8('漢字'.encode('SJIS').freeze) }.not_to raise_error
53
+ end
47
54
  end
48
55
 
49
56
  describe 'utf8_to_jis' do
50
- it "utf8_to_jis ですべての改行コードが CRLF に変更されること" do
57
+ it 'utf8_to_jis ですべての改行コードが CRLF に変更されること' do
51
58
  expect(utf8_to_jis("UTF8\rSAMPLE\nTEXT\r\n")).to eq(jis("UTF8\r\nSAMPLE\r\nTEXT\r\n"))
52
59
  end
60
+
61
+ it 'frozenでも通過すること' do
62
+ expect { utf8_to_jis('漢字'.freeze) }.not_to raise_error
63
+ end
53
64
  end
54
65
 
55
66
  describe 'jis_string_regexp' do
56
- it "jis_string_regexpでISO-2022-JPの文字列がマッチすること" do
57
- expect(jis_string_regexp.match(ascii_8bit(utf8_to_jis("abcしからずんばこじをえずdef")))).not_to be_nil
58
- expect(jis_to_utf8(jis("\x1b\x24\x42#{$1}\x1b\x28\x42"))).to eq("しからずんばこじをえず")
67
+ it 'jis_string_regexpでISO-2022-JPの文字列がマッチすること' do
68
+ expect(jis_string_regexp.match(ascii_8bit(utf8_to_jis('abcしからずんばこじをえずdef')))).not_to be_nil
69
+ expect(jis_to_utf8(jis("\x1b\x24\x42#{Regexp.last_match(1)}\x1b\x28\x42"))).to eq('しからずんばこじをえず')
59
70
  end
60
71
  end
61
72
 
62
73
  describe 'jis_to_utf8' do
63
- it "jis_to_utf8 ですべての改行コードが LF に変更されること" do
74
+ it 'jis_to_utf8 ですべての改行コードが LF に変更されること' do
64
75
  expect(jis_to_utf8("JIS\rSAMPLE\nTEXT\r\n")).to eq(utf8("JIS\nSAMPLE\nTEXT\n"))
65
76
  end
77
+
78
+ it 'frozenでも通過すること' do
79
+ expect { jis_to_utf8('漢字'.encode('ISO-2022-JP').freeze) }.not_to raise_error
80
+ end
66
81
  end
67
82
 
68
83
  describe '#force_encode' do
@@ -71,59 +86,123 @@ describe Jpmobile::Util do
71
86
  end
72
87
 
73
88
  it 'does not enter infinite loop on retry' do
74
- expect{ force_encode("\e\x28\x49\x9a\x43\x3D\x44\e\x28\x42".force_encoding('ISO-2022-JP'), 'iso-2022-jp', 'UTF-8') }.to raise_error ::Encoding::InvalidByteSequenceError
89
+ expect { force_encode("\e\x28\x49\x9a\x43\x3D\x44\e\x28\x42".force_encoding('ISO-2022-JP'), 'iso-2022-jp', 'UTF-8') }.to raise_error ::Encoding::InvalidByteSequenceError
90
+ end
91
+
92
+ it 'frozenでも通過すること' do
93
+ expect { force_encode('漢字'.encode('ISO-2022-JP').freeze, 'iso-2022-jp', 'UTF-8') }.not_to raise_error
94
+ end
95
+ end
96
+
97
+ describe '#fold_text' do
98
+ it 'UTF-8の日本語文字列が指定文字数で折り返された配列で返ること' do
99
+ expect(fold_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15)).
100
+ to eq(
101
+ %w[
102
+ 長い日本語の題名で折り返される
103
+ かようにするには事前に分割して
104
+ いないとダメなことがわかりまし
105
+ たよ
106
+ ]
107
+ )
108
+ end
109
+
110
+ it 'UTF-8の短い文字列は折り返されないこと' do
111
+ expect(fold_text('短い', 15)).to eq(['短い'])
112
+ end
113
+
114
+ it 'frozenでも通過すること' do
115
+ expect { fold_text(('漢字' * 10).freeze, 15) }.not_to raise_error
75
116
  end
76
117
  end
77
118
 
78
- it "fold_textでUTF-8の日本語文字列が指定文字数で折り返された配列で返ること" do
79
- expect(fold_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15)).to eq([
80
- '長い日本語の題名で折り返される',
81
- 'かようにするには事前に分割して',
82
- 'いないとダメなことがわかりまし',
83
- 'たよ'
84
- ])
119
+ describe '#split_text' do
120
+ it 'UTF-8の日本語文字列が指定文字数で2つに分割されること' do
121
+ expect(split_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15)).
122
+ to eq(
123
+ %w[
124
+ 長い日本語の題名で折り返される
125
+ かようにするには事前に分割していないとダメなことがわかりましたよ
126
+ ]
127
+ )
128
+ end
129
+
130
+ it 'nilかblankの場合はnilが返ること' do
131
+ expect(split_text('', 15)).to be_nil
132
+ expect(split_text(nil, 15)).to be_nil
133
+ end
134
+
135
+ it 'frozenでも通過すること' do
136
+ expect { split_text(('漢字' * 10).freeze, 15) }.not_to raise_error
137
+ end
85
138
  end
86
139
 
87
- it "fold_textでUTF-8の短い文字列は折り返されないこと" do
88
- expect(fold_text('短い', 15)).to eq(['短い'])
140
+ describe '#sjis' do
141
+ it 'frozenでも通過すること' do
142
+ expect { sjis('漢字'.freeze) }.not_to raise_error
143
+ end
89
144
  end
90
145
 
91
- it "split_textでUTF-8の日本語文字列が指定文字数で2つに分割されること" do
92
- expect(split_text('長い日本語の題名で折り返されるかようにするには事前に分割していないとダメなことがわかりましたよ', 15)).to eq([
93
- '長い日本語の題名で折り返される',
94
- 'かようにするには事前に分割していないとダメなことがわかりましたよ'
95
- ])
146
+ describe '#utf8' do
147
+ it 'frozenでも通過すること' do
148
+ expect { utf8('漢字'.freeze) }.not_to raise_error
149
+ end
96
150
  end
97
151
 
98
- it "split_textでnilかblankの場合はnilが返ること" do
99
- expect(split_text('', 15)).to be_nil
100
- expect(split_text(nil, 15)).to be_nil
152
+ describe '#jis' do
153
+ it 'frozenでも通過すること' do
154
+ expect { jis('漢字'.freeze) }.not_to raise_error
155
+ end
156
+ end
157
+
158
+ describe '#jis_win' do
159
+ it 'frozenでも通過すること' do
160
+ expect { jis_win('漢字'.freeze) }.not_to raise_error
161
+ end
162
+ end
163
+
164
+ describe '#ascii_8bit' do
165
+ it 'frozenでも通過すること' do
166
+ expect { ascii_8bit('漢字'.freeze) }.not_to raise_error
167
+ end
168
+ end
169
+
170
+ describe '#ascii_compatible!' do
171
+ it 'frozenでも通過すること' do
172
+ expect { ascii_compatible!('漢字'.freeze) }.not_to raise_error
173
+ end
101
174
  end
102
175
 
103
- it "全角チルダがjisに適切に変換されること" do
176
+ it '全角チルダがjisに適切に変換されること' do
104
177
  expect(ascii_8bit(utf8_to_jis("\xef\xbd\x9e"))).to eq(ascii_8bit("\x1b\x24\x42\x21\x41\x1b\x28\x42"))
105
- expect(ascii_8bit(encode("\xef\xbd\x9e", "ISO-2022-JP"))).to eq(ascii_8bit("\x1b\x24\x42\x21\x41\x1b\x28\x42"))
178
+ expect(ascii_8bit(encode("\xef\xbd\x9e", 'ISO-2022-JP'))).to eq(ascii_8bit("\x1b\x24\x42\x21\x41\x1b\x28\x42"))
106
179
  end
107
180
 
108
181
  describe 'invert_table' do
109
182
  it 'pickups the first(least) of duplicated values when inverting hash table' do
110
- hash = invert_table({
183
+ hash = invert_table(
184
+ {
111
185
  0xFE009 => 0xE63E,
112
186
  0xFE00A => 0xE63E,
113
187
  0xFE00B => 0x3013,
114
188
  0xFE010 => 0xE6B3,
115
- 0xFE038 => 0xE73F})
189
+ 0xFE038 => 0xE73F,
190
+ }
191
+ )
116
192
  expect(hash[0xE63E]).to eq(0xFE009)
117
193
  expect(hash[0x3013]).to eq(0xFE00B)
118
194
  end
119
195
 
120
196
  it 'should not raise error when hash has Array keys' do
121
- hash = invert_table({
197
+ hash = invert_table(
198
+ {
122
199
  [0x1F1E8, 0x1F1F3] => 0x3013,
123
200
  0x1F1FF => 0x3013,
124
201
  0x1F526 => 0xE6FB,
125
202
  [0x0023, 0x20E3] => 0xE6E0,
126
- 0x1F354 => 0xE673})
203
+ 0x1F354 => 0xE673,
204
+ }
205
+ )
127
206
  expect(hash[0x3013]).to eq([0x1F1E8, 0x1F1F3])
128
207
  expect(hash[0xE6FB]).to eq(0x1F526)
129
208
  end
@@ -2,47 +2,47 @@ require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
2
2
 
3
3
  describe 'Jpmobile::Mobile::valid_ip?' do
4
4
  [
5
- [ '210.153.84.1' , :Docomo ],
6
- [ '210.153.84.254' , :Docomo ],
7
- [ '210.230.128.225' , :Au ],
8
- [ '210.230.128.238' , :Au ],
9
- [ '123.108.237.1' , :Softbank ],
10
- [ '123.108.237.31' , :Softbank ],
11
- [ '123.108.237.1' , :Vodafone ],
12
- [ '123.108.237.31' , :Vodafone ],
13
- [ '61.198.142.1' , :Willcom ],
14
- [ '61.198.142.254' , :Willcom ],
15
- [ '61.198.142.1' , :Ddipocket ],
16
- [ '61.198.142.254' , :Ddipocket ],
17
- [ '117.55.1.224' , :Emobile ],
18
- [ '117.55.1.254' , :Emobile ],
5
+ ['210.153.84.1', :Docomo],
6
+ ['210.153.84.254', :Docomo],
7
+ ['210.230.128.225', :Au],
8
+ ['210.230.128.238', :Au],
9
+ ['123.108.237.1', :Softbank],
10
+ ['123.108.237.31', :Softbank],
11
+ ['123.108.237.1', :Vodafone],
12
+ ['123.108.237.31', :Vodafone],
13
+ ['61.198.142.1', :Willcom],
14
+ ['61.198.142.254', :Willcom],
15
+ ['61.198.142.1', :Ddipocket],
16
+ ['61.198.142.254', :Ddipocket],
17
+ ['117.55.1.224', :Emobile],
18
+ ['117.55.1.254', :Emobile],
19
19
  ].each do |remote_ip, carrier|
20
- it "should be return true if #{remote_ip} is in #{:carrier} address" do
20
+ it "should be return true if #{remote_ip} is in #{carrier} address" do
21
21
  expect(Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip)).to eq(true)
22
22
  end
23
23
  end
24
24
 
25
25
  [
26
- [ '127.0.0.1' , :Docomo ],
27
- [ '210.153.83.1' , :Docomo ],
28
- [ '210.153.83.254' , :Docomo ],
29
- [ '127.0.0.1' , :Au ],
30
- [ '210.169.41.1' , :Au ],
31
- [ '210.169.41.254' , :Au ],
32
- [ '127.0.0.1' , :Softbank ],
33
- [ '123.108.238.1' , :Softbank ],
34
- [ '123.108.238.254' , :Softbank ],
35
- [ '127.0.0.1' , :Vodafone ],
36
- [ '123.108.238.1' , :Vodafone ],
37
- [ '123.108.238.254' , :Vodafone ],
38
- [ '127.0.0.1' , :Willcom ],
39
- [ '61.198.144.1' , :Willcom ],
40
- [ '61.198.144.254' , :Willcom ],
41
- [ '127.0.0.1' , :Ddipocket ],
42
- [ '61.198.144.1' , :Ddipocket ],
43
- [ '61.198.144.254' , :Ddipocket ],
44
- [ '127.0.0.1' , :Emobile ],
45
- [ '117.55.1.223' , :Emobile ],
26
+ ['127.0.0.1', :Docomo],
27
+ ['210.153.83.1', :Docomo],
28
+ ['210.153.83.254', :Docomo],
29
+ ['127.0.0.1', :Au],
30
+ ['210.169.41.1', :Au],
31
+ ['210.169.41.254', :Au],
32
+ ['127.0.0.1', :Softbank],
33
+ ['123.108.238.1', :Softbank],
34
+ ['123.108.238.254', :Softbank],
35
+ ['127.0.0.1', :Vodafone],
36
+ ['123.108.238.1', :Vodafone],
37
+ ['123.108.238.254', :Vodafone],
38
+ ['127.0.0.1', :Willcom],
39
+ ['61.198.144.1', :Willcom],
40
+ ['61.198.144.254', :Willcom],
41
+ ['127.0.0.1', :Ddipocket],
42
+ ['61.198.144.1', :Ddipocket],
43
+ ['61.198.144.254', :Ddipocket],
44
+ ['127.0.0.1', :Emobile],
45
+ ['117.55.1.223', :Emobile],
46
46
  ].each do |remote_ip, carrier|
47
47
  it 'should not be return true if #{:remote_ip} is in #{carrier} address' do
48
48
  expect(Jpmobile::Mobile.const_get(carrier).valid_ip?(remote_ip)).not_to eq(true)
@@ -1,15 +1,14 @@
1
- # -*- coding: utf-8 -*-
2
1
  require File.expand_path(File.join(File.dirname(__FILE__), 'spec_helper'))
3
2
  require 'mail'
4
3
  require 'jpmobile/mail'
5
4
 
6
5
  describe Jpmobile::Mobile::AbstractMobile do
7
- subject{ Jpmobile::Mobile::AbstractMobile.new(nil, nil) }
6
+ subject { Jpmobile::Mobile::AbstractMobile.new(nil, nil) }
8
7
 
9
8
  describe '#variants' do
10
9
  describe '#variants' do
11
10
  subject { super().variants }
12
- it { is_expected.to be === ['mobile'] }
11
+ it { is_expected.to eq(['mobile']) }
13
12
  end
14
13
  end
15
14
 
@@ -22,12 +21,12 @@ describe Jpmobile::Mobile::AbstractMobile do
22
21
  end
23
22
 
24
23
  describe Jpmobile::Mobile::Docomo do
25
- subject{ Jpmobile::Mobile::Docomo.new(nil, nil) }
24
+ subject { Jpmobile::Mobile::Docomo.new(nil, nil) }
26
25
 
27
26
  describe '#variants' do
28
27
  describe '#variants' do
29
28
  subject { super().variants }
30
- it { is_expected.to eq(['mobile_docomo', 'mobile']) }
29
+ it { is_expected.to eq(%w[mobile_docomo mobile]) }
31
30
  end
32
31
  end
33
32
 
@@ -39,12 +38,12 @@ describe Jpmobile::Mobile::Docomo do
39
38
  end
40
39
 
41
40
  describe Jpmobile::Mobile::Au do
42
- subject{ Jpmobile::Mobile::Au.new(nil, nil) }
41
+ subject { Jpmobile::Mobile::Au.new(nil, nil) }
43
42
 
44
43
  describe '#variants' do
45
44
  describe '#variants' do
46
45
  subject { super().variants }
47
- it { is_expected.to eq(['mobile_au', 'mobile']) }
46
+ it { is_expected.to eq(%w[mobile_au mobile]) }
48
47
  end
49
48
  end
50
49
 
@@ -56,12 +55,12 @@ describe Jpmobile::Mobile::Au do
56
55
  end
57
56
 
58
57
  describe Jpmobile::Mobile::Softbank do
59
- subject{ Jpmobile::Mobile::Softbank.new(nil, nil) }
58
+ subject { Jpmobile::Mobile::Softbank.new(nil, nil) }
60
59
 
61
60
  describe '#variants' do
62
61
  describe '#variants' do
63
62
  subject { super().variants }
64
- it { is_expected.to eq(['mobile_softbank', 'mobile']) }
63
+ it { is_expected.to eq(%w[mobile_softbank mobile]) }
65
64
  end
66
65
  end
67
66
 
@@ -73,12 +72,12 @@ describe Jpmobile::Mobile::Softbank do
73
72
  end
74
73
 
75
74
  describe Jpmobile::Mobile::Android do
76
- subject{ Jpmobile::Mobile::Android.new(nil, nil) }
75
+ subject { Jpmobile::Mobile::Android.new(nil, nil) }
77
76
 
78
77
  describe '#variants' do
79
78
  describe '#variants' do
80
79
  subject { super().variants }
81
- it { is_expected.to eq(['smart_phone_android', 'smart_phone']) }
80
+ it { is_expected.to eq(%w[smart_phone_android smart_phone]) }
82
81
  end
83
82
  end
84
83
 
@@ -90,12 +89,12 @@ describe Jpmobile::Mobile::Android do
90
89
  end
91
90
 
92
91
  describe Jpmobile::Mobile::AndroidTablet do
93
- subject{ Jpmobile::Mobile::AndroidTablet.new(nil, nil) }
92
+ subject { Jpmobile::Mobile::AndroidTablet.new(nil, nil) }
94
93
 
95
94
  describe '#variants' do
96
95
  describe '#variants' do
97
96
  subject { super().variants }
98
- it { is_expected.to eq(['tablet_android_tablet', 'tablet', 'smart_phone']) }
97
+ it { is_expected.to eq(%w[tablet_android_tablet tablet smart_phone]) }
99
98
  end
100
99
  end
101
100
 
@@ -107,12 +106,12 @@ describe Jpmobile::Mobile::AndroidTablet do
107
106
  end
108
107
 
109
108
  describe Jpmobile::Mobile::Iphone do
110
- subject{ Jpmobile::Mobile::Iphone.new(nil, nil) }
109
+ subject { Jpmobile::Mobile::Iphone.new(nil, nil) }
111
110
 
112
111
  describe '#variants' do
113
112
  describe '#variants' do
114
113
  subject { super().variants }
115
- it { is_expected.to eq(['smart_phone_iphone', 'smart_phone']) }
114
+ it { is_expected.to eq(%w[smart_phone_iphone smart_phone]) }
116
115
  end
117
116
  end
118
117
 
@@ -124,12 +123,12 @@ describe Jpmobile::Mobile::Iphone do
124
123
  end
125
124
 
126
125
  describe Jpmobile::Mobile::Ipad do
127
- subject{ Jpmobile::Mobile::Ipad.new(nil, nil) }
126
+ subject { Jpmobile::Mobile::Ipad.new(nil, nil) }
128
127
 
129
128
  describe '#variants' do
130
129
  describe '#variants' do
131
130
  subject { super().variants }
132
- it { is_expected.to eq(['tablet_ipad', 'tablet', 'smart_phone']) }
131
+ it { is_expected.to eq(%w[tablet_ipad tablet smart_phone]) }
133
132
  end
134
133
  end
135
134
 
@@ -141,12 +140,12 @@ describe Jpmobile::Mobile::Ipad do
141
140
  end
142
141
 
143
142
  describe Jpmobile::Mobile::WindowsPhone do
144
- subject{ Jpmobile::Mobile::WindowsPhone.new(nil, nil) }
143
+ subject { Jpmobile::Mobile::WindowsPhone.new(nil, nil) }
145
144
 
146
145
  describe '#variants' do
147
146
  describe '#variants' do
148
147
  subject { super().variants }
149
- it { is_expected.to eq(['smart_phone_windows_phone', 'smart_phone']) }
148
+ it { is_expected.to eq(%w[smart_phone_windows_phone smart_phone]) }
150
149
  end
151
150
  end
152
151