marty 2.3.14 → 2.3.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/app/models/marty/delorean_rule.rb +2 -3
- data/lib/marty/util.rb +15 -0
- data/lib/marty/version.rb +1 -1
- data/spec/controllers/job_controller_spec.rb +1 -1
- data/spec/features/enum_spec.rb +2 -2
- data/spec/features/log_view_spec.rb +5 -5
- data/spec/features/rule_spec.rb +30 -30
- data/spec/features/user_view_spec.rb +2 -0
- data/spec/lib/logger_spec.rb +1 -1
- data/spec/models/event_spec.rb +1 -1
- data/spec/models/promise_spec.rb +1 -1
- data/spec/models/user_spec.rb +6 -6
- data/spec/spec_helper.rb +9 -69
- data/spec/support/chromedriver.rb +41 -0
- data/spec/support/components/netzke_combobox.rb +57 -0
- data/spec/support/components/netzke_grid.rb +356 -0
- data/spec/support/custom_matchers.rb +18 -0
- data/spec/support/custom_selectors.rb +49 -0
- data/spec/support/delayed_job_helpers.rb +1 -1
- data/spec/support/download_helper.rb +52 -0
- data/spec/support/helper.rb +20 -0
- data/spec/support/netzke.rb +306 -0
- data/spec/support/performance_helper.rb +26 -0
- data/spec/support/post_run_logger.rb +32 -0
- data/spec/support/{spec_setup.rb → setup.rb} +19 -6
- data/spec/support/shared_connection.rb +31 -0
- data/spec/support/{clean_db_helpers.rb → shared_connection_db_helpers.rb} +2 -2
- data/spec/support/structure_compare.rb +62 -0
- data/spec/support/suite.rb +27 -0
- data/spec/support/{integration_helpers.rb → users.rb} +11 -9
- metadata +18 -6
- data/spec/support/user_helpers.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a297a85d0d4cdfde6d667e399b64684900dba8e9b9faaffa355737c8c5c5678b
|
4
|
+
data.tar.gz: 46c85fe0f1c7de9d3fba4d55b216d3e7daa24cc6a9f76cf1d75befb15cdf5284
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac982f3abebddb0f92269d41eed6c100c297feac1a9726693abaeba7b93b3d0c281525f2df3ed7d94d43e67a12a95eb2782f65d8010ab94e4e4157b43bb5bbf6
|
7
|
+
data.tar.gz: f4816a56f8b3b61f72acb67faeffdd17f55010db418ab520f60f11c2058c123928c54e813c78e28c9b22a94b45620ea84568b091de90b41352735334da6658a7
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
marty (2.3.
|
4
|
+
marty (2.3.15)
|
5
5
|
aws-sigv4 (~> 1.0, >= 1.0.2)
|
6
6
|
axlsx (= 3.0.0pre)
|
7
7
|
coderay
|
@@ -106,7 +106,7 @@ GEM
|
|
106
106
|
i18n (0.9.5)
|
107
107
|
concurrent-ruby (~> 1.0)
|
108
108
|
io-like (0.3.0)
|
109
|
-
json-schema (2.8.
|
109
|
+
json-schema (2.8.1)
|
110
110
|
addressable (>= 2.4)
|
111
111
|
loofah (2.2.2)
|
112
112
|
crass (~> 1.0.2)
|
@@ -152,10 +152,9 @@ class Marty::DeloreanRule < Marty::BaseRule
|
|
152
152
|
estack_full = resh.delete(:err_stack)
|
153
153
|
estack = estack_full && {
|
154
154
|
err_stack: estack_full.select{ |l| l.starts_with?('DELOREAN')}} || {}
|
155
|
+
detail = { input: params, dgparams: dgparams} + resh + estack
|
155
156
|
Marty::Logger.info("Rule Log #{ruleh['name']}",
|
156
|
-
|
157
|
-
dgparams: dgparams } + resh + estack
|
158
|
-
)
|
157
|
+
Marty::Util.scrub_obj(detail))
|
159
158
|
end
|
160
159
|
end
|
161
160
|
end
|
data/lib/marty/util.rb
CHANGED
@@ -132,4 +132,19 @@ module Marty::Util
|
|
132
132
|
URI.encode("#{Marty::Util.marty_path}/report?data=#{data}"\
|
133
133
|
"&reptitle=#{title}&format=#{format}")
|
134
134
|
end
|
135
|
+
|
136
|
+
def self.scrub_obj(obj)
|
137
|
+
trav = lambda {|o|
|
138
|
+
if o.is_a?(Hash)
|
139
|
+
return o.each_with_object({}) {|(k, v), h| h[k] = trav.call(v)}
|
140
|
+
elsif o.is_a?(Array)
|
141
|
+
return o.map {|v| trav.call(v)}
|
142
|
+
elsif o.to_s.length > 10000
|
143
|
+
o.class.to_s
|
144
|
+
else
|
145
|
+
o
|
146
|
+
end
|
147
|
+
}
|
148
|
+
trav.call(obj)
|
149
|
+
end
|
135
150
|
end
|
data/lib/marty/version.rb
CHANGED
@@ -15,7 +15,7 @@ describe Marty::JobController, slow: true do
|
|
15
15
|
|
16
16
|
# Needed here because shutting transactional fixtures off
|
17
17
|
# means we lose the globally set uesr
|
18
|
-
Mcfly.whodunnit =
|
18
|
+
Mcfly.whodunnit = system_user
|
19
19
|
|
20
20
|
Marty::Script.load_script_bodies(promise_bodies, Date.today)
|
21
21
|
|
data/spec/features/enum_spec.rb
CHANGED
@@ -178,12 +178,12 @@ feature 'test netzke + pg_enum compatibility', js: true do
|
|
178
178
|
|
179
179
|
and_by "filter form by state_enum ASCENDING" do
|
180
180
|
press("Enum state")
|
181
|
-
expect(lp_grid.
|
181
|
+
expect(lp_grid.get_col_vals(:enum_state)).to eq(["AS","AZ","DC","WA"])
|
182
182
|
end
|
183
183
|
|
184
184
|
and_by "filter form by state_enum DESCENDING" do
|
185
185
|
press("Enum state")
|
186
|
-
expect(lp_grid.
|
186
|
+
expect(lp_grid.get_col_vals(:enum_state)).to eq(["WA","DC","AZ","AS"])
|
187
187
|
end
|
188
188
|
|
189
189
|
end
|
@@ -45,7 +45,7 @@ feature 'logger view', js: true, capybara: true do
|
|
45
45
|
press('System')
|
46
46
|
show_submenu('Log Maintenance')
|
47
47
|
press('View Log')
|
48
|
-
|
48
|
+
wait_for_ajax
|
49
49
|
|
50
50
|
exp_types = ["fatal", "error", "info", "debug", "warn"]
|
51
51
|
exp_messages = ["fatal message", "error message",
|
@@ -72,11 +72,11 @@ feature 'logger view', js: true, capybara: true do
|
|
72
72
|
wait_for_ajax
|
73
73
|
cnt = logview.row_count()
|
74
74
|
expect(cnt).to eq(exp_count)
|
75
|
-
types = logview.
|
76
|
-
messages = logview.
|
77
|
-
details = logview.
|
75
|
+
types = logview.get_col_vals('message_type', cnt, 0)
|
76
|
+
messages = logview.get_col_vals('message', cnt, 0)
|
77
|
+
details = logview.get_col_vals('details', cnt, 0).
|
78
78
|
map { |d| CGI.unescapeHTML(d) }
|
79
|
-
ts = logview.
|
79
|
+
ts = logview.get_col_vals('timestamp_custom', cnt, 0)
|
80
80
|
expect(ts).to eq(@ts.slice(0,exp_count))
|
81
81
|
expect(types).to eq(exp_types.slice(0,exp_count))
|
82
82
|
expect(messages).to eq(exp_messages.slice(0,exp_count))
|
data/spec/features/rule_spec.rb
CHANGED
@@ -200,7 +200,7 @@ feature 'rule view', js: true do
|
|
200
200
|
exp = "Computed - Error in rule 'abc' field 'computed_guards': Syntax error on line 1"
|
201
201
|
expect(page).to have_content(exp)
|
202
202
|
sleep 2 # sleep needed for message to clear, otherwise failing tests could
|
203
|
-
|
203
|
+
# pass due to prior messages
|
204
204
|
|
205
205
|
# lhs is not identifier - BaseRuleView#simple_to_has will raise
|
206
206
|
fill_in(:computed_guards, with: '0sadf = 123j')
|
@@ -307,7 +307,7 @@ computed_value = if paramb
|
|
307
307
|
then param1 / (grid1_grid_result||1)
|
308
308
|
else (grid2_grid_result||1) / param1
|
309
309
|
EOL
|
310
|
-
names = mrv.
|
310
|
+
names = mrv.get_col_vals(:name, 9, 0)
|
311
311
|
idx = names.index{|n|n=='Rule3'}+1
|
312
312
|
mrv.select_row(idx)
|
313
313
|
press("Edit")
|
@@ -326,9 +326,9 @@ EOL
|
|
326
326
|
go_to_xyz_rules
|
327
327
|
xrv = netzke_find("xyz_rule_view")
|
328
328
|
expect(page).to have_content("Rule type")
|
329
|
-
expect(xrv.
|
330
|
-
|
331
|
-
|
329
|
+
expect(xrv.get_col_vals(:name, 5, 0)).to eq(["ZRule1", "ZRule2",
|
330
|
+
"ZRule3", "ZRule4",
|
331
|
+
"ZRule5"])
|
332
332
|
xrv.select_row(1)
|
333
333
|
press("Edit")
|
334
334
|
fill_in("Range Guard 1", with: "[100,200)")
|
@@ -359,37 +359,37 @@ EOL
|
|
359
359
|
"bv"=>"base_value"}}
|
360
360
|
|
361
361
|
expect(r.first.as_json).to include(exp)
|
362
|
-
expect(xrv.
|
363
|
-
|
362
|
+
expect(xrv.get_col_vals(:g_string, 8, 0)).to eq(["aaa", "bbb", "ccc", "ddd",
|
363
|
+
"eee", "eee", "eee", "eee"])
|
364
364
|
click_column(xrv, "String list Guard")
|
365
|
-
expect(xrv.
|
366
|
-
|
365
|
+
expect(xrv.get_col_vals(:g_string, 8, 0)).to eq(["eee", "eee", "eee", "eee",
|
366
|
+
"ddd", "ccc", "bbb", "aaa"])
|
367
367
|
column_filter(xrv, "String list Guard", "eee")
|
368
368
|
rc = xrv.row_count
|
369
|
-
expect(xrv.
|
369
|
+
expect(xrv.get_col_vals(:g_string,rc,0)).to eq(["eee", "eee", "eee", "eee"])
|
370
370
|
column_filter_toggle(xrv, "String list Guard")
|
371
371
|
rc = xrv.row_count
|
372
|
-
expect(xrv.
|
373
|
-
|
372
|
+
expect(xrv.get_col_vals(:g_string,rc,0)).to eq(["eee", "eee", "eee", "eee",
|
373
|
+
"ddd", "ccc", "bbb", "aaa"])
|
374
374
|
column_filter(xrv, "Grids", "Grid1")
|
375
375
|
rc = xrv.row_count
|
376
|
-
|
377
|
-
expect(xrv.
|
378
|
-
|
376
|
+
# netzke reports jsonb as string
|
377
|
+
expect(xrv.get_col_vals(:grids,rc,0)).to eq([%Q({"grid1":"DataGrid1"}),
|
378
|
+
%Q({"grid1":"DataGrid1"})])
|
379
379
|
column_filter_toggle(xrv, "Grids")
|
380
380
|
rc = xrv.row_count
|
381
|
-
expect(xrv.
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
381
|
+
expect(xrv.get_col_vals(:grids,rc,0)).to eq([%Q({"grid1":"DataGrid3"}),
|
382
|
+
%Q({"grid1":"DataGrid3"}),
|
383
|
+
%Q({"grid1":"DataGrid3"}),
|
384
|
+
%Q({"grid1":"DataGrid3"}),
|
385
|
+
%Q({"grid1":"DataGrid3"}),
|
386
|
+
%Q({"grid1":"DataGrid2"}),
|
387
|
+
%Q({"grid1":"DataGrid1"}),
|
388
|
+
%Q({"grid1":"DataGrid1"})])
|
389
389
|
press("Applications")
|
390
390
|
press("Data Grids")
|
391
391
|
dgv = netzke_find("data_grid_view")
|
392
|
-
cvs = dgv.
|
392
|
+
cvs = dgv.get_col_vals(:name, 4, 0)
|
393
393
|
ind1 = cvs.index("DataGrid1")+1
|
394
394
|
ind4 = cvs.index("DataGrid4")+1
|
395
395
|
dgv.select_row(ind1)
|
@@ -406,8 +406,8 @@ EOL
|
|
406
406
|
go_to_xyz_rules
|
407
407
|
wait_for_ajax
|
408
408
|
|
409
|
-
names = xrv.
|
410
|
-
gvs = xrv.
|
409
|
+
names = xrv.get_col_vals(:name, 5, 0)
|
410
|
+
gvs = xrv.get_col_vals(:grids, 5, 0)
|
411
411
|
g1h = {"grid1"=>"DataGrid1 new"}
|
412
412
|
expect(JSON.parse(gvs[names.index("ZRule1")])).to eq(g1h)
|
413
413
|
expect(JSON.parse(gvs[names.index("ZRule2")])).to eq(g1h)
|
@@ -415,14 +415,14 @@ EOL
|
|
415
415
|
go_to_my_rules
|
416
416
|
wait_for_ajax
|
417
417
|
|
418
|
-
names = mrv.
|
419
|
-
gvs = mrv.
|
420
|
-
rvs = mrv.
|
418
|
+
names = mrv.get_col_vals(:name, 9, 0)
|
419
|
+
gvs = mrv.get_col_vals(:grids, 9, 0)
|
420
|
+
rvs = mrv.get_col_vals(:results, 9, 0)
|
421
421
|
expect(JSON.parse(gvs[names.index('abc')])).to eq(g1h)
|
422
422
|
expect(JSON.parse(gvs[names.index('Rule2b')])).to eq(g1h +
|
423
423
|
{"grid2"=>"DataGrid2"})
|
424
424
|
expect(JSON.parse(rvs[names.index('Rule5')])["other_grid"]).to eq(
|
425
|
-
|
425
|
+
'"DataGrid4 new"')
|
426
426
|
|
427
427
|
end
|
428
428
|
end
|
data/spec/lib/logger_spec.rb
CHANGED
@@ -68,7 +68,7 @@ module Marty
|
|
68
68
|
|
69
69
|
# Needed here because shutting transactional fixtures off
|
70
70
|
# means we lose the globally set user
|
71
|
-
Mcfly.whodunnit =
|
71
|
+
Mcfly.whodunnit = system_user
|
72
72
|
|
73
73
|
Marty::Script.load_script_bodies(promise_bodies, Date.today)
|
74
74
|
start_delayed_job
|
data/spec/models/event_spec.rb
CHANGED
@@ -12,7 +12,7 @@ describe Marty::Event do
|
|
12
12
|
|
13
13
|
# Needed here because shutting transactional fixtures off
|
14
14
|
# means we lose the globally set user
|
15
|
-
Mcfly.whodunnit =
|
15
|
+
Mcfly.whodunnit = system_user
|
16
16
|
|
17
17
|
Marty::Script.load_script_bodies(promise_bodies, Date.today)
|
18
18
|
start_delayed_job
|
data/spec/models/promise_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe Marty::Promise, slow: true do
|
|
10
10
|
|
11
11
|
# Needed here because shutting transactional fixtures off
|
12
12
|
# means we lose the globally set user
|
13
|
-
Mcfly.whodunnit =
|
13
|
+
Mcfly.whodunnit = system_user
|
14
14
|
|
15
15
|
Marty::Script.load_script_bodies(promise_bodies, Date.today)
|
16
16
|
|
data/spec/models/user_spec.rb
CHANGED
@@ -4,11 +4,11 @@ module Marty
|
|
4
4
|
describe User do
|
5
5
|
before(:each) do
|
6
6
|
Rails.configuration.marty.system_account =
|
7
|
-
|
7
|
+
system_user.login
|
8
8
|
end
|
9
9
|
|
10
10
|
let (:tuser) {
|
11
|
-
|
11
|
+
create_user('other_user')
|
12
12
|
}
|
13
13
|
|
14
14
|
describe "validations" do
|
@@ -22,7 +22,7 @@ module Marty
|
|
22
22
|
|
23
23
|
it "should require unique login" do
|
24
24
|
expect(Mcfly.whodunnit).to_not be_nil
|
25
|
-
user =
|
25
|
+
user = system_user.dup
|
26
26
|
expect(user).to_not be_valid
|
27
27
|
expect(user.errors[:login].to_s).to include('already been taken')
|
28
28
|
user.login = 'marty2'
|
@@ -30,7 +30,7 @@ module Marty
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should not allow Gemini account to be de-activated" do
|
33
|
-
user =
|
33
|
+
user = system_user
|
34
34
|
user.active = false
|
35
35
|
expect(user).to_not be_valid
|
36
36
|
expect(user.errors[:base].to_s).
|
@@ -38,14 +38,14 @@ module Marty
|
|
38
38
|
end
|
39
39
|
|
40
40
|
it "should not allow accounts to be deleted" do
|
41
|
-
user =
|
41
|
+
user = system_user
|
42
42
|
user.destroy
|
43
43
|
expect(user.destroyed?).to be false
|
44
44
|
end
|
45
45
|
|
46
46
|
it "should not allow user managers to edit the Gemini account" do
|
47
47
|
Mcfly.whodunnit = tuser
|
48
|
-
user =
|
48
|
+
user = system_user
|
49
49
|
allow_any_instance_of(Marty::User).to receive(:user_manager_only).
|
50
50
|
and_return(true)
|
51
51
|
user.firstname = 'Testing'
|
data/spec/spec_helper.rb
CHANGED
@@ -3,67 +3,22 @@ ENV["RAILS_ENV"] ||= "test"
|
|
3
3
|
require 'dummy/config/application'
|
4
4
|
require 'rspec/rails'
|
5
5
|
require 'database_cleaner'
|
6
|
-
|
6
|
+
|
7
|
+
support = Pathname.new(__FILE__).parent.to_s + '/support'
|
8
|
+
require "#{support}/suite"
|
9
|
+
require "#{support}/shared_connection"
|
7
10
|
|
8
11
|
Dummy::Application.initialize! unless Dummy::Application.initialized?
|
9
12
|
|
10
13
|
ActiveRecord::Migrator.migrate File.expand_path("../../db/migrate/", __FILE__)
|
11
14
|
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
|
12
15
|
|
13
|
-
Dir[Rails.root.join("../support/**/*.rb")].each { |f| require f }
|
14
|
-
|
15
|
-
def register_chrome_driver driver = :chrome, options={}
|
16
|
-
Capybara.register_driver driver do |app|
|
17
|
-
caps = Selenium::WebDriver::Remote::Capabilities.
|
18
|
-
chrome(options + {pageLoadStrategy: 'none'})
|
19
|
-
|
20
|
-
Capybara::Selenium::Driver.new(app,
|
21
|
-
browser: :chrome,
|
22
|
-
desired_capabilities: caps)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
CLASSES_TO_EXCLUDE_FROM_SHARED = ["Marty::Log"]
|
27
|
-
class ActiveRecord::Base
|
28
|
-
mattr_accessor :shared_connection
|
29
|
-
class << self
|
30
|
-
alias_method :orig_connection, :connection
|
31
|
-
end
|
32
|
-
def self.clear_connection
|
33
|
-
@@shared_connection = nil
|
34
|
-
end
|
35
|
-
|
36
|
-
clear_connection
|
37
|
-
|
38
|
-
def self.connection
|
39
|
-
CLASSES_TO_EXCLUDE_FROM_SHARED.include?(model_name) ? orig_connection :
|
40
|
-
@@shared_connection ||
|
41
|
-
ConnectionPool::Wrapper.new(:size => 1) {retrieve_connection}
|
42
|
-
end
|
43
|
-
|
44
|
-
def self.reset_shared_connection
|
45
|
-
@@shared_connection = ConnectionPool::Wrapper.
|
46
|
-
new(:size => 1) {retrieve_connection}
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
register_chrome_driver(:chrome, chromeOptions: { args: %w[start-maximized]})
|
51
|
-
register_chrome_driver(:headless,
|
52
|
-
chromeOptions: {
|
53
|
-
args: %w[headless disable-gpu window-size=3840,2160]
|
54
|
-
})
|
55
|
-
|
56
|
-
Capybara.javascript_driver = ENV['HEADLESS'] == 'true' ? :headless : :chrome
|
57
|
-
|
58
|
-
ActiveRecord::Base.shared_connection = ActiveRecord::Base.connection
|
59
|
-
|
60
16
|
RSpec.configure do |config|
|
61
|
-
config.include
|
62
|
-
config.include
|
63
|
-
config.include
|
64
|
-
config.include Marty::IntegrationHelpers
|
65
|
-
config.include MartyRSpec::Util
|
17
|
+
config.include Marty::RSpec::Suite
|
18
|
+
config.include Marty::RSpec::SharedConnection
|
19
|
+
config.include Marty::RSpec::SharedConnectionDbHelpers
|
66
20
|
|
21
|
+
#RspecMarty::SharedConnection.classes_to_exclude_shared = ['Marty::Log']
|
67
22
|
Capybara.default_max_wait_time = 3
|
68
23
|
|
69
24
|
# TODO: Continue to remove should syntax from specs - remove this line to see
|
@@ -83,7 +38,7 @@ RSpec.configure do |config|
|
|
83
38
|
end
|
84
39
|
|
85
40
|
config.before(:each) do
|
86
|
-
|
41
|
+
marty_whodunnit
|
87
42
|
end
|
88
43
|
|
89
44
|
config.after(:each, :js => true) do |example|
|
@@ -102,19 +57,4 @@ RSpec.configure do |config|
|
|
102
57
|
config.use_transactional_fixtures = true
|
103
58
|
|
104
59
|
Netzke::Testing.rspec_init(config)
|
105
|
-
|
106
|
-
# FIXME: temporary monkey patch to fix marty_rspec for new extjs/rails
|
107
|
-
module MartyRSpec
|
108
|
-
module Components
|
109
|
-
class NetzkeGrid
|
110
|
-
def get_row_vals row
|
111
|
-
res = run_js <<-JS
|
112
|
-
#{ext_var(grid, 'grid')}
|
113
|
-
return Ext.encode(#{ext_row(row.to_i - 1, 'grid')}.data);
|
114
|
-
JS
|
115
|
-
JSON.parse(res)
|
116
|
-
end
|
117
|
-
end
|
118
|
-
end
|
119
|
-
end
|
120
60
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'selenium-webdriver'
|
2
|
+
require Pathname.new(__FILE__).parent.to_s + '/download_helper'
|
3
|
+
|
4
|
+
module Marty; module RSpec; module Chromedriver
|
5
|
+
def self.register_chrome_driver driver= :chrome, opts={}
|
6
|
+
Capybara.register_driver driver do |app|
|
7
|
+
copts = {
|
8
|
+
chromeOptions: opts.deep_merge(
|
9
|
+
prefs: {'download.default_directory' =>
|
10
|
+
Marty::RSpec::DownloadHelper::PATH.to_s}),
|
11
|
+
pageLoadStrategy: 'none',
|
12
|
+
}
|
13
|
+
caps = Selenium::WebDriver::Remote::Capabilities.chrome(copts)
|
14
|
+
driver = Capybara::Selenium::Driver.new(app,
|
15
|
+
browser: :chrome,
|
16
|
+
desired_capabilities: caps)
|
17
|
+
yield driver if block_given?
|
18
|
+
driver
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
register_chrome_driver
|
23
|
+
|
24
|
+
headless_args = %w[headless disable-gpu window-size=3840,2160]
|
25
|
+
register_chrome_driver(:headless_chrome, args: headless_args) do |driver|
|
26
|
+
|
27
|
+
# workaround to enable downloading with headless chrome
|
28
|
+
bridge = driver.browser.send(:bridge)
|
29
|
+
bridge.http.call(:post,
|
30
|
+
"/session/#{bridge.session_id}/chromium/send_command",
|
31
|
+
cmd: 'Page.setDownloadBehavior',
|
32
|
+
params: {
|
33
|
+
behavior: 'allow',
|
34
|
+
downloadPath: Marty::RSpec::DownloadHelper::PATH.to_s
|
35
|
+
})
|
36
|
+
end
|
37
|
+
|
38
|
+
Capybara.default_driver = :chrome
|
39
|
+
Capybara.javascript_driver = ENV['HEADLESS'] == 'true' ?
|
40
|
+
:headless_chrome : :chrome
|
41
|
+
end end end
|