Sha256: 2f5bf79022d0ed8889ceb6d1994caf77d1b9b18196e8cf26e01d8d0331ed0e14

Contents?: true

Size: 1.39 KB

Versions: 61

Compression:

Stored size: 1.39 KB

Contents

# -*- coding: utf-8 -*-
require File.join(File.expand_path(File.dirname(__FILE__)), '../../rack_helper.rb')

describe Jpmobile::Rack::MobileCarrier, "iphone" do
  include Rack::Test::Methods

  context "端末種別で" do
    it "iPhone を判別できること" do
      res = Rack::MockRequest.env_for(
        'http://jpmobile-rails.org/',
        'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16')
      env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]

      env['rack.jpmobile'].class.should            == Jpmobile::Mobile::Iphone
      env['rack.jpmobile'].position.should         be_nil
      env['rack.jpmobile'].smart_phone?.should     be_true
      env['rack.jpmobile'].supports_cookie?.should be_true
    end
  end

  context "IPアドレス制限で" do
    it "Softbank 網からのアクセスでも invalid になること" do
      res = Rack::MockRequest.env_for(
        'http://jpmobile-rails.org/',
        'HTTP_USER_AGENT' => 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; ja-jp) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16',
        "REMOTE_ADDR"=>"202.179.204.1")
      env = Jpmobile::Rack::MobileCarrier.new(UnitApplication.new).call(res)[1]

      env['rack.jpmobile'].valid_ip?.should be_false
    end
  end
end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
jpmobile-0.1.0.pre spec/rack/jpmobile/iphone_spec.rb