jpmobile 0.1.6 → 1.0.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/README +0 -0
- data/README.rdoc +58 -29
- data/Rakefile +1 -1
- data/VERSION.yml +4 -4
- data/lib/jpmobile.rb +3 -0
- data/lib/jpmobile/email.rb +17 -2
- data/lib/jpmobile/emoticon.rb +87 -23
- data/lib/jpmobile/emoticon/au.rb +644 -0
- data/lib/jpmobile/emoticon/softbank.rb +488 -0
- data/lib/jpmobile/emoticon/z_combine.rb +16 -13
- data/lib/jpmobile/hook_action_controller.rb +1 -13
- data/lib/jpmobile/hook_action_view.rb +3 -62
- data/lib/jpmobile/mail.rb +316 -0
- data/lib/jpmobile/mailer.rb +31 -0
- data/lib/jpmobile/mobile/abstract_mobile.rb +66 -0
- data/lib/jpmobile/mobile/au.rb +25 -2
- data/lib/jpmobile/mobile/docomo.rb +23 -1
- data/lib/jpmobile/mobile/emobile.rb +1 -1
- data/lib/jpmobile/mobile/softbank.rb +33 -1
- data/lib/jpmobile/mobile/vodafone.rb +1 -1
- data/lib/jpmobile/mobile/willcom.rb +1 -1
- data/lib/jpmobile/path_set.rb +40 -0
- data/lib/jpmobile/rails.rb +24 -0
- data/lib/jpmobile/resolver.rb +38 -0
- data/lib/jpmobile/util.rb +223 -14
- data/lib/tasks/jpmobile_tasks.rake +41 -48
- data/spec/rack/jpmobile/emoticon_spec.rb +3 -8
- data/spec/rack/jpmobile/filter_spec.rb +1 -1
- data/spec/rack/jpmobile/params_filter_spec.rb +4 -4
- data/spec/rack_helper.rb +5 -9
- data/spec/unit/detect_by_email_spec.rb +29 -0
- data/spec/unit/emoticon_spec.rb +90 -0
- data/spec/unit/encoding_spec.rb +102 -0
- data/spec/unit/mail_spec.rb +117 -0
- data/spec/unit/receive_mail_spec.rb +289 -0
- data/spec/unit/spec_helper.rb +8 -0
- data/spec/unit/util_spec.rb +5 -0
- data/test/rails/overrides/app/controllers/application_controller.rb +3 -2
- data/test/rails/overrides/app/controllers/template_path_controller.rb +8 -0
- data/test/rails/overrides/app/models/mobile_mailer.rb +19 -0
- data/test/rails/overrides/app/models/normal_mailer.rb +9 -0
- data/test/rails/overrides/spec/models/mobile_mailer_spec.rb +737 -0
- data/test/rails/overrides/spec/models/normal_mailer_spec.rb +34 -0
- data/test/rails/overrides/spec/requests/template_path_spec.rb +13 -7
- data/test/rails/overrides/spec/spec_helper.rb +6 -0
- data/test/rails/rails_root/app/controllers/application_controller.rb +3 -2
- data/test/rails/rails_root/app/controllers/template_path_controller.rb +8 -0
- data/test/rails/rails_root/app/models/mobile_mailer.rb +2 -1
- data/test/rails/rails_root/app/models/normal_mailer.rb +9 -0
- data/test/rails/rails_root/config/initializers/secret_token.rb +1 -1
- data/test/rails/rails_root/spec/models/mobile_mailer_spec.rb +73 -80
- data/test/rails/rails_root/spec/models/normal_mailer_spec.rb +34 -0
- data/test/rails/rails_root/spec/requests/template_path_spec.rb +13 -7
- data/test/rails/rails_root/spec/spec_helper.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile.rb +2 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/emoticon.rb +7 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_controller.rb +1 -13
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_view.rb +3 -62
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mail.rb +162 -111
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mailer.rb +31 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/abstract_mobile.rb +34 -3
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/au.rb +2 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/docomo.rb +4 -5
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/mobile/softbank.rb +7 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/path_set.rb +40 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rack/params_filter.rb +1 -1
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/rails.rb +24 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/resolver.rb +38 -0
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/util.rb +33 -23
- metadata +43 -14
- data/test/legacy/emoticon_test.rb +0 -63
- data/test/legacy/helper.rb +0 -8
- data/test/rails/rails_root/vendor/plugins/jpmobile/lib/jpmobile/hook_action_mailer.rb +0 -22
@@ -29,61 +29,56 @@ rescue LoadError
|
|
29
29
|
end
|
30
30
|
|
31
31
|
namespace :test do
|
32
|
-
desc "run jpmobile legacy tests"
|
33
|
-
Rake::TestTask.new(:legacy) do |t|
|
34
|
-
t.libs << 'lib'
|
35
|
-
t.pattern = 'test/legacy/**/*_test.rb'
|
36
|
-
t.verbose = true
|
37
|
-
end
|
38
32
|
desc "Generate rails app and run jpmobile tests in the app"
|
39
|
-
task :rails, [:
|
33
|
+
task :rails, [:skip] do |t, args|
|
40
34
|
rails_root = "test/rails/rails_root"
|
41
35
|
relative_root = "../../../"
|
42
|
-
rails_versions = args.versions.split("/") rescue ["3.0.x"]
|
43
36
|
|
44
|
-
puts "Running tests in Rails
|
37
|
+
puts "Running tests in Rails"
|
38
|
+
skip = args.skip == "true"
|
45
39
|
|
46
|
-
|
47
|
-
puts " for #{rails_version}"
|
40
|
+
unless skip
|
48
41
|
# generate rails app
|
49
42
|
FileUtils.rm_rf(rails_root)
|
50
43
|
FileUtils.mkdir_p(rails_root)
|
51
|
-
|
44
|
+
`rails new #{rails_root}`
|
45
|
+
end
|
52
46
|
|
53
|
-
|
54
|
-
|
47
|
+
# setup jpmobile
|
48
|
+
plugin_path = File.join(rails_root, 'vendor', 'plugins', 'jpmobile')
|
49
|
+
FileUtils.mkdir_p(plugin_path)
|
50
|
+
FileList["*"].exclude("test").exclude("spec").each do |file|
|
51
|
+
FileUtils.cp_r(file, plugin_path)
|
52
|
+
end
|
53
|
+
|
54
|
+
# setup jpmobile-ipaddresses
|
55
|
+
begin
|
56
|
+
plugin_path = File.join(rails_root, 'vendor', 'plugins', 'jpmobile-ipaddresses')
|
55
57
|
FileUtils.mkdir_p(plugin_path)
|
56
|
-
FileList["
|
58
|
+
FileList["vendor/jpmobile-ipaddresses/*"].exclude("test").each do |file|
|
57
59
|
FileUtils.cp_r(file, plugin_path)
|
58
60
|
end
|
61
|
+
rescue LoadError
|
62
|
+
puts "IP Address test requires jpmobile-ipaddresses module"
|
63
|
+
end
|
59
64
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
end
|
67
|
-
rescue LoadError
|
68
|
-
puts "IP Address test requires jpmobile-ipaddresses module"
|
69
|
-
end
|
70
|
-
|
71
|
-
# setup jpmobile-terminfo
|
72
|
-
begin
|
73
|
-
plugin_path = File.join(rails_root, 'vendor', 'plugins', 'jpmobile-terminfo')
|
74
|
-
FileUtils.mkdir_p(plugin_path)
|
75
|
-
FileList["vendor/jpmobile-terminfo/*"].exclude("test").each do |file|
|
76
|
-
FileUtils.cp_r(file, plugin_path)
|
77
|
-
end
|
78
|
-
rescue LoadError
|
79
|
-
puts "Terminal display information test requires jpmobile-terminfo module"
|
65
|
+
# setup jpmobile-terminfo
|
66
|
+
begin
|
67
|
+
plugin_path = File.join(rails_root, 'vendor', 'plugins', 'jpmobile-terminfo')
|
68
|
+
FileUtils.mkdir_p(plugin_path)
|
69
|
+
FileList["vendor/jpmobile-terminfo/*"].exclude("test").each do |file|
|
70
|
+
FileUtils.cp_r(file, plugin_path)
|
80
71
|
end
|
72
|
+
rescue LoadError
|
73
|
+
puts "Terminal display information test requires jpmobile-terminfo module"
|
74
|
+
end
|
81
75
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
76
|
+
# setup tests
|
77
|
+
FileList["test/rails/overrides/*"].each do |file|
|
78
|
+
FileUtils.cp_r(file, rails_root)
|
79
|
+
end
|
86
80
|
|
81
|
+
unless skip
|
87
82
|
# for cookie_only option
|
88
83
|
config_path = File.join(rails_root, 'config', 'initializers', 'session_store.rb')
|
89
84
|
File.open(config_path, 'w') do |file|
|
@@ -92,16 +87,14 @@ Rails.application.config.session_store :active_record_store, :key => '_session_i
|
|
92
87
|
Rails.application.config.session_options = {:cookie_only => false}
|
93
88
|
END
|
94
89
|
end
|
95
|
-
|
96
|
-
# run tests in rails
|
97
|
-
cd rails_root
|
98
|
-
# ruby "-S bundle install"
|
99
|
-
ruby "-S rake db:migrate test"
|
100
|
-
ruby "-S rake spec"
|
101
|
-
# ruby "-S rspec -b --color spec/requests/filter_spec.rb -e 'jpmobile integration spec HankakuInputFilterController SoftBank 910T からのアクセス it should behave like hankaku_filter :input => true のとき はtextareaの中では半角に変換されないこと'"
|
102
|
-
|
103
|
-
cd relative_root
|
104
90
|
end
|
91
|
+
|
92
|
+
# run tests in rails
|
93
|
+
cd rails_root
|
94
|
+
# ruby "-S bundle install"
|
95
|
+
ruby "-S rake db:migrate test" unless skip
|
96
|
+
ruby "-S rake spec"
|
97
|
+
# ruby "-S rspec -b --color spec/requests/filter_spec.rb -e 'jpmobile integration spec HankakuInputFilterController SoftBank 910T からのアクセス it should behave like hankaku_filter :input => true のとき はtextareaの中では半角に変換されないこと'"
|
105
98
|
end
|
106
99
|
desc "Run sinatra on jpmobile tests"
|
107
100
|
Rake::TestTask.new(:sinatra) do |t|
|
@@ -4,6 +4,7 @@ require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.r
|
|
4
4
|
describe "絵文字が" do
|
5
5
|
include Rack::Test::Methods
|
6
6
|
include Jpmobile::RackHelper
|
7
|
+
include Jpmobile::Util
|
7
8
|
|
8
9
|
before(:each) do
|
9
10
|
@docomo_cr = "";
|
@@ -77,10 +78,7 @@ describe "絵文字が" do
|
|
77
78
|
end
|
78
79
|
|
79
80
|
it "パラメータが変換されること" do
|
80
|
-
query_string = "q=" + URI.encode(sjis("\xf8\x9f"))
|
81
|
-
if query_string.respond_to?(:force_encoding)
|
82
|
-
query_string.force_encoding("ASCII-8BIT")
|
83
|
-
end
|
81
|
+
query_string = ascii_8bit("q=" + URI.encode(sjis("\xf8\x9f")))
|
84
82
|
|
85
83
|
res = Rack::MockRequest.env_for(
|
86
84
|
"/?#{query_string}",
|
@@ -127,10 +125,7 @@ describe "絵文字が" do
|
|
127
125
|
end
|
128
126
|
|
129
127
|
it "パラメータが変換されること" do
|
130
|
-
query_string = "q=" + URI.encode(sjis("\xf6\x60"))
|
131
|
-
if query_string.respond_to?(:force_encoding)
|
132
|
-
query_string.force_encoding("ASCII-8BIT")
|
133
|
-
end
|
128
|
+
query_string = ascii_8bit("q=" + URI.encode(sjis("\xf6\x60")))
|
134
129
|
|
135
130
|
res = Rack::MockRequest.env_for(
|
136
131
|
"/?#{query_string}",
|
@@ -10,21 +10,21 @@ describe Jpmobile::Rack::ParamsFilter do
|
|
10
10
|
before(:each) do
|
11
11
|
@query_params = {
|
12
12
|
"hoge" => "ほげ",
|
13
|
-
"パラメータ" => "
|
13
|
+
"パラメータ" => "テストです〜■",
|
14
14
|
}
|
15
15
|
@form_params = {
|
16
16
|
"bar" => "万葉集",
|
17
|
-
"アジャイル" => "
|
17
|
+
"アジャイル" => "僕の〜♪",
|
18
18
|
}
|
19
19
|
end
|
20
20
|
|
21
21
|
context "Shift_JIS 変換の " do
|
22
22
|
before(:each) do
|
23
23
|
@query_string = @query_params.map {|k, v|
|
24
|
-
"%s=%s" % [::Rack::Utils.escape(
|
24
|
+
"%s=%s" % [::Rack::Utils.escape(utf8_to_sjis(k)), ::Rack::Utils.escape(utf8_to_sjis(v))]
|
25
25
|
}.join("&")
|
26
26
|
@form_string = @form_params.map {|k, v|
|
27
|
-
"%s=%s" % [
|
27
|
+
"%s=%s" % [utf8_to_sjis(k), utf8_to_sjis(v)]
|
28
28
|
}.join("&")
|
29
29
|
end
|
30
30
|
|
data/spec/rack_helper.rb
CHANGED
@@ -19,15 +19,14 @@ rescue LoadError
|
|
19
19
|
end
|
20
20
|
|
21
21
|
RSpec.configure do |config|
|
22
|
-
config.
|
22
|
+
config.filter_run :focus => true
|
23
|
+
config.run_all_when_everything_filtered = true
|
24
|
+
config.color_enabled = true
|
23
25
|
end
|
24
26
|
|
25
27
|
class UnitApplication
|
26
28
|
def initialize(body = nil)
|
27
|
-
@body = body || "Body"
|
28
|
-
if @body.respond_to?(:force_encoding)
|
29
|
-
@body.force_encoding("UTF-8")
|
30
|
-
end
|
29
|
+
@body = Jpmobile::Util.utf8(body || "Body")
|
31
30
|
end
|
32
31
|
|
33
32
|
def call(env)
|
@@ -53,10 +52,7 @@ end
|
|
53
52
|
class RenderParamApp
|
54
53
|
def call(env)
|
55
54
|
request = Rack::Request.new(env)
|
56
|
-
q = request.params['q']
|
57
|
-
if q.respond_to?(:force_encoding)
|
58
|
-
q.force_encoding("UTF-8")
|
59
|
-
end
|
55
|
+
q = Jpmobile::Util.utf8(request.params['q'])
|
60
56
|
|
61
57
|
[200, env, q]
|
62
58
|
end
|
@@ -11,6 +11,8 @@ describe 'Jpmobile::Email' do
|
|
11
11
|
['dadaea@pdx.ne.jp.jp' , nil ],
|
12
12
|
['xxxe@dj.pdx.ne.jp' , Jpmobile::Mobile::Willcom ],
|
13
13
|
['xxxe@dj.pdx.ne.jp.jp' , nil ],
|
14
|
+
['xxxe@willcom.com' , Jpmobile::Mobile::Willcom ],
|
15
|
+
['xxxe@willcom.com.jp' , nil ],
|
14
16
|
['oeeikx@softbank.ne.jp' , Jpmobile::Mobile::Softbank ],
|
15
17
|
['oeeikx@softbank.ne.jp.jp' , nil ],
|
16
18
|
['eaae@disney.ne.jp' , Jpmobile::Mobile::Softbank ],
|
@@ -22,4 +24,31 @@ describe 'Jpmobile::Email' do
|
|
22
24
|
Jpmobile::Email.detect(email_addr).should == carrier
|
23
25
|
end
|
24
26
|
end
|
27
|
+
|
28
|
+
[
|
29
|
+
['From: Jpmobile Rails <example@example.ne.jp>' , nil ],
|
30
|
+
['From: Jpmobile Rails <test@docomo.ne.jp>' , Jpmobile::Mobile::Docomo ],
|
31
|
+
['From: test@docomo.ne.jp' , Jpmobile::Mobile::Docomo ],
|
32
|
+
['From: Jpmobile Rails <test@docomo.ne.jp.jp>' , nil ],
|
33
|
+
['From: Jpmobile Rails <a(--)l@ezweb.ne.jp>' , Jpmobile::Mobile::Au ],
|
34
|
+
['From: a(--)l@ezweb.ne.jp' , Jpmobile::Mobile::Au ],
|
35
|
+
['From: Jpmobile Rails <a(--)l@ezweb.ne.jp.jp>' , nil ],
|
36
|
+
['From: Jpmobile Rails <dadaea@pdx.ne.jp>' , Jpmobile::Mobile::Willcom ],
|
37
|
+
['From: Jpmobile Rails <dadaea@pdx.ne.jp.jp>' , nil ],
|
38
|
+
['From: Jpmobile Rails <xxxe@dj.pdx.ne.jp>' , Jpmobile::Mobile::Willcom ],
|
39
|
+
['From: Jpmobile Rails <xxxe@dj.pdx.ne.jp.jp>' , nil ],
|
40
|
+
['From: Jpmobile Rails <xxxe@willcom.com>' , Jpmobile::Mobile::Willcom ],
|
41
|
+
['From: Jpmobile Rails <xxxe@willcom.com.jp>' , nil ],
|
42
|
+
['From: Jpmobile Rails <oeeikx@softbank.ne.jp>' , Jpmobile::Mobile::Softbank ],
|
43
|
+
['From: oeeikx@softbank.ne.jp' , Jpmobile::Mobile::Softbank ],
|
44
|
+
['From: Jpmobile Rails <oeeikx@softbank.ne.jp.jp>' , nil ],
|
45
|
+
['From: Jpmobile Rails <eaae@disney.ne.jp>' , Jpmobile::Mobile::Softbank ],
|
46
|
+
['From: Jpmobile Rails <eaae@disney.ne.jp.jp>' , nil ],
|
47
|
+
['From: Jpmobile Rails <iiiaa@r.vodafone.ne.jp>' , Jpmobile::Mobile::Vodafone ],
|
48
|
+
['From: Jpmobile Rails <iiiaa@r.vodafone.ne.jp.jp>' , nil ],
|
49
|
+
].each do |line, carrier|
|
50
|
+
it "#detect should return #{carrier} when take mail header #{line}}" do
|
51
|
+
Jpmobile::Email.detect_from_mail_header(line).should == carrier
|
52
|
+
end
|
53
|
+
end
|
25
54
|
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
3
|
+
|
4
|
+
describe Jpmobile::Emoticon do
|
5
|
+
include Jpmobile::Util
|
6
|
+
|
7
|
+
describe "unicodecr_to_external" do
|
8
|
+
context "should convert unicodecr to docomo encoding" do
|
9
|
+
it "when no options" do
|
10
|
+
Jpmobile::Emoticon::unicodecr_to_external("").should == sjis("\xf8\x9f")
|
11
|
+
end
|
12
|
+
|
13
|
+
it "in multiple convertion" do
|
14
|
+
Jpmobile::Emoticon::unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true).should == sjis("\xf8\x9f\xf8\xa0")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "should convert unicodecr to au encoding" do
|
19
|
+
it "when no options" do
|
20
|
+
Jpmobile::Emoticon::unicodecr_to_external("").should == sjis("\xf6\x59")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "should convert unicodecr to softbank encoding" do
|
25
|
+
it "when no opptions" do
|
26
|
+
Jpmobile::Emoticon::unicodecr_to_external("").should == [0xe001].pack('U')
|
27
|
+
end
|
28
|
+
|
29
|
+
it "in multiple convertion" do
|
30
|
+
Jpmobile::Emoticon::unicodecr_to_external("", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true).should == [0xe04a, 0xe049].pack('U*')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
describe "unicodecr_to_utf8" do
|
36
|
+
it "should convert unicodecr to internal utf8 encoding" do
|
37
|
+
# docomo codepoint
|
38
|
+
Jpmobile::Emoticon::unicodecr_to_utf8("").should == utf8("\356\230\276")
|
39
|
+
# au codepoint
|
40
|
+
Jpmobile::Emoticon::unicodecr_to_utf8("").should == utf8("\356\222\201")
|
41
|
+
# softbank codepoint
|
42
|
+
Jpmobile::Emoticon::unicodecr_to_utf8("").should == utf8("\xef\x80\x81")
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "utf8_to_unicodecr" do
|
47
|
+
it "should convert utf8 encoding to unicodecr" do
|
48
|
+
# docomo codepoint
|
49
|
+
Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\230\276")).should == ""
|
50
|
+
# au codepoint
|
51
|
+
Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\222\201")).should == ""
|
52
|
+
# softbank codepoint
|
53
|
+
Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\xef\x80\x81")).should == ""
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe "external_to_unicodecr" do
|
58
|
+
it "should convert docomo encoding to unicodecr" do
|
59
|
+
Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\xf8\x9f")).should == ""
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should convert au encoding to unicodecr" do
|
63
|
+
Jpmobile::Emoticon::external_to_unicodecr_au(sjis("\xf6\x59")).should == ""
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should convert softbank encoding to unicodecr" do
|
67
|
+
Jpmobile::Emoticon::external_to_unicodecr_softbank([0xe001].pack('U')).should == ""
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should not convert docomo encoding of koukai-sjis emoticons to unicodecr" do
|
71
|
+
Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\x8c\xf6\x8a\x4a")).should == sjis("\x8c\xf6\x8a\x4a")
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
context "for email" do
|
76
|
+
describe "au" do
|
77
|
+
it "should not convert 助助 that does not contain emoticons" do
|
78
|
+
Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("助助")).should_not match(/e484/i)
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should not convert exterior of 2byte Kanji-code" do
|
82
|
+
Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("abcd=uしから=uずんば=u")).should_not match(/e484/i)
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should not convert ascii string to unicodecr" do
|
86
|
+
Jpmobile::Emoticon.external_to_unicodecr_au_mail(utf8_to_jis("-------=_NextPart_15793_72254_63179")).should_not match(/e5c2/i)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require File.join(File.expand_path(File.dirname(__FILE__)), 'spec_helper')
|
3
|
+
|
4
|
+
describe "Jpmobile::Mobile" do
|
5
|
+
include Jpmobile::Util
|
6
|
+
|
7
|
+
describe "AbstractMobile" do
|
8
|
+
before(:each) do
|
9
|
+
@mobile = Jpmobile::Mobile::AbstractMobile.new(nil, nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
context "to_mail_subject" do
|
13
|
+
it "should convert string to ISO-2022-JP B-Encoding when string contains Japanese" do
|
14
|
+
@mobile.to_mail_subject("ほげ").should == "=?ISO-2022-JP?B?GyRCJFskMhsoQg==?="
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
context "to_mail_body" do
|
19
|
+
it "should convert string to ISO-2022-JP when string contains Japanese" do
|
20
|
+
@mobile.to_mail_body("ほげ").should == utf8_to_jis("ほげ")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "Docomo" do
|
26
|
+
before(:each) do
|
27
|
+
@mobile = Jpmobile::Mobile::Docomo.new(nil, nil)
|
28
|
+
end
|
29
|
+
|
30
|
+
context "to_mail_subject" do
|
31
|
+
it "should convert string to Shift_JIS B-Encoding when string contains Japanese" do
|
32
|
+
@mobile.to_mail_subject("ほげ").should == "=?Shift_JIS?B?gtmCsA==?="
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should convert emoticon  to \xf8\x9f in B-Encoding" do
|
36
|
+
@mobile.to_mail_subject("ほげ").should == "=?Shift_JIS?B?gtmCsPif?="
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "to_mail_body" do
|
41
|
+
it "should convert string to Shift_JIS when string contains Japanese" do
|
42
|
+
@mobile.to_mail_body("ほげ").should == utf8_to_sjis("ほげ")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should convert emoticon  to \xf8\x9f" do
|
46
|
+
@mobile.to_mail_body("ほげ").should == utf8_to_sjis("ほげ") + sjis("\xf8\x9f")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe "Au" do
|
52
|
+
before(:each) do
|
53
|
+
@mobile = Jpmobile::Mobile::Au.new(nil, nil)
|
54
|
+
end
|
55
|
+
|
56
|
+
context "to_mail_subject" do
|
57
|
+
it "should convert string to ISO-2022-JP B-Encoding when string contains Japanese" do
|
58
|
+
@mobile.to_mail_subject("ほげ").should == "=?ISO-2022-JP?B?GyRCJFskMhsoQg==?="
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should convert emoticon  to \x75\x41 in B-Encoding" do
|
62
|
+
@mobile.to_mail_subject("ほげ").should == "=?ISO-2022-JP?B?GyRCJFskMhsoQhskQnVBGyhC?="
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "to_mail_body" do
|
67
|
+
it "should convert string to ISO-2022-JP when string contains Japanese" do
|
68
|
+
@mobile.to_mail_body("ほげ").should == utf8_to_jis("ほげ")
|
69
|
+
end
|
70
|
+
|
71
|
+
it "should convert emoticon  to \x75\x41" do
|
72
|
+
ascii_8bit(@mobile.to_mail_body("ほげ")).should == ascii_8bit(utf8_to_jis("ほげ") + jis("\x1b\x24\x42\x75\x41\x1b\x28\x42"))
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
describe "Softbank" do
|
78
|
+
before(:each) do
|
79
|
+
@mobile = Jpmobile::Mobile::Softbank.new(nil, nil)
|
80
|
+
end
|
81
|
+
|
82
|
+
context "to_mail_subject" do
|
83
|
+
it "should convert string to Shift_JIS B-Encoding when string contains Japanese" do
|
84
|
+
@mobile.to_mail_subject("ほげ").should == "=?Shift_JIS?B?gtmCsA==?="
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should convert emoticon  to \xf9\x8b in B-Encoding" do
|
88
|
+
@mobile.to_mail_subject("ほげ").should == "=?Shift_JIS?B?gtmCsPmL?="
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
context "to_mail_body" do
|
93
|
+
it "should convert string to Shift_JIS when string contains Japanese" do
|
94
|
+
@mobile.to_mail_body("ほげ").should == utf8_to_sjis("ほげ")
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should convert emoticon  to \xf9\x8b" do
|
98
|
+
@mobile.to_mail_body("ほげ").should == utf8_to_sjis("ほげ") + sjis("\xf9\x8b")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|