Sha256: 23fabfc5ea5995a3ad7a8beb06ccd86f4d89749c89d077f6a5ee53d71c128b40

Contents?: true

Size: 1.38 KB

Versions: 44

Compression:

Stored size: 1.38 KB

Contents

# -*- coding: utf-8 -*-
require 'guestbook'
require 'rack/test'
require 'test/unit'

class SinatraOnJpmobile < Test::Unit::TestCase
  include Rack::Test::Methods
  include Jpmobile::Util

  def app
    Guestbook
  end

  def last_app
    SinatraTestHelper.instance.last_app
  end

  def test_not_convert_pc_get
    get '/', {:g => Jpmobile::Util.sjis("万葉")}, {}
    assert_equal last_response.body, "万葉"
  end

  def test_not_convert_pc_post
    post '/', {:p => Jpmobile::Util.utf8("けーたい")}, {}
    assert_equal last_response.body, "けーたい"
  end

  def test_docomo_get_convert_to_utf8
    get '/', {:g => utf8_to_sjis("万葉")}, {"HTTP_USER_AGENT" => "DoCoMo/2.0 SH902i(c100;TB;W24H12)"}
    assert_equal last_app.assigns(:g), "万葉"
    assert_equal last_response.body, utf8_to_sjis("万葉")
  end

  def test_docomo_post_convert_to_utf8
    post '/', {:p => utf8_to_sjis("けーたい")}, {"HTTP_USER_AGENT" => "DoCoMo/2.0 SH902i(c100;TB;W24H12)"}
    assert_equal last_app.assigns(:p), "けーたい"
    assert_equal last_response.body, utf8_to_sjis("けーたい")
  end

  # def test_view_selector_pc
  #   get '/top', {}, {"HTTP_USER_AGENT" => "Mozilla"}
  #   assert_equal last_response.body, 'PC'
  # end

  # def test_view_selector_mobile
  #   get '/top', {}, {"HTTP_USER_AGENT" => "DoCoMo/2.0 SH902i(c100;TB;W24H12)"}
  #   assert_equal last_response.body, 'MOBILE'
  # end
end

Version data entries

44 entries across 44 versions & 1 rubygems

Version Path
jpmobile-4.2.5 test/sinatra/test/filter_test.rb
jpmobile-4.2.4 test/sinatra/test/filter_test.rb
jpmobile-5.0.0 test/sinatra/test/filter_test.rb
jpmobile-5.0.0.beta3 test/sinatra/test/filter_test.rb
jpmobile-4.1.5 test/sinatra/test/filter_test.rb
jpmobile-5.0.0.beta2 test/sinatra/test/filter_test.rb
jpmobile-4.2.3 test/sinatra/test/filter_test.rb
jpmobile-4.2.2 test/sinatra/test/filter_test.rb
jpmobile-4.2.1 test/sinatra/test/filter_test.rb
jpmobile-5.0.0.beta1 test/sinatra/test/filter_test.rb
jpmobile-4.2.0 test/sinatra/test/filter_test.rb
jpmobile-3.0.9 test/sinatra/test/filter_test.rb
jpmobile-4.1.4 test/sinatra/test/filter_test.rb
jpmobile-4.0.1 test/sinatra/test/filter_test.rb
jpmobile-4.1.1 test/sinatra/test/filter_test.rb
jpmobile-4.1.0 test/sinatra/test/filter_test.rb
jpmobile-3.0.8 test/sinatra/test/filter_test.rb
jpmobile-4.1.0.rc1 test/sinatra/test/filter_test.rb
jpmobile-4.0.0 test/sinatra/test/filter_test.rb
jpmobile-3.0.7 test/sinatra/test/filter_test.rb