Skip to content
Browse files

Merge remote branch 'kou/master'

  • Loading branch information...
2 parents c3f96c1 + d8e6e04 commit 037a766bf7cbd5ed587059dacf139e7be83bf195 @rust rust committed Jun 4, 2010
View
2 lib/jpmobile.rb
@@ -1,5 +1,3 @@
-$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__)))
-
module Jpmobile
autoload :Email , 'jpmobile/email'
autoload :Emoticon, 'jpmobile/emoticon'
View
18 lib/jpmobile/emoticon.rb
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
+
+require 'scanf'
require 'nkf'
module Jpmobile
@@ -88,9 +90,21 @@ def self.unicodecr_to_external(str, conversion_table=nil, to_sjis=true)
when Integer
# 変換先がUnicodeで指定されている。つまり対応する絵文字がある。
if sjis = UNICODE_TO_SJIS[converted]
- [sjis].pack('n')
+ if to_sjis
+ sjis_emotion = [sjis].pack('n')
+ if sjis_emotion.respond_to?(:force_encoding)
+ sjis_emotion.force_encoding("Shift_JIS")
+ end
+ sjis_emotion
+ else
+ [converted].pack("U")
+ end
elsif webcode = SOFTBANK_UNICODE_TO_WEBCODE[converted-0x1000]
- "\x1b\x24#{webcode}\x0f"
+ emotion = "\x1b\x24#{webcode}\x0f"
+ if emotion.respond_to?(:force_encoding)
+ emotion.force_encoding(str.encoding)
+ end
+ emotion
else
# キャリア変換テーブルに指定されていたUnicodeに対応する
# 携帯側エンコーディングが見つからない(変換テーブルの不備の可能性あり)。
View
21 lib/jpmobile/emoticon/z_combine.rb
@@ -1,4 +1,7 @@
-$KCODE='u'
+unless Object.const_defined?(:Encoding)
+ $KCODE = 'u'
+end
+
module Jpmobile
module Emoticon
SJIS_TO_UNICODE = {}
@@ -7,11 +10,21 @@ module Emoticon
SJIS_TO_UNICODE.freeze
UNICODE_TO_SJIS = SJIS_TO_UNICODE.invert.freeze
- SJIS_REGEXP = Regexp.union(*SJIS_TO_UNICODE.keys.map{|s| Regexp.compile(Regexp.escape([s].pack('n'),"s"),nil,'s')})
+ if Object.const_defined?(:Encoding)
+ sjis_regexp = Proc.new do |sjis|
+ Regexp.compile(Regexp.escape([sjis].pack('n').force_encoding("Shift_JIS")))
+ end
+ else
+ sjis_regexp = Proc.new do |sjis|
+ Regexp.compile(Regexp.escape([sjis].pack('n'),"s"),nil,'s')
+ end
+ end
+
+ SJIS_REGEXP = Regexp.union(*SJIS_TO_UNICODE.keys.map{|s| sjis_regexp[s]})
SOFTBANK_WEBCODE_REGEXP = Regexp.union(*([/(?!)/n]+SOFTBANK_WEBCODE_TO_UNICODE.keys.map{|x| "\x1b\x24#{x}\x0f"}))
- DOCOMO_SJIS_REGEXP = Regexp.union(*DOCOMO_SJIS_TO_UNICODE.keys.map{|s| Regexp.compile(Regexp.escape([s].pack('n'),"s"),nil,'s')})
- AU_SJIS_REGEXP = Regexp.union(*AU_SJIS_TO_UNICODE.keys.map{|s| Regexp.compile(Regexp.escape([s].pack('n'),"s"),nil,'s')})
+ DOCOMO_SJIS_REGEXP = Regexp.union(*DOCOMO_SJIS_TO_UNICODE.keys.map{|s| sjis_regexp[s]})
+ AU_SJIS_REGEXP = Regexp.union(*AU_SJIS_TO_UNICODE.keys.map{|s| sjis_regexp[s]})
SOFTBANK_UNICODE_REGEXP = Regexp.union(*SOFTBANK_UNICODE_TO_WEBCODE.keys.map{|x| [x].pack('U')}).freeze
EMOTICON_UNICODES = UNICODE_TO_SJIS.keys|SOFTBANK_UNICODE_TO_WEBCODE.keys.map{|k|k+0x1000}
View
3 lib/jpmobile/filter.rb
@@ -1,8 +1,7 @@
+# -*- coding: utf-8 -*-
# = 文字コードフィルタ
# thanks to masuidrive <masuidrive (at) masuidrive.jp>
-require 'scanf'
-
class ActionController::Base #:nodoc:
def self.mobile_filter(options={})
options = {:emoticon=>true, :hankaku=>false}.update(options)
View
3 lib/jpmobile/request_with_mobile.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+#
# jpmobile の各機能を提供するモジュール
# envメソッドと、parameter あるいは params メソッドが実装されている必要がある。
# 今のところはRack::RequestとActionController::AbstractRequestに対応しているはず。
@@ -31,6 +33,7 @@ def mobile?
# 携帯電話の機種に応じて Mobile::xxx を返す。
# 携帯電話でない場合はnilを返す。
def mobile
+ @__mobile ||= nil
return @__mobile if @__mobile
Jpmobile::Mobile.carriers.each do |const|
View
24 spec/unit/detect_by_ua_spec.rb
@@ -1,25 +1,23 @@
require File.join(File.dirname(__FILE__), 'spec_helper')
describe 'Jpmobile::RequestWithMobile' do
- before(:all) do
- ReqClass = Class.new
- ReqClass.class_eval do
- include Jpmobile::RequestWithMobile
+ Spec::Fixture::Base.new self, :carrier => :user_agent do
+ def request_class
+ Class.new do
+ include Jpmobile::RequestWithMobile
- def initialize user_agent
- @user_agent = user_agent
- end
+ def initialize user_agent
+ @user_agent = user_agent
+ end
- def user_agent
- @user_agent
+ def user_agent
+ @user_agent
+ end
end
end
- end
-
- Spec::Fixture::Base.new self, :carrier => :user_agent do
it '#mobile should return :carrier when take :user_agent as UserAgent' do |carrier, user_agent|
- ReqClass.new(user_agent).mobile.class.should == carrier
+ request_class.new(user_agent).mobile.class.should == carrier
end
set_fixtures([
View
2 spec/unit/util_spec.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.join(File.dirname(__FILE__), 'spec_helper')
describe Jpmobile::Util, ".deep_apply" do
View
4 tasks/jpmobile_tasks.rake
@@ -70,8 +70,8 @@ END
# run tests in rails
cd rails_root
- sh "rake db:migrate"
- sh "rake spec"
+ ruby "-S rake db:migrate"
+ ruby "-S rake spec"
cd relative_root
end
View
3 test/legacy/autoload_test.rb
@@ -1,4 +1,5 @@
-require 'test/unit'
+require File.dirname(__FILE__)+'/helper'
+
module Jpmobile
module Mobile
require 'jpmobile/mobile/abstract_mobile'
View
40 test/legacy/emoticon_functional_test.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__)+'/helper'
class EmoticonTestController < ActionController::Base
@@ -46,26 +48,26 @@ def test_docomo_from_docomo
# DoCoMo携帯
user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
get :docomo_cr
- assert_equal "\xf8\x9f", @response.body
+ assert_equal sjis("\xf8\x9f"), @response.body
get :docomo_utf8
- assert_equal "\xf8\x9f", @response.body
- get :query, :q=>"\xf8\x9f"
+ assert_equal sjis("\xf8\x9f"), @response.body
+ get :query, :q=>sjis("\xf8\x9f")
assert_equal "\xee\x98\xbe", assigns["q"]
- assert_equal "\xf8\x9f", @response.body
+ assert_equal sjis("\xf8\x9f"), @response.body
get :docomo_docomopoint
- assert_equal "\xf9\x79", @response.body
+ assert_equal sjis("\xf9\x79"), @response.body
end
def test_docomo_from_au
# Au携帯電話での閲覧
user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
get :docomo_cr
- assert_equal "\xf6\x60", @response.body
+ assert_equal sjis("\xf6\x60"), @response.body
get :docomo_utf8
- assert_equal "\xf6\x60", @response.body
+ assert_equal sjis("\xf6\x60"), @response.body
get :docomo_docomopoint
- assert_equal "[ドコモポイント]".tosjis, @response.body
+ assert_equal to_sjis("[ドコモポイント]"), @response.body
end
def test_docomo_from_softbank
@@ -88,7 +90,7 @@ def test_docomo_from_jphone
assert_equal "\e$Gj\x0f", @response.body
get :docomo_docomopoint
assert_equal "Shift_JIS", @response.charset
- assert_equal "[ドコモポイント]".tosjis, @response.body
+ assert_equal to_sjis("[ドコモポイント]"), @response.body
end
def test_au_from_pc
@@ -103,21 +105,21 @@ def test_au_from_au
# Au
user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
get :au_cr
- assert_equal "\xf6\x60", @response.body
+ assert_equal sjis("\xf6\x60"), @response.body
get :au_utf8
- assert_equal "\xf6\x60", @response.body
- get :query, :q=>"\xf6\x60"
+ assert_equal sjis("\xf6\x60"), @response.body
+ get :query, :q=>sjis("\xf6\x60")
assert_equal [0xe488].pack("U"), assigns["q"]
- assert_equal "\xf6\x60", @response.body
+ assert_equal sjis("\xf6\x60"), @response.body
end
def test_au_from_docomo
# DoCoMo携帯電話での閲覧
user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
get :au_cr
- assert_equal "\xf8\x9f", @response.body
+ assert_equal sjis("\xf8\x9f"), @response.body
get :au_utf8
- assert_equal "\xf8\x9f", @response.body
+ assert_equal sjis("\xf8\x9f"), @response.body
end
def test_au_from_softbank
@@ -177,17 +179,17 @@ def test_softbank_from_docomo
# DoCoMo携帯電話での閲覧
user_agent "DoCoMo/2.0 SH902i(c100;TB;W24H12)"
get :softbank_cr
- assert_equal "\xf8\x9f", @response.body
+ assert_equal sjis("\xf8\x9f"), @response.body
get :softbank_utf8
- assert_equal "\xf8\x9f", @response.body
+ assert_equal sjis("\xf8\x9f"), @response.body
end
def test_softbank_from_au
# Au携帯電話での閲覧
user_agent "KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0"
get :softbank_cr
- assert_equal "\xf6\x60", @response.body
+ assert_equal sjis("\xf6\x60"), @response.body
get :softbank_utf8
- assert_equal "\xf6\x60", @response.body
+ assert_equal sjis("\xf6\x60"), @response.body
end
end
View
24 test/legacy/emoticon_test.rb
@@ -2,34 +2,34 @@
class DocomoEmoticonTest < Test::Unit::TestCase
def test_external_unicodecr_docomo
- assert_equal "&#xe63e;", Jpmobile::Emoticon::external_to_unicodecr_docomo("\xf8\x9f")
+ assert_equal "&#xe63e;", Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\xf8\x9f"))
end
def test_unicodecr_external_docomo
- assert_equal "\xf8\x9f", Jpmobile::Emoticon::unicodecr_to_external("&#xe63e;")
+ assert_equal sjis("\xf8\x9f"), Jpmobile::Emoticon::unicodecr_to_external("&#xe63e;")
end
def test_unicodecr_external_docomo_for_string
- assert_equal "\xf8\x9f\xf8\xa0", Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)
+ assert_equal sjis("\xf8\x9f\xf8\xa0"), Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_DOCOMO, true)
end
def test_unicodecr_utf8_docomo
- assert_equal "\356\230\276", Jpmobile::Emoticon::unicodecr_to_utf8("&#xe63e;")
+ assert_equal utf8("\356\230\276"), Jpmobile::Emoticon::unicodecr_to_utf8("&#xe63e;")
end
def test_utf8_unicodecr_docomo
- assert_equal "&#xe63e;", Jpmobile::Emoticon::utf8_to_unicodecr("\356\230\276")
+ assert_equal "&#xe63e;", Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\230\276"))
end
end
class AuEmoticonTest < Test::Unit::TestCase
def test_au_external_unicodecr
- assert_equal "&#xe481;", Jpmobile::Emoticon::external_to_unicodecr_au("\xf6\x59")
+ assert_equal "&#xe481;", Jpmobile::Emoticon::external_to_unicodecr_au(sjis("\xf6\x59"))
end
def test_au_unicodecr_external
- assert_equal "\xf6\x59", Jpmobile::Emoticon::unicodecr_to_external("&#xe481;")
+ assert_equal sjis("\xf6\x59"), Jpmobile::Emoticon::unicodecr_to_external("&#xe481;")
end
def test_au_unicodecr_utf8
- assert_equal "\356\222\201", Jpmobile::Emoticon::unicodecr_to_utf8("&#xe481;")
+ assert_equal utf8("\356\222\201"), Jpmobile::Emoticon::unicodecr_to_utf8("&#xe481;")
end
def test_au_utf8_unicodecr
- assert_equal "&#xe481;", Jpmobile::Emoticon::utf8_to_unicodecr("\356\222\201")
+ assert_equal "&#xe481;", Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\356\222\201"))
end
end
@@ -47,10 +47,10 @@ def test_softbank_cr_webcode
assert_equal "\x1b$G!\x0f", Jpmobile::Emoticon::unicodecr_to_external("&#xf001;")
end
def test_softbank_cr_utf8
- assert_equal "\xef\x80\x81", Jpmobile::Emoticon::unicodecr_to_utf8("&#xf001;")
+ assert_equal utf8("\xef\x80\x81"), Jpmobile::Emoticon::unicodecr_to_utf8("&#xf001;")
end
def test_softbank_utf8_cr
- assert_equal "&#xf001;", Jpmobile::Emoticon::utf8_to_unicodecr("\xef\x80\x81")
+ assert_equal "&#xf001;", Jpmobile::Emoticon::utf8_to_unicodecr(utf8("\xef\x80\x81"))
end
def test_unicodecr_external_softbank_for_string
assert_equal "\x1b$Gj\x0f\x1b$Gi\x0f", Jpmobile::Emoticon::unicodecr_to_external("&#xE48E;", Jpmobile::Emoticon::CONVERSION_TABLE_TO_SOFTBANK, true)
@@ -59,6 +59,6 @@ def test_unicodecr_external_softbank_for_string
class KoukaiEmoticonTest < Test::Unit::TestCase
def test_koukai_sjis
- assert_equal "\x8c\xf6\x8a\x4a", Jpmobile::Emoticon::external_to_unicodecr_docomo("\x8c\xf6\x8a\x4a")
+ assert_equal sjis("\x8c\xf6\x8a\x4a"), Jpmobile::Emoticon::external_to_unicodecr_docomo(sjis("\x8c\xf6\x8a\x4a"))
end
end
View
18 test/legacy/filter_test.rb
@@ -1,17 +1,19 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__)+'/helper'
class FilterTest < Test::Unit::TestCase
def setup
- @aiu_sjis = "\202\240\202\242\202\244" # あいう
- @aiu_utf8 = "\343\201\202\343\201\204\343\201\206" # あいう
+ @aiu_sjis = sjis("\202\240\202\242\202\244") # あいう
+ @aiu_utf8 = utf8("\343\201\202\343\201\204\343\201\206") # あいう
- @aiu_zhz = "\343\201\202\357\275\262\343\202\246" # あイウ (イ半角), UTF-8
- @aiu_zzz = "\343\201\202\343\202\244\343\202\246" # あイウ, UTF-8
- @aiu_zhh = "\343\201\202\357\275\262\357\275\263" # あイウ (イウ半角), UTF-8
+ @aiu_zhz = utf8("\343\201\202\357\275\262\343\202\246") # あイウ (イ半角), UTF-8
+ @aiu_zzz = utf8("\343\201\202\343\202\244\343\202\246") # あイウ, UTF-8
+ @aiu_zhh = utf8("\343\201\202\357\275\262\357\275\263") # あイウ (イウ半角), UTF-8
- @abracadabra_z_utf8 = "\343\202\242\343\203\226\343\203\251\343\202\253\343\203\200\343\203\226\343\203\251" # アブラカダブラ, UTF-8
- @abracadabra_h_utf8 = "\357\275\261\357\276\214\357\276\236\357\276\227\357\275\266\357\276\200\357\276\236\357\276\214\357\276\236\357\276\227" # アブラカダブラ(半角), UTF-8
- @abracadabra_z_sjis = "\203A\203u\203\211\203J\203_\203u\203\211" # アブラカダブラ, Shift_JIS
+ @abracadabra_z_utf8 = utf8("\343\202\242\343\203\226\343\203\251\343\202\253\343\203\200\343\203\226\343\203\251") # アブラカダブラ, UTF-8
+ @abracadabra_h_utf8 = utf8("\357\275\261\357\276\214\357\276\236\357\276\227\357\275\266\357\276\200\357\276\236\357\276\214\357\276\236\357\276\227") # アブラカダブラ(半角), UTF-8
+ @abracadabra_z_sjis = sjis("\203A\203u\203\211\203J\203_\203u\203\211") # アブラカダブラ, Shift_JIS
end
def test_filter_sjis
filter = Jpmobile::Filter::Sjis.new
View
35 test/legacy/helper.rb
@@ -1,14 +1,24 @@
-require 'test/unit'
+# -*- coding: utf-8 -*-
+
require 'rubygems'
+begin
+ gem 'test-unit', '= 1.2.3'
+rescue Gem::LoadError
+end
+require 'test/unit'
+action_pack_version = '2.3.5'
+gem 'actionpack', "= #{action_pack_version}"
require 'action_controller'
require 'rack'
RAILS_ENV = "test"
require File.dirname(__FILE__)+'/../../lib/jpmobile'
# ActionPackのTestのためのrequire
-action_pack_full_path = Gem.cache.search('actionpack').sort_by { |g| g.version.version }.last
-require File.join(action_pack_full_path.full_gem_path,'test/abstract_unit')
+action_pack_gem = Gem.cache.find_name('actionpack').find do |gem|
+ action_pack_version == gem.version.version
+end
+require File.join(action_pack_gem.full_gem_path,'test/abstract_unit')
class FakeCgi < CGI
attr_accessor :stdinput, :stdoutput, :env_table
@@ -46,5 +56,24 @@ def init(c)
@request.host = "www.example.jp"
@request.session.session_id = "mysessionid"
end
+ def sjis(ascii_8bit)
+ if ascii_8bit.respond_to?(:force_encoding)
+ ascii_8bit.force_encoding("Shift_JIS")
+ end
+ ascii_8bit
+ end
+ def utf8(ascii_8bit)
+ if ascii_8bit.respond_to?(:force_encoding)
+ ascii_8bit.force_encoding("utf-8")
+ end
+ ascii_8bit
+ end
+ def to_sjis(utf8)
+ if utf8.respond_to?(:encode)
+ utf8.encode("Shift_JIS")
+ else
+ utf8.tosjis
+ end
+ end
end
Test::Unit::TestCase.class_eval{ include Jpmobile::TestHelper }
View
2 test/legacy/softbank_test.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__)+'/helper'
class SoftbankTest < Test::Unit::TestCase
View
2 test/rails/overrides/spec/controllers/docomo_guid_spec.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
describe "docomo_guid が起動しないとき", :shared => true do
View
2 test/rails/overrides/spec/controllers/docomo_spec.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
describe "DoCoMo SH902i からのアクセス" do
View
2 test/rails/overrides/spec/controllers/emobile_spec.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
describe "H11T モバイルブラウザからのアクセス", :behaviour_type=>:controller do
View
15 test/rails/overrides/spec/controllers/filter_spec.rb
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
describe "文字コードフィルタが動作しているとき", :shared => true do
@@ -16,20 +17,20 @@
describe "Shift_JISで通信する端末との通信", :shared => true do
it "はShift_JISで携帯に送出されること" do
get :abracadabra_utf8
- response.body.should == "アブラカダブラ".tosjis
+ response.body.should == to_sjis("アブラカダブラ")
response.charset.should == "Shift_JIS"
end
it "はxhtmlでもShift_JISで携帯に送出されること" do
get :abracadabra_xhtml_utf8
- response.body.should == "アブラカダブラ".tosjis
+ response.body.should == to_sjis("アブラカダブラ")
response.charset.should == "Shift_JIS"
end
it "はShift_JISで渡されたパラメタがparamsにUTF-8に変換されて格納されること" do
- get :index, :q => "アブラカダブラ".tosjis
+ get :index, :q => to_sjis("アブラカダブラ")
assigns[:q].should == "アブラカダブラ"
end
it "は半角カナのparamsを変換しないこと" do
- get :index, :q => "\261\314\336\327\266\300\336\314\336\327" # アブラカダブラ半角,SJIS
+ get :index, :q => sjis("\261\314\336\327\266\300\336\314\336\327") # アブラカダブラ半角,SJIS
assigns[:q].should == "アブラカダブラ"
end
it_should_behave_like "文字コードフィルタが動作しているとき"
@@ -60,15 +61,15 @@
describe "Shift_JISで通信する端末との通信(半角変換付き)", :shared => true do
it "は半角に変換されShift_JISで携帯に送出されること" do
get :abracadabra_utf8
- response.body.should == "\261\314\336\327\266\300\336\314\336\327" # アブラカダブラ半角,SJIS
+ response.body.should == sjis("\261\314\336\327\266\300\336\314\336\327") # アブラカダブラ半角,SJIS
response.charset.should == "Shift_JIS"
end
it "はShift_JISで渡されたパラメタがparamsにUTF-8に変換されて格納されること" do
- get :index, :q => "アブラカダブラ".tosjis
+ get :index, :q => to_sjis("アブラカダブラ")
assigns[:q].should == "アブラカダブラ"
end
it "は半角Shift_JISで渡されたパラメタがparamsに全角UTF-8に変換されて格納されること" do
- get :index, :q => "\261\314\336\327\266\300\336\314\336\327" # アブラカダブラ半角,SJIS
+ get :index, :q => sjis("\261\314\336\327\266\300\336\314\336\327") # アブラカダブラ半角,SJIS
assigns[:q].should == "アブラカダブラ"
end
it_should_behave_like "文字コードフィルタが動作しているとき"
View
2 test/rails/overrides/spec/controllers/pc_spec.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
describe "PCからのアクセスの場合", :behaviour_type=>:controller do
View
2 test/rails/overrides/spec/controllers/softbank_emulator_spec.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
describe "携帯電話からのアクセス", :shared => true do
View
2 test/rails/overrides/spec/controllers/template_path_spec.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
#
View
1 test/rails/overrides/spec/controllers/trans_sid_spec.rb
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
describe "trans_sid が起動しないとき", :shared => true do
View
2 test/rails/overrides/spec/helpers/helpers_spec.rb
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
require File.dirname(__FILE__) + '/../spec_helper'
describe Jpmobile::Helpers do
View
15 test/rails/overrides/spec/spec_helper.rb
@@ -45,3 +45,18 @@
#
# For more information take a look at Spec::Runner::Configuration and Spec::Runner
end
+
+def sjis(ascii_8bit)
+ if ascii_8bit.respond_to?(:force_encoding)
+ ascii_8bit.force_encoding("Shift_JIS")
+ end
+ ascii_8bit
+end
+
+def to_sjis(utf8)
+ if utf8.respond_to?(:encode)
+ utf8.encode("Shift_JIS")
+ else
+ utf8.tosjis
+ end
+end

0 comments on commit 037a766

Please sign in to comment.
Something went wrong with that request. Please try again.