jpmobile 6.1.2 → 7.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +8 -3
  3. data/.rubocop.yml +1 -1
  4. data/.ruby-version +1 -1
  5. data/Gemfile +2 -0
  6. data/Gemfile.lock +119 -138
  7. data/README.md +3 -18
  8. data/jpmobile.gemspec +3 -4
  9. data/lib/jpmobile/docomo_guid.rb +2 -2
  10. data/lib/jpmobile/hook_action_view.rb +3 -3
  11. data/lib/jpmobile/hook_template_details_requested.rb +12 -0
  12. data/lib/jpmobile/mailer.rb +1 -1
  13. data/lib/jpmobile/mobile/android.rb +1 -1
  14. data/lib/jpmobile/mobile/android_tablet.rb +1 -1
  15. data/lib/jpmobile/mobile/au.rb +2 -2
  16. data/lib/jpmobile/mobile/black_berry.rb +1 -1
  17. data/lib/jpmobile/mobile/ddipocket.rb +1 -1
  18. data/lib/jpmobile/mobile/docomo.rb +2 -2
  19. data/lib/jpmobile/mobile/emobile.rb +2 -2
  20. data/lib/jpmobile/mobile/ipad.rb +1 -1
  21. data/lib/jpmobile/mobile/iphone.rb +1 -1
  22. data/lib/jpmobile/mobile/softbank.rb +2 -2
  23. data/lib/jpmobile/mobile/vodafone.rb +2 -2
  24. data/lib/jpmobile/mobile/willcom.rb +2 -2
  25. data/lib/jpmobile/mobile/windows_phone.rb +1 -1
  26. data/lib/jpmobile/path_set.rb +10 -36
  27. data/lib/jpmobile/rails.rb +2 -0
  28. data/lib/jpmobile/resolver.rb +44 -6
  29. data/lib/jpmobile/template_details.rb +38 -0
  30. data/lib/jpmobile/trans_sid.rb +1 -1
  31. data/lib/jpmobile/util.rb +1 -1
  32. data/lib/jpmobile/version.rb +1 -1
  33. data/lib/jpmobile/view_selector.rb +5 -6
  34. data/lib/jpmobile.rb +13 -0
  35. data/lib/tasks/jpmobile_tasks.rake +2 -1
  36. data/spec/rack/jpmobile/mobile_by_ua_spec.rb +1 -0
  37. data/test/rails/overrides/Gemfile.jpmobile +4 -0
  38. data/test/rails/overrides/app/controllers/mobile_spec_controller.rb +1 -1
  39. data/test/rails/overrides/app/controllers/template_path_controller.rb +3 -0
  40. data/test/rails/overrides/app/views/mobile_spec/mobile_not_exist.html.erb +3 -0
  41. data/test/rails/overrides/config/routes.rb +1 -1
  42. data/test/rails/overrides/spec/controllers/mobile_spec_controller_spec.rb +3 -3
  43. data/test/rails/overrides/spec/rails_helper.rb +1 -1
  44. data/test/rails/overrides/spec/requests/filter_spec.rb +106 -0
  45. data/test/rails/overrides/spec/requests/template_path_spec.rb +1 -1
  46. data/test/rails/overrides/spec/{features → system}/admin/top_spec.rb +2 -2
  47. data/test/rails/overrides/spec/{features → system}/filter_spec.rb +2 -7
  48. data/test/rails/overrides/spec/system/support/cuprite_setup.rb +14 -0
  49. data/test/rails/overrides/spec/system_helper.rb +3 -0
  50. metadata +23 -29
  51. data/test/rails/overrides/app/views/mobile_spec/no_mobile.html.erb +0 -3
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
4
4
  # スーパクラスはSoftbank。
5
5
  class Vodafone < Softbank
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = /^(Vodafone|Vemulator)/.freeze
7
+ USER_AGENT_REGEXP = /^(Vodafone|Vemulator)/
8
8
  # 対応するメールアドレスの正規表現
9
- MAIL_ADDRESS_REGEXP = /.+@[dhtcrknsq]\.vodafone\.ne\.jp/.freeze
9
+ MAIL_ADDRESS_REGEXP = /.+@[dhtcrknsq]\.vodafone\.ne\.jp/
10
10
 
11
11
  # cookieに対応しているか?
12
12
  def supports_cookie?
@@ -4,9 +4,9 @@ module Jpmobile::Mobile
4
4
  # Ddipocketのスーパクラス。
5
5
  class Willcom < AbstractMobile
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = %r{^Mozilla/3.0\(WILLCOM}.freeze
7
+ USER_AGENT_REGEXP = %r{^Mozilla/3.0\(WILLCOM}
8
8
  # 対応するメールアドレスの正規表現
9
- MAIL_ADDRESS_REGEXP = /.+@((.+\.)?pdx\.ne\.jp|willcom\.com)/.freeze
9
+ MAIL_ADDRESS_REGEXP = /.+@((.+\.)?pdx\.ne\.jp|willcom\.com)/
10
10
 
11
11
  # 位置情報があれば Position のインスタンスを返す。無ければ +nil+ を返す。
12
12
  def position
@@ -4,6 +4,6 @@ module Jpmobile::Mobile
4
4
  # ==WindowsPhone
5
5
  class WindowsPhone < SmartPhone
6
6
  # 対応するUser-Agentの正規表現
7
- USER_AGENT_REGEXP = /Windows Phone/.freeze
7
+ USER_AGENT_REGEXP = /Windows Phone/
8
8
  end
9
9
  end
@@ -1,41 +1,15 @@
1
1
  module Jpmobile
2
- class PathSet < Array
3
- %w[initialize << concat insert push unshift].each do |method|
4
- class_eval <<-METHOD, __FILE__, __LINE__ + 1
5
- def #{method}(*args)
6
- super
7
- typecast!
8
- end
9
- METHOD
10
- end
2
+ class PathSet < ActionView::PathSet
3
+ private
11
4
 
12
- def find(path, prefix = nil, partial = false, details = {}, key = nil)
13
- template = find_all(path, prefix, partial, details, key).first
14
- raise MissingTemplate.new(self, "#{prefix}/#{path}", details, partial) unless template
15
-
16
- template
17
- end
18
-
19
- def find_all(*args)
20
- each do |resolver|
21
- templates = resolver.find_all(*args)
22
- return templates unless templates.empty?
23
- end
24
- []
25
- end
26
-
27
- def exists?(*args)
28
- find_all(*args).any?
29
- end
30
-
31
- protected
32
-
33
- def typecast!
34
- each_with_index do |path, i|
35
- path = path.to_s if path.is_a?(Pathname)
36
- next unless path.is_a?(String)
37
-
38
- self[i] = Jpmobile::Resolver.new(path)
5
+ def typecast(paths)
6
+ paths.map do |path|
7
+ case path
8
+ when Pathname, String
9
+ Jpmobile::Resolver.new path.to_s
10
+ else
11
+ super(paths)
12
+ end
39
13
  end
40
14
  end
41
15
  end
@@ -12,8 +12,10 @@ end
12
12
 
13
13
  ActiveSupport.on_load(:action_view) do
14
14
  require 'jpmobile/hook_action_view'
15
+ require 'jpmobile/hook_template_details_requested'
15
16
 
16
17
  self.prepend Jpmobile::HtmlOptionsWithAcceptCharset
18
+ ActionView::TemplateDetails::Requested.prepend Jpmobile::HookTemplateDetailsRequested
17
19
  end
18
20
 
19
21
  ActiveSupport.on_load(:after_initialize) do
@@ -1,14 +1,52 @@
1
1
  module Jpmobile
2
2
  class Resolver < ::ActionView::FileSystemResolver
3
- EXTENSIONS = [:locale, :formats, :handlers, :mobile].freeze
4
- DEFAULT_PATTERN = ':prefix/:action{_:mobile,}{.:locale,}{.:formats,}{+:variants,}{.:handlers,}'.freeze
5
-
6
3
  def initialize(path)
7
- raise ArgumentError, 'path already is a Resolver class' if path.is_a?(Resolver)
4
+ super(path)
5
+
6
+ @path_parser = Jpmobile::Resolver::PathParser.new
7
+ end
8
8
 
9
+ def clear_cache
9
10
  super
10
- @pattern = DEFAULT_PATTERN
11
- @path = File.expand_path(path)
11
+
12
+ @path_parser = Jpmobile::Resolver::PathParser.new
13
+ end
14
+
15
+ class PathParser < ::ActionView::Resolver::PathParser
16
+ def build_path_regex
17
+ handlers = ::ActionView::Template::Handlers.extensions.map {|x| Regexp.escape(x) }.join('|')
18
+ formats = ::ActionView::Template::Types.symbols.map {|x| Regexp.escape(x) }.join('|')
19
+ locales = '[a-z]{2}(?:-[A-Z]{2})?'
20
+ variants = '[^.]*'
21
+ mobile = Jpmobile::Mobile.all_variants.map {|x| Regexp.escape(x) }.join('|')
22
+
23
+ %r{
24
+ \A
25
+ (?:(?<prefix>.*)/)?
26
+ (?<partial>_)?
27
+ (?<action>.*?)
28
+ (?:_(?<mobile>#{mobile}))??
29
+ (?:\.(?<locale>#{locales}))??
30
+ (?:\.(?<format>#{formats}))??
31
+ (?:\+(?<variant>#{variants}))??
32
+ (?:\.(?<handler>#{handlers}))?
33
+ \z
34
+ }x
35
+ end
36
+
37
+ def parse(path)
38
+ @regex ||= build_path_regex
39
+ match = @regex.match(path)
40
+ path = ActionView::TemplatePath.build(match[:action], match[:prefix] || '', !!match[:partial])
41
+ details = Jpmobile::TemplateDetails.new(
42
+ match[:locale]&.to_sym,
43
+ match[:handler]&.to_sym,
44
+ match[:format]&.to_sym,
45
+ match[:variant]&.to_sym,
46
+ match[:mobile]&.to_sym,
47
+ )
48
+ ParsedPath.new(path, details)
49
+ end
12
50
  end
13
51
  end
14
52
  end
@@ -0,0 +1,38 @@
1
+ module Jpmobile
2
+ class TemplateDetails < ActionView::TemplateDetails
3
+ def initialize(locale, handler, format, variant, mobile)
4
+ @mobile = mobile
5
+
6
+ super(locale, handler, format, variant)
7
+ end
8
+
9
+ def matches?(requested)
10
+ requested.formats_idx[@format] &&
11
+ requested.locale_idx[@locale] &&
12
+ requested.variants_idx[@variant] &&
13
+ requested.handlers_idx[@handler] &&
14
+ requested.mobile_idx[@mobile]
15
+ end
16
+
17
+ def sort_key_for(requested)
18
+ [
19
+ requested.formats_idx[@format],
20
+ requested.locale_idx[@locale],
21
+ requested.variants_idx[@variant],
22
+ requested.handlers_idx[@handler],
23
+ requested.mobile_idx[@mobile],
24
+ ]
25
+ end
26
+
27
+ class Requested < ActionView::TemplateDetails::Requested
28
+ attr_reader :mobile, :mobile_idx
29
+
30
+ def initialize(locale:, handlers:, formats:, variants:, mobile:)
31
+ super(locale: locale, handlers: handlers, formats: formats, variants: variants)
32
+
33
+ @mobile = mobile.map(&:to_sym)
34
+ @mobile_idx = build_idx_hash(mobile)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -91,7 +91,7 @@ module Jpmobile
91
91
  end
92
92
 
93
93
  module ActionController
94
- class Metal #:nodoc:
94
+ class Metal # :nodoc:
95
95
  class_attribute :trans_sid_mode
96
96
 
97
97
  class << self
data/lib/jpmobile/util.rb CHANGED
@@ -291,7 +291,7 @@ module Jpmobile
291
291
  def split_text(str, size = 15)
292
292
  return nil if str.nil? || (str == '')
293
293
 
294
- [str[0..(size - 1)], str[size..-1]]
294
+ [str[0..(size - 1)], str[size..]]
295
295
  end
296
296
 
297
297
  def invert_table(hash)
@@ -1,3 +1,3 @@
1
1
  module Jpmobile
2
- VERSION = '6.1.2'.freeze
2
+ VERSION = '7.0.0'.freeze
3
3
  end
@@ -1,12 +1,11 @@
1
1
  module Jpmobile
2
2
  module ViewSelector
3
- def self.included(base)
4
- base.class_eval do
5
- before_action :register_mobile
3
+ extend ActiveSupport::Concern
6
4
 
7
- self._view_paths = self._view_paths.dup
8
- self.view_paths.unshift(*self.view_paths.map {|resolver| Jpmobile::Resolver.new(resolver.to_path) })
9
- end
5
+ included do
6
+ before_action :register_mobile
7
+
8
+ self.view_paths = Jpmobile::PathSet.new(self.view_paths.paths.map(&:path))
10
9
  end
11
10
 
12
11
  def register_mobile
data/lib/jpmobile.rb CHANGED
@@ -48,9 +48,19 @@ module Jpmobile
48
48
  end
49
49
 
50
50
  def self.carriers=(ary)
51
+ @all_variants = nil
52
+
51
53
  @carriers = ary
52
54
  end
53
55
 
56
+ def self.all_variants
57
+ return @all_variants if @all_variants
58
+
59
+ @all_variants = carriers.map {|carrier|
60
+ Jpmobile::Mobile.const_get(carrier).new({}, {}).variants
61
+ }.flatten.uniq
62
+ end
63
+
54
64
  require 'jpmobile/mobile/abstract_mobile'
55
65
  end
56
66
 
@@ -63,6 +73,9 @@ module Jpmobile
63
73
  autoload :Mailer, 'jpmobile/mailer'
64
74
  autoload :Resolver, 'jpmobile/resolver'
65
75
 
76
+ autoload :PathSet, 'jpmobile/path_set'
77
+ autoload :TemplateDetails, 'jpmobile/template_details'
78
+
66
79
  autoload :ViewSelector, 'jpmobile/view_selector'
67
80
  autoload :FallbackViewSelector, 'jpmobile/fallback_view_selector'
68
81
 
@@ -112,12 +112,13 @@ namespace :test do
112
112
 
113
113
  system 'bundle install'
114
114
  system 'bin/rails db:migrate RAILS_ENV=test' unless skip
115
- system 'bin/rails spec'
115
+ system 'bin/rails spec', exception: true
116
116
 
117
117
  ENV.replace(original_env)
118
118
  end
119
119
  end
120
120
  end
121
+
121
122
  desc 'Run sinatra on jpmobile tests'
122
123
  Rake::TestTask.new(:sinatra) do |t|
123
124
  t.libs << 'lib'
@@ -17,6 +17,7 @@ describe Jpmobile::MobileCarrier do
17
17
  [Jpmobile::Mobile::Emobile, 'emobile/1.0.0 (H11T; like Gecko; Wireless) NetFront/3.4'],
18
18
  [Jpmobile::Mobile::Iphone, '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'],
19
19
  [Jpmobile::Mobile::Android, 'Mozilla/5.0 (Linux; U; Android 1.6; ja-jp; SonyEriccsonSO-01B Build/R1EA018) AppleWebKit/528.5+ (KHTML, like Gecko) Version/3.1.2 Mobile Safari/525.20.1'],
20
+ [Jpmobile::Mobile::Android, 'Mozilla/5.0 (Linux; Android 9; ANE-LX2J Build/HUAWEIANE-LX2J; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/88.0.4324.93 Mobile Safari/537.36 Instagram 172.0.0.21.123 Android (28/9; 480dpi; 1080x2060; HUAWEI; ANE-LX2J; HWANE; hi6250; ja_JP; 269790805)'],
20
21
  [Jpmobile::Mobile::WindowsPhone, 'Mozilla/4.0 (Compatible; MSIE 6.0; Windows NT 5.1 T-01A_6.5; Windows Phone 6.5)'],
21
22
  [Jpmobile::Mobile::BlackBerry, 'BlackBerry9000/4.6.0.224 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/220'],
22
23
  [Jpmobile::Mobile::Ipad, 'Mozilla/5.0 (iPad; U; CPU OS 4_3 like Mac OS X; ja-jp) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8F191 Safari/6533.18.5'],
@@ -14,3 +14,7 @@ group :development, :test do
14
14
  gem "rspec-rails"
15
15
  gem 'rails-controller-testing'
16
16
  end
17
+
18
+ group :test do
19
+ gem 'cuprite'
20
+ end
@@ -8,6 +8,6 @@ class MobileSpecController < ApplicationController
8
8
  render file: File.join(Rails.public_path, '422.html')
9
9
  end
10
10
 
11
- def no_mobile
11
+ def mobile_not_exist
12
12
  end
13
13
  end
@@ -10,6 +10,9 @@ class TemplatePathController < ApplicationController
10
10
  def show
11
11
  end
12
12
 
13
+ def partial
14
+ end
15
+
13
16
  def optioned_index
14
17
  render action: 'index'
15
18
  end
@@ -0,0 +1,3 @@
1
+ PC mobile_not_exist
2
+
3
+ <%= render 'partial_view_sample' -%>
@@ -61,7 +61,7 @@ RailsRoot::Application.routes.draw do
61
61
  %w[
62
62
  index
63
63
  file_render
64
- no_mobile
64
+ mobile_not_exist
65
65
  ].each do |a|
66
66
  get "mobile_spec/#{a}", to: "mobile_spec##{a}"
67
67
  end
@@ -52,7 +52,7 @@ describe MobileSpecController, type: :controller do
52
52
  end
53
53
  end
54
54
 
55
- describe "GET 'no_mobile'" do
55
+ describe "GET 'mobile_not_exist'" do
56
56
  around do |example|
57
57
  orig_value = Jpmobile.config.fallback_view_selector
58
58
  Jpmobile.config.fallback_view_selector = true
@@ -65,7 +65,7 @@ describe MobileSpecController, type: :controller do
65
65
  context 'PC access' do
66
66
  it 'should be successful' do
67
67
  request.user_agent = 'Mozilla'
68
- get 'no_mobile'
68
+ get 'mobile_not_exist'
69
69
 
70
70
  expect(response).to be_successful
71
71
  expect(response.body).not_to match('RailsRoot PC mobile')
@@ -75,7 +75,7 @@ describe MobileSpecController, type: :controller do
75
75
  context 'mobile access' do
76
76
  it 'should be successful' do
77
77
  request.user_agent = 'DoCoMo/2.0 SH902i(c100;TB;W24H12)'
78
- get 'no_mobile'
78
+ get 'mobile_not_exist'
79
79
 
80
80
  expect(response).to be_successful
81
81
  expect(response.body).not_to match('RailsRoot mobile')
@@ -48,7 +48,7 @@ RSpec.configure do |config|
48
48
  # # ...
49
49
  # end
50
50
  #
51
- # The different available types are documented in the features, such as in
51
+ # The different available types are documented in the system, such as in
52
52
  # https://relishapp.com/rspec/rspec-rails/docs
53
53
  config.infer_spec_type_from_file_location!
54
54
 
@@ -0,0 +1,106 @@
1
+ require 'system_helper'
2
+
3
+ describe 'jpmobile integration spec', type: :request do
4
+ include Jpmobile::Util
5
+
6
+ before do
7
+ page.driver.headers = { 'User-Agent' => user_agent }
8
+ end
9
+
10
+ shared_examples_for '文字コードフィルタが動作しているとき' do
11
+ it 'はhtml以外は変換しないこと' do
12
+ get "/#{controller}/rawdata", env: { 'HTTP_USER_AGENT' => user_agent }
13
+ expect(response.body.encode('UTF-8')).to eq('アブラカダブラ')
14
+ expect(response.headers['Content-Type']).not_to match(/charset/i)
15
+ end
16
+ end
17
+
18
+ #
19
+ # PCからのアクセス
20
+ #
21
+ describe FilterController do
22
+ let(:controller) { 'filter' }
23
+
24
+ describe 'PCからのアクセス' do
25
+ let(:user_agent) do
26
+ 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)'
27
+ end
28
+ it_should_behave_like '文字コードフィルタが動作しているとき'
29
+ end
30
+
31
+ describe 'DoCoMo SH902i からのアクセス' do
32
+ let(:user_agent) do
33
+ 'DoCoMo/2.0 SH902i(c100;TB;W24H12)'
34
+ end
35
+ it_should_behave_like '文字コードフィルタが動作しているとき'
36
+ end
37
+
38
+ describe 'au CA32 からのアクセス' do
39
+ let(:user_agent) do
40
+ 'KDDI-CA32 UP.Browser/6.2.0.7.3.129 (GUI) MMP/2.0'
41
+ end
42
+ it_should_behave_like '文字コードフィルタが動作しているとき'
43
+ end
44
+
45
+ describe 'Vodafone V903T からのアクセス' do
46
+ let(:user_agent) do
47
+ 'Vodafone/1.0/V903T/TJ001 Browser/VF-Browser/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 Ext-J-Profile/JSCL-1.2.2 Ext-V-Profile/VSCL-2.0.0'
48
+ end
49
+ it_should_behave_like '文字コードフィルタが動作しているとき'
50
+ end
51
+
52
+ describe 'SoftBank 910T からのアクセス' do
53
+ let(:user_agent) do
54
+ 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1'
55
+ end
56
+ it_should_behave_like '文字コードフィルタが動作しているとき'
57
+ end
58
+ end
59
+
60
+ describe HankakuFilterController do
61
+ let(:controller) { 'hankaku_filter' }
62
+
63
+ describe 'PCからのアクセス' do
64
+ let(:user_agent) do
65
+ 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ja; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)'
66
+ end
67
+ it_should_behave_like '文字コードフィルタが動作しているとき'
68
+ end
69
+
70
+ describe 'DoCoMo SH902i からのアクセス' do
71
+ let(:user_agent) do
72
+ 'DoCoMo/2.0 SH902i(c100;TB;W24H12)'
73
+ end
74
+
75
+ it_should_behave_like '文字コードフィルタが動作しているとき'
76
+ end
77
+
78
+ describe 'SoftBank 910T からのアクセス' do
79
+ let(:user_agent) do
80
+ 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1'
81
+ end
82
+
83
+ it_should_behave_like '文字コードフィルタが動作しているとき'
84
+ end
85
+ end
86
+
87
+ describe HankakuInputFilterController do
88
+ let(:controller) { 'hankaku_input_filter' }
89
+
90
+ describe 'DoCoMo SH902i からのアクセス' do
91
+ let(:user_agent) do
92
+ 'DoCoMo/2.0 SH902i(c100;TB;W24H12)'
93
+ end
94
+
95
+ it_should_behave_like '文字コードフィルタが動作しているとき'
96
+ end
97
+
98
+ describe 'SoftBank 910T からのアクセス' do
99
+ let(:user_agent) do
100
+ 'SoftBank/1.0/910T/TJ001/SN000000000000000 Browser/NetFront/3.3 Profile/MIDP-2.0 Configuration/CLDC-1.1'
101
+ end
102
+
103
+ it_should_behave_like '文字コードフィルタが動作しているとき'
104
+ end
105
+ end
106
+ end
@@ -2,7 +2,7 @@ require 'rails_helper'
2
2
 
3
3
  describe TemplatePathController, 'integrated_views', type: :request do
4
4
  before do
5
- page.driver.header('User-Agent', user_agent)
5
+ page.driver.headers = { 'User-Agent' => user_agent }
6
6
  end
7
7
 
8
8
  describe 'index' do
@@ -1,9 +1,9 @@
1
- require 'rails_helper'
1
+ require 'system_helper'
2
2
 
3
3
  describe Admin::TopController, type: :feature do
4
4
  describe "GET 'full_path'" do
5
5
  before do
6
- page.driver.header('user_agent', user_agent)
6
+ page.driver.headers = { 'User-Agent' => user_agent }
7
7
  end
8
8
 
9
9
  context 'PCからのアクセスの場合' do
@@ -1,10 +1,10 @@
1
- require 'rails_helper'
1
+ require 'system_helper'
2
2
 
3
3
  describe 'jpmobile integration spec', type: :feature do
4
4
  include Jpmobile::Util
5
5
 
6
6
  before do
7
- page.driver.header('User-Agent', user_agent)
7
+ page.driver.headers = { 'User-Agent' => user_agent }
8
8
  end
9
9
 
10
10
  shared_examples_for 'hankaku_filter input: true のとき' do
@@ -38,11 +38,6 @@ describe 'jpmobile integration spec', type: :feature do
38
38
  end
39
39
 
40
40
  shared_examples_for '文字コードフィルタが動作しているとき' do
41
- it 'はhtml以外は変換しないこと' do
42
- visit "/#{controller}/rawdata"
43
- expect(page.body.encode('UTF-8')).to have_content('アブラカダブラ')
44
- expect(page.response_headers['Content-Type']).not_to match(/charset/i)
45
- end
46
41
  it 'response.bodyが空のときは文字コードを変更しないこと' do
47
42
  visit "/#{controller}/empty"
48
43
  expect(page.response_headers['Content-Type']).to match(/utf-8/i)
@@ -0,0 +1,14 @@
1
+ require 'capybara/cuprite'
2
+
3
+ Capybara.register_driver(:cuprite) do |app|
4
+ Capybara::Cuprite::Driver.new(
5
+ app,
6
+ **{
7
+ window_size: [1200, 800],
8
+ browser_options: {},
9
+ inspector: true,
10
+ },
11
+ )
12
+ end
13
+
14
+ Capybara.default_driver = Capybara.javascript_driver = :cuprite
@@ -0,0 +1,3 @@
1
+ require 'rails_helper'
2
+
3
+ Dir[File.join(__dir__, 'system/support/**/*.rb')].sort.each {|file| require file }