marty 2.5.2 → 2.5.4
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 +5 -5
- data/.gitignore +4 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +11 -589
- data/Gemfile +9 -9
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -3
- data/app/components/marty/api_auth_view.rb +3 -3
- data/app/components/marty/api_config_view.rb +8 -8
- data/app/components/marty/api_log_view.rb +16 -20
- data/app/components/marty/auth_app.rb +6 -6
- data/app/components/marty/base_rule_view.rb +27 -19
- data/app/components/marty/config_view.rb +12 -9
- data/app/components/marty/data_grid_view.rb +26 -26
- data/app/components/marty/delorean_rule_view.rb +0 -1
- data/app/components/marty/event_view.rb +27 -27
- data/app/components/marty/extras/layout.rb +26 -26
- data/app/components/marty/extras/misc.rb +2 -2
- data/app/components/marty/grid.rb +13 -13
- data/app/components/marty/grid_append_only.rb +0 -1
- data/app/components/marty/import_type_view.rb +13 -13
- data/app/components/marty/import_view.rb +17 -16
- data/app/components/marty/log_view.rb +16 -14
- data/app/components/marty/main_auth_app.rb +59 -59
- data/app/components/marty/main_auth_app/client/main_auth_app.js +3 -3
- data/app/components/marty/mcfly_grid_panel.rb +10 -10
- data/app/components/marty/new_posting_form.rb +11 -11
- data/app/components/marty/new_posting_window.rb +0 -1
- data/app/components/marty/posting_grid.rb +12 -13
- data/app/components/marty/promise_view.rb +6 -6
- data/app/components/marty/report_form.rb +50 -53
- data/app/components/marty/report_select.rb +27 -27
- data/app/components/marty/reporting.rb +4 -4
- data/app/components/marty/script_form.rb +40 -42
- data/app/components/marty/script_grid.rb +24 -24
- data/app/components/marty/script_tester.rb +40 -42
- data/app/components/marty/scripting.rb +25 -27
- data/app/components/marty/simple_app.rb +24 -9
- data/app/components/marty/tag_grid.rb +12 -13
- data/app/components/marty/user_view.rb +35 -35
- data/app/controllers/marty/application_controller.rb +3 -4
- data/app/controllers/marty/components_controller.rb +1 -1
- data/app/controllers/marty/delayed_job_controller.rb +1 -0
- data/app/controllers/marty/diagnostic/controller.rb +4 -6
- data/app/controllers/marty/job_controller.rb +6 -6
- data/app/controllers/marty/report_controller.rb +11 -11
- data/app/controllers/marty/rpc_controller.rb +15 -16
- data/app/helpers/marty/script_set.rb +4 -4
- data/app/models/marty/api_auth.rb +4 -5
- data/app/models/marty/api_config.rb +1 -1
- data/app/models/marty/base.rb +9 -8
- data/app/models/marty/base_rule.rb +18 -13
- data/app/models/marty/config.rb +4 -5
- data/app/models/marty/data_grid.rb +157 -181
- data/app/models/marty/delorean_rule.rb +63 -62
- data/app/models/marty/enum.rb +1 -1
- data/app/models/marty/event.rb +56 -59
- data/app/models/marty/helper.rb +38 -6
- data/app/models/marty/import_type.rb +6 -6
- data/app/models/marty/log.rb +3 -2
- data/app/models/marty/name_validator.rb +3 -2
- data/app/models/marty/pg_enum.rb +3 -4
- data/app/models/marty/posting.rb +20 -24
- data/app/models/marty/promise.rb +28 -30
- data/app/models/marty/script.rb +30 -28
- data/app/models/marty/tag.rb +8 -8
- data/app/models/marty/token.rb +2 -2
- data/app/models/marty/user.rb +24 -23
- data/app/models/marty/vw_promise.rb +10 -11
- data/config/routes.rb +2 -2
- data/delorean/blame_report.dl +268 -0
- data/{spec/dummy/delorean/fields.dl → delorean/marty_fields.dl} +8 -0
- data/delorean/table_report.dl +34 -0
- data/docker-compose.dummy.yml +2 -3
- data/lib/marty/aws/base.rb +8 -8
- data/lib/marty/aws/request.rb +4 -4
- data/lib/marty/cache_adapters/mcfly_ruby_cache.rb +1 -0
- data/lib/marty/content_handler.rb +25 -25
- data/lib/marty/data_change.rb +49 -71
- data/lib/marty/data_conversion.rb +20 -28
- data/lib/marty/data_exporter.rb +25 -28
- data/lib/marty/data_importer.rb +25 -27
- data/lib/marty/engine.rb +1 -2
- data/lib/marty/json_schema.rb +22 -24
- data/lib/marty/logger.rb +6 -9
- data/lib/marty/mcfly_model.rb +20 -24
- data/lib/marty/migrations.rb +37 -35
- data/lib/marty/monkey.rb +33 -33
- data/lib/marty/permissions.rb +18 -18
- data/lib/marty/promise_job.rb +17 -17
- data/lib/marty/promise_proxy.rb +6 -6
- data/lib/marty/relation.rb +6 -7
- data/lib/marty/rpc_call.rb +13 -12
- data/lib/marty/rule_script_set.rb +32 -28
- data/lib/marty/schema_helper.rb +37 -51
- data/lib/marty/util.rb +25 -24
- data/lib/marty/version.rb +1 -1
- data/lib/marty/xl.rb +121 -115
- data/make-dummy.mk +3 -0
- data/marty.gemspec +21 -21
- data/other/marty/api/base.rb +34 -35
- data/other/marty/diagnostic/aws/ec2_instance.rb +8 -8
- data/other/marty/diagnostic/base.rb +13 -14
- data/other/marty/diagnostic/collection.rb +2 -1
- data/other/marty/diagnostic/connections.rb +8 -6
- data/other/marty/diagnostic/database.rb +1 -0
- data/other/marty/diagnostic/delayed_job_version.rb +7 -9
- data/other/marty/diagnostic/delayed_job_worker_total_count.rb +1 -1
- data/other/marty/diagnostic/delayed_job_workers.rb +1 -1
- data/other/marty/diagnostic/environment_variables.rb +17 -15
- data/other/marty/diagnostic/fatal.rb +1 -1
- data/other/marty/diagnostic/node.rb +5 -9
- data/other/marty/diagnostic/nodes.rb +7 -5
- data/other/marty/diagnostic/packer.rb +7 -7
- data/other/marty/diagnostic/reporter.rb +24 -27
- data/other/marty/diagnostic/version.rb +3 -5
- data/script/rails +2 -1
- data/spec/controllers/application_controller_spec.rb +6 -6
- data/spec/controllers/delayed_job_controller_spec.rb +4 -4
- data/spec/controllers/diagnostic/controller_spec.rb +59 -60
- data/spec/controllers/job_controller_spec.rb +68 -69
- data/spec/controllers/rpc_controller_spec.rb +353 -359
- data/spec/controllers/rpc_import_spec.rb +15 -16
- data/spec/dummy/delorean/blame_report.dl +110 -15
- data/spec/dummy/delorean/data_report.dl +4 -4
- data/spec/dummy/delorean/marty_fields.dl +63 -0
- data/spec/dummy/delorean/table_report.dl +34 -0
- data/spec/features/auth_app_spec.rb +1 -2
- data/spec/features/data_import_spec.rb +2 -3
- data/spec/features/enum_spec.rb +42 -46
- data/spec/features/jobs_dashboard_spec.rb +14 -8
- data/spec/features/log_view_spec.rb +40 -43
- data/spec/features/reporting_spec.rb +15 -15
- data/spec/features/rule_spec.rb +195 -190
- data/spec/features/scripting_spec.rb +17 -20
- data/spec/features/scripting_test_spec.rb +32 -33
- data/spec/features/user_view_spec.rb +15 -17
- data/spec/job_helper.rb +11 -11
- data/spec/lib/data_blame_spec.rb +82 -0
- data/spec/lib/data_exporter_spec.rb +31 -32
- data/spec/lib/data_importer_spec.rb +382 -395
- data/spec/lib/delorean_query_spec.rb +117 -119
- data/spec/lib/json_schema_spec.rb +382 -392
- data/spec/lib/logger_spec.rb +23 -24
- data/spec/lib/mcfly_model_spec.rb +112 -109
- data/spec/lib/migrations_spec.rb +10 -10
- data/spec/lib/struct_compare_spec.rb +6 -6
- data/spec/lib/table_report_spec.rb +90 -0
- data/spec/lib/xl_spec.rb +63 -65
- data/spec/lib/xl_styles_spec.rb +16 -19
- data/spec/models/api_auth_spec.rb +30 -30
- data/spec/models/config_spec.rb +32 -32
- data/spec/models/data_grid_spec.rb +642 -655
- data/spec/models/event_spec.rb +96 -88
- data/spec/models/import_type_spec.rb +20 -20
- data/spec/models/posting_spec.rb +35 -35
- data/spec/models/promise_spec.rb +5 -5
- data/spec/models/rule_spec.rb +280 -269
- data/spec/models/script_spec.rb +27 -18
- data/spec/models/user_spec.rb +9 -9
- data/spec/other/diagnostic/base_spec.rb +20 -19
- data/spec/other/diagnostic/collection_spec.rb +6 -5
- data/spec/other/diagnostic/delayed_job_version_spec.rb +1 -1
- data/spec/other/diagnostic/delayed_job_workers_spec.rb +8 -8
- data/spec/other/diagnostic/reporter_spec.rb +31 -33
- data/spec/spec_helper.rb +5 -5
- data/spec/support/chromedriver.rb +3 -5
- data/spec/support/components/netzke_combobox.rb +1 -1
- data/spec/support/components/netzke_grid.rb +17 -17
- data/spec/support/custom_matchers.rb +2 -2
- data/spec/support/download_helper.rb +1 -1
- data/spec/support/helper.rb +1 -2
- data/spec/support/netzke.rb +31 -31
- data/spec/support/performance_helper.rb +8 -8
- data/spec/support/post_run_logger.rb +1 -2
- data/spec/support/setup.rb +1 -4
- data/spec/support/shared_connection.rb +2 -2
- data/spec/support/structure_compare.rb +21 -22
- data/spec/support/suite.rb +1 -2
- data/spec/support/users.rb +5 -6
- metadata +32 -26
data/spec/models/promise_spec.rb
CHANGED
|
@@ -21,7 +21,7 @@ describe Marty::Promise, slow: true do
|
|
|
21
21
|
@time = DateTime.now
|
|
22
22
|
expect(Marty::Promise.count).to eq(0)
|
|
23
23
|
engine = Marty::ScriptSet.new.get_engine(NAME_A)
|
|
24
|
-
engine.background_eval(
|
|
24
|
+
engine.background_eval('Y', { 'p_title' => NAME_A }, ['d'])
|
|
25
25
|
sleep 5
|
|
26
26
|
Marty::Promise.cleanup
|
|
27
27
|
expect(Marty::Promise.count).to eq(10)
|
|
@@ -37,25 +37,25 @@ describe Marty::Promise, slow: true do
|
|
|
37
37
|
stop_delayed_job
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
it
|
|
40
|
+
it 'should retain jobs that were run less than 4 hours ago' do
|
|
41
41
|
Timecop.freeze(@time + 4.hours)
|
|
42
42
|
Marty::Promise.cleanup
|
|
43
43
|
expect(Marty::Promise.count).to eq(10)
|
|
44
44
|
end
|
|
45
45
|
|
|
46
|
-
it
|
|
46
|
+
it 'should cleanup jobs that are older than 4 hours' do
|
|
47
47
|
Timecop.freeze(@time + 4.hours + 1.minute)
|
|
48
48
|
Marty::Promise.cleanup
|
|
49
49
|
expect(Marty::Promise.count).to eq(0)
|
|
50
50
|
end
|
|
51
51
|
|
|
52
|
-
it
|
|
52
|
+
it 'should allow cleanup of all jobs when forced by admin' do
|
|
53
53
|
Timecop.freeze(@time + 4.hours)
|
|
54
54
|
Marty::Promise.cleanup(true)
|
|
55
55
|
expect(Marty::Promise.count).to eq(0)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
|
-
it
|
|
58
|
+
it 'should provide a live search scope for filtering by user or role' do
|
|
59
59
|
expect(Marty::VwPromise.live_search('XXX').size).to eq(0)
|
|
60
60
|
expect(Marty::VwPromise.live_search('marty').size).to eq(10)
|
|
61
61
|
expect(Marty::VwPromise.live_search('Admin').size).to eq(10)
|
data/spec/models/rule_spec.rb
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Marty::RuleSpec
|
|
4
|
-
describe
|
|
4
|
+
describe 'Rule' do
|
|
5
5
|
before(:all) do
|
|
6
6
|
@save_file = "/tmp/save_#{Process.pid}.psql"
|
|
7
7
|
save_clean_db(@save_file)
|
|
8
8
|
marty_whodunnit
|
|
9
9
|
Marty::Script.load_scripts
|
|
10
|
-
@ruleopts_myrule=['simple_result', 'computed_value', 'final_value',
|
|
11
|
-
|
|
12
|
-
@ruleopts_xyz=['bvlength', 'bv']
|
|
10
|
+
@ruleopts_myrule = ['simple_result', 'computed_value', 'final_value',
|
|
11
|
+
'grid_sum', 'c1', 'sr2']
|
|
12
|
+
@ruleopts_xyz = ['bvlength', 'bv']
|
|
13
13
|
end
|
|
14
14
|
after(:all) do
|
|
15
15
|
restore_clean_db(@save_file)
|
|
@@ -18,21 +18,21 @@ module Marty::RuleSpec
|
|
|
18
18
|
dt = DateTime.parse('2017-1-1')
|
|
19
19
|
p = File.expand_path('../../fixtures/csv/rule', __FILE__)
|
|
20
20
|
[Marty::DataGrid, Gemini::XyzRule, Gemini::MyRule].each do |klass|
|
|
21
|
-
f =
|
|
22
|
-
Marty::DataImporter.do_import(klass, File.read(f), dt, nil, nil,
|
|
21
|
+
f = '%s/%s.csv' % [p, klass.to_s.sub(/(Gemini|Marty)::/, '')]
|
|
22
|
+
Marty::DataImporter.do_import(klass, File.read(f), dt, nil, nil, ',')
|
|
23
23
|
end
|
|
24
24
|
Marty::Tag.do_create('2017-01-01', 'tag')
|
|
25
25
|
end
|
|
26
|
-
context
|
|
26
|
+
context 'validation' do
|
|
27
27
|
subject do
|
|
28
|
-
guards = (@g_array ? {
|
|
29
|
-
(@g_single ? {
|
|
30
|
-
(@g_string ? {
|
|
31
|
-
(@g_bool.nil? ? {} : {
|
|
32
|
-
(@g_nullbool.nil? ? {} : {
|
|
33
|
-
(@g_range ? {
|
|
34
|
-
(@g_integer ? {
|
|
35
|
-
Gemini::MyRule.create!(name:
|
|
28
|
+
guards = (@g_array ? { 'g_array' => @g_array } : {}) +
|
|
29
|
+
(@g_single ? { 'g_single' => @g_single } : {}) +
|
|
30
|
+
(@g_string ? { 'g_string' => @g_string } : {}) +
|
|
31
|
+
(@g_bool.nil? ? {} : { 'g_bool' => @g_bool }) +
|
|
32
|
+
(@g_nullbool.nil? ? {} : { 'g_nullbool' => @g_nullbool }) +
|
|
33
|
+
(@g_range ? { 'g_range' => @g_range } : {}) +
|
|
34
|
+
(@g_integer ? { 'g_integer' => @g_integer } : {})
|
|
35
|
+
Gemini::MyRule.create!(name: 'testrule',
|
|
36
36
|
rule_type: @rule_type,
|
|
37
37
|
start_dt: @start_dt || '2013-1-1',
|
|
38
38
|
end_dt: @end_dt,
|
|
@@ -42,85 +42,84 @@ module Marty::RuleSpec
|
|
|
42
42
|
results: @results || {}
|
|
43
43
|
)
|
|
44
44
|
end
|
|
45
|
-
it
|
|
45
|
+
it 'detects type errors' do
|
|
46
46
|
@rule_type = 'SimpleRule'
|
|
47
|
-
@g_integer =
|
|
48
|
-
expect{subject}.to raise_error(/Guards - Wrong type for 'g_integer'/)
|
|
47
|
+
@g_integer = 'abc'
|
|
48
|
+
expect { subject }.to raise_error(/Guards - Wrong type for 'g_integer'/)
|
|
49
49
|
end
|
|
50
|
-
it
|
|
51
|
-
@rule_type =
|
|
52
|
-
@g_array = [
|
|
53
|
-
expect{subject}.to raise_error(/Guards - Bad value 'abcd' for 'g_array'/)
|
|
50
|
+
it 'detects value errors 1' do
|
|
51
|
+
@rule_type = 'SimpleRule'
|
|
52
|
+
@g_array = ['G1V1', 'abcd']
|
|
53
|
+
expect { subject }.to raise_error(/Guards - Bad value 'abcd' for 'g_array'/)
|
|
54
54
|
end
|
|
55
|
-
it
|
|
56
|
-
@rule_type =
|
|
57
|
-
@g_array = [
|
|
55
|
+
it 'detects value errors 2' do
|
|
56
|
+
@rule_type = 'SimpleRule'
|
|
57
|
+
@g_array = ['G1V1', 'xyz', 'abc']
|
|
58
58
|
exp = /Guards - Bad values 'xyz', 'abc' for 'g_array'/
|
|
59
|
-
expect{subject}.to raise_error(exp)
|
|
59
|
+
expect { subject }.to raise_error(exp)
|
|
60
60
|
end
|
|
61
|
-
it
|
|
62
|
-
@rule_type =
|
|
63
|
-
@g_single = [
|
|
61
|
+
it 'detects arity errors 1' do
|
|
62
|
+
@rule_type = 'SimpleRule'
|
|
63
|
+
@g_single = ['G2V1', 'G2V2']
|
|
64
64
|
exp = /Guards - Wrong arity for 'g_single' .expected single got multi./
|
|
65
|
-
expect{subject}.to raise_error(exp)
|
|
65
|
+
expect { subject }.to raise_error(exp)
|
|
66
66
|
end
|
|
67
|
-
it
|
|
68
|
-
@rule_type =
|
|
69
|
-
@g_array =
|
|
67
|
+
it 'detects arity errors 2' do
|
|
68
|
+
@rule_type = 'SimpleRule'
|
|
69
|
+
@g_array = 'G1V1'
|
|
70
70
|
exp = /Guards - Wrong arity for 'g_array' .expected multi got single./
|
|
71
|
-
expect{subject}.to raise_error(exp)
|
|
71
|
+
expect { subject }.to raise_error(exp)
|
|
72
72
|
end
|
|
73
|
-
it
|
|
74
|
-
@rule_type =
|
|
75
|
-
@computed_guards = {
|
|
73
|
+
it 'detects errors in computed guards' do
|
|
74
|
+
@rule_type = 'SimpleRule'
|
|
75
|
+
@computed_guards = { 'guard1' => 'zvjsdf12.z8*' }
|
|
76
76
|
exp = /Computed - Error in rule 'testrule' field 'computed_guards': Syntax error/
|
|
77
|
-
expect{subject}.to raise_error(exp)
|
|
77
|
+
expect { subject }.to raise_error(exp)
|
|
78
78
|
end
|
|
79
|
-
it
|
|
80
|
-
@rule_type =
|
|
81
|
-
@results = {
|
|
82
|
-
@grids = {
|
|
79
|
+
it 'detects errors in computed results' do
|
|
80
|
+
@rule_type = 'SimpleRule'
|
|
81
|
+
@results = { 'does_not_compute' => 'zvjsdf12.z8*' }
|
|
82
|
+
@grids = { 'grid1' => 'DataGrid1', 'grid2' => 'DataGrid2' }
|
|
83
83
|
exp = /Computed - Error in rule 'testrule' field 'results': Syntax error/
|
|
84
|
-
expect{subject}.to raise_error(exp)
|
|
84
|
+
expect { subject }.to raise_error(exp)
|
|
85
85
|
end
|
|
86
|
-
it
|
|
87
|
-
@rule_type =
|
|
88
|
-
@results = {
|
|
89
|
-
@grids = {
|
|
86
|
+
it 'detects errors in computed results 2' do
|
|
87
|
+
@rule_type = 'SimpleRule'
|
|
88
|
+
@results = { 'does_not_compute' => 'zvjsdf12.z8*' }
|
|
89
|
+
@grids = { 'grid1' => 'DataGrid1', 'grid2' => 'DataGrid1', 'grid3' => 'DataGrid3' }
|
|
90
90
|
exp = /Computed - Error in rule 'testrule' field 'results': Syntax error/
|
|
91
|
-
expect{subject}.to raise_error(exp)
|
|
91
|
+
expect { subject }.to raise_error(exp)
|
|
92
92
|
end
|
|
93
|
-
it
|
|
94
|
-
@rule_type =
|
|
95
|
-
@results = {
|
|
96
|
-
@grids = {
|
|
93
|
+
it 'detects errors in computed results 3' do
|
|
94
|
+
@rule_type = 'SimpleRule'
|
|
95
|
+
@results = { 'does_not_compute' => 'zvjsdf12.z8*' }
|
|
96
|
+
@grids = { 'grid1' => 'DataGrid1', 'grid2' => 'DataGrid1', 'grid3' => 'DataGrid1' }
|
|
97
97
|
exp = /Computed - Error in rule 'testrule' field 'results': Syntax error/
|
|
98
|
-
expect{subject}.to raise_error(exp)
|
|
98
|
+
expect { subject }.to raise_error(exp)
|
|
99
99
|
end
|
|
100
|
-
it
|
|
101
|
-
@rule_type =
|
|
102
|
-
@grids = {
|
|
100
|
+
it 'reports bad grid names' do
|
|
101
|
+
@rule_type = 'SimpleRule'
|
|
102
|
+
@grids = { 'grid1' => 'xyz', 'grid2' => 'DataGrid2', 'grid3' => 'DataGrid1' }
|
|
103
103
|
exp = /Grids - Bad grid name 'xyz' for 'grid1'/
|
|
104
|
-
expect{subject}.to raise_error(exp)
|
|
104
|
+
expect { subject }.to raise_error(exp)
|
|
105
105
|
end
|
|
106
|
-
it
|
|
107
|
-
vals = Gemini::MyRule.all.map do
|
|
108
|
-
|
|
109
|
-
[r.name, r.simple_guards["g_has_default"]]
|
|
106
|
+
it 'sets guard defaults correctly' do
|
|
107
|
+
vals = Gemini::MyRule.all.map do |r|
|
|
108
|
+
[r.name, r.simple_guards['g_has_default']]
|
|
110
109
|
end
|
|
111
|
-
expect(vals.sort).to eq([[
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
110
|
+
expect(vals.sort).to eq([['Rule1', 'different'],
|
|
111
|
+
['Rule2', 'string default'],
|
|
112
|
+
['Rule2a', 'string default'],
|
|
113
|
+
['Rule2b', 'string default'],
|
|
114
|
+
['Rule2c', 'string default'],
|
|
115
|
+
['Rule3', 'string default'],
|
|
116
|
+
['Rule4', 'string default'],
|
|
117
|
+
['Rule5', 'foo']].sort)
|
|
119
118
|
end
|
|
120
119
|
end
|
|
121
|
-
context
|
|
120
|
+
context 'validation (xyz type)' do
|
|
122
121
|
subject do
|
|
123
|
-
r=Gemini::XyzRule.create!(name:
|
|
122
|
+
r = Gemini::XyzRule.create!(name: 'testrule',
|
|
124
123
|
rule_type: @rule_type,
|
|
125
124
|
start_dt: @start_dt || '2013-1-1',
|
|
126
125
|
end_dt: @end_dt,
|
|
@@ -128,237 +127,249 @@ module Marty::RuleSpec
|
|
|
128
127
|
computed_guards: @computed_guards || {},
|
|
129
128
|
grids: @grids || {},
|
|
130
129
|
results: @results || {}
|
|
131
|
-
|
|
130
|
+
)
|
|
132
131
|
r.reload
|
|
133
132
|
end
|
|
134
|
-
it
|
|
133
|
+
it 'detects script errors' do
|
|
135
134
|
@rule_type = 'XRule'
|
|
136
|
-
@results = {
|
|
135
|
+
@results = { 'x' => 'zx sdf wer' }
|
|
137
136
|
exp = /Computed - Error in rule 'testrule' field 'results': Syntax error/
|
|
138
|
-
expect{subject}.to raise_error(exp)
|
|
137
|
+
expect { subject }.to raise_error(exp)
|
|
139
138
|
end
|
|
140
|
-
it
|
|
139
|
+
it 'rule script stuff overrides 1' do
|
|
141
140
|
@rule_type = 'XRule'
|
|
142
|
-
@computed_guards = {
|
|
141
|
+
@computed_guards = { 'abc' => 'true', 'xyz_guard' => 'err err err' }
|
|
143
142
|
exp = /Computed - Error in rule 'testrule' field 'xyz': Syntax error/
|
|
144
|
-
expect{subject}.to raise_error(exp)
|
|
143
|
+
expect { subject }.to raise_error(exp)
|
|
145
144
|
end
|
|
146
|
-
it
|
|
145
|
+
it 'rule script stuff overrides 2' do
|
|
147
146
|
@rule_type = 'XRule'
|
|
148
|
-
@computed_guards = {
|
|
147
|
+
@computed_guards = { 'abc' => 'err err err', 'xyz_guard' => 'xyz_param' }
|
|
149
148
|
exp = /Computed - Error in rule 'testrule' field 'computed_guards': Syntax error/
|
|
150
|
-
expect{subject}.to raise_error(exp)
|
|
149
|
+
expect { subject }.to raise_error(exp)
|
|
151
150
|
end
|
|
152
|
-
it
|
|
151
|
+
it 'rule script stuff overrides 3' do
|
|
153
152
|
@rule_type = 'XRule'
|
|
154
|
-
@computed_guards = {
|
|
153
|
+
@computed_guards = { 'abc' => 'true', 'xyz_guard' => '!xyz_param' }
|
|
155
154
|
rule = subject
|
|
156
|
-
expect(rule.compute_xyz('infinity',true)).to be false
|
|
157
|
-
expect(rule.compute_xyz('infinity',false)).to be true
|
|
155
|
+
expect(rule.compute_xyz('infinity', true)).to be false
|
|
156
|
+
expect(rule.compute_xyz('infinity', false)).to be true
|
|
158
157
|
end
|
|
159
|
-
it
|
|
158
|
+
it 'no error' do
|
|
160
159
|
@rule_type = 'XRule'
|
|
161
|
-
@results = {
|
|
162
|
-
expect{subject}.not_to raise_error
|
|
160
|
+
@results = { 'x' => '1' }
|
|
161
|
+
expect { subject }.not_to raise_error
|
|
163
162
|
end
|
|
164
163
|
end
|
|
165
164
|
|
|
166
|
-
context
|
|
167
|
-
it
|
|
165
|
+
context 'lookups' do
|
|
166
|
+
it 'matches' do
|
|
168
167
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
169
|
-
{'rule_type'=>'SimpleRule'},
|
|
170
|
-
|
|
168
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
169
|
+
'g_array' => 'G1V3')
|
|
171
170
|
expect(lookup.to_a.count).to eq(1)
|
|
172
|
-
expect(lookup.first.name).to eq(
|
|
171
|
+
expect(lookup.first.name).to eq('Rule1')
|
|
173
172
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
174
|
-
{'rule_type'=>'SimpleRule',
|
|
173
|
+
{ 'rule_type' => 'SimpleRule',
|
|
175
174
|
|
|
176
|
-
'other_flag'=>true},
|
|
175
|
+
'other_flag' => true },
|
|
177
176
|
{})
|
|
178
177
|
expect(lookup.to_a.count).to eq(4)
|
|
179
|
-
expect(lookup.map
|
|
180
|
-
|
|
178
|
+
expect(lookup.map(&:name).to_set).to eq(Set['Rule2', 'Rule2a',
|
|
179
|
+
'Rule2b', 'Rule2c'])
|
|
181
180
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
182
|
-
{'rule_type'=>'ComplexRule',
|
|
183
|
-
'other_flag'=>false},
|
|
181
|
+
{ 'rule_type' => 'ComplexRule',
|
|
182
|
+
'other_flag' => false },
|
|
184
183
|
{})
|
|
185
184
|
expect(lookup.to_a.count).to eq(1)
|
|
186
|
-
expect(lookup.first.name).to eq(
|
|
185
|
+
expect(lookup.first.name).to eq('Rule3')
|
|
187
186
|
# bool false matches bool nil
|
|
188
187
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
189
|
-
{'rule_type'=>'ComplexRule',
|
|
190
|
-
'other_flag'=>false},
|
|
191
|
-
|
|
188
|
+
{ 'rule_type' => 'ComplexRule',
|
|
189
|
+
'other_flag' => false },
|
|
190
|
+
'g_bool' => false)
|
|
192
191
|
expect(lookup.to_a.count).to eq(1)
|
|
193
|
-
expect(lookup.first.name).to eq(
|
|
192
|
+
expect(lookup.first.name).to eq('Rule3')
|
|
194
193
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
195
|
-
{'rule_type'=>'ComplexRule'},
|
|
196
|
-
|
|
194
|
+
{ 'rule_type' => 'ComplexRule' },
|
|
195
|
+
'g_string' => 'def')
|
|
197
196
|
expect(lookup.to_a.count).to eq(1)
|
|
198
|
-
expect(lookup.first.name).to eq(
|
|
197
|
+
expect(lookup.first.name).to eq('Rule3')
|
|
199
198
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
200
|
-
{'rule_type'=>'ComplexRule'},
|
|
201
|
-
|
|
199
|
+
{ 'rule_type' => 'ComplexRule' },
|
|
200
|
+
'g_string' => 'abc')
|
|
202
201
|
expect(lookup).to eq([])
|
|
203
202
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
204
|
-
{'rule_type'=>'SimpleRule'},
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
204
|
+
'g_bool' => true, 'g_range' => 25,
|
|
205
|
+
'g_integer' => 99)
|
|
207
206
|
expect(lookup.to_a.count).to eq(1)
|
|
208
|
-
expect(lookup.first.name).to eq(
|
|
207
|
+
expect(lookup.first.name).to eq('Rule2a')
|
|
209
208
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
210
|
-
{'rule_type'=>'SimpleRule'},
|
|
211
|
-
|
|
209
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
210
|
+
'g_bool' => true, 'g_range' => 75)
|
|
212
211
|
expect(lookup.to_a.count).to eq(1)
|
|
213
|
-
expect(lookup.first.name).to eq(
|
|
212
|
+
expect(lookup.first.name).to eq('Rule1')
|
|
214
213
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
215
|
-
{'rule_type'=>'SimpleRule'},
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
215
|
+
'g_bool' => true, 'g_range' => 75,
|
|
216
|
+
'g_integer' => 11)
|
|
218
217
|
expect(lookup).to eq([])
|
|
219
218
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
220
|
-
{'rule_type'=>'SimpleRule'},
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
220
|
+
'g_bool' => true, 'g_range' => 75,
|
|
221
|
+
'g_integer' => 10)
|
|
223
222
|
expect(lookup.to_a.count).to eq(1)
|
|
224
|
-
expect(lookup.first.name).to eq(
|
|
223
|
+
expect(lookup.first.name).to eq('Rule1')
|
|
225
224
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
226
|
-
{'rule_type'=>'SimpleRule'},
|
|
227
|
-
|
|
228
|
-
|
|
225
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
226
|
+
'g_bool' => false, 'g_range' => 25,
|
|
227
|
+
'g_integer' => 10)
|
|
229
228
|
expect(lookup.to_a.count).to eq(1)
|
|
230
|
-
expect(lookup.first.name).to eq(
|
|
229
|
+
expect(lookup.first.name).to eq('Rule2c')
|
|
231
230
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
232
|
-
{'rule_type'=>'SimpleRule'}, {})
|
|
231
|
+
{ 'rule_type' => 'SimpleRule' }, {})
|
|
233
232
|
expect(lookup.to_a.count).to eq(5)
|
|
234
233
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
235
|
-
{'rule_dt'=>
|
|
234
|
+
{ 'rule_dt' => '2017-3-1 02:00:00' },
|
|
236
235
|
{})
|
|
237
236
|
expect(lookup.to_a.count).to eq(6)
|
|
238
|
-
expect(lookup.pluck(:name).to_set).to eq(Set[
|
|
239
|
-
|
|
237
|
+
expect(lookup.pluck(:name).to_set).to eq(Set['Rule1', 'Rule2', 'Rule2a',
|
|
238
|
+
'Rule2b', 'Rule2c', 'Rule3'])
|
|
240
239
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
241
|
-
{'rule_dt'=>
|
|
240
|
+
{ 'rule_dt' => '2017-4-1 16:00:00' },
|
|
242
241
|
{})
|
|
243
242
|
expect(lookup.to_a.count).to eq(1)
|
|
244
|
-
expect(lookup.pluck(:name).first).to eq(
|
|
243
|
+
expect(lookup.pluck(:name).first).to eq('Rule4')
|
|
245
244
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
246
|
-
{'rule_dt'=>
|
|
245
|
+
{ 'rule_dt' => '2016-12-31' }, {})
|
|
247
246
|
expect(lookup.to_a).to eq([])
|
|
248
247
|
lookup = Gemini::MyRule.get_matches('infinity',
|
|
249
|
-
{'rule_dt'=>
|
|
248
|
+
{ 'rule_dt' => '2017-5-1 00:00:01' }, {})
|
|
250
249
|
expect(lookup.to_a).to eq([])
|
|
251
250
|
lookup = Gemini::MyRule.get_matches('infinity', {},
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
'g_bool_def' => false,
|
|
252
|
+
'g_nbool_def' => true)
|
|
254
253
|
expect(lookup.to_a.count).to eq(1)
|
|
255
|
-
expect(lookup.pluck(:name).first).to eq(
|
|
254
|
+
expect(lookup.pluck(:name).first).to eq('Rule1')
|
|
256
255
|
end
|
|
257
256
|
end
|
|
258
|
-
context
|
|
259
|
-
let(:complex)
|
|
260
|
-
{'rule_type'=>'ComplexRule'},
|
|
261
|
-
{'g_string'=>'def'}).first }
|
|
262
|
-
let(:xyz) { Gemini::XyzRule.get_matches('infinity',
|
|
263
|
-
{'rule_type'=>'ZRule'},
|
|
264
|
-
{'g_integer'=> 2}).first }
|
|
265
|
-
let(:simple) {
|
|
257
|
+
context 'rule compute' do
|
|
258
|
+
let(:complex) do
|
|
266
259
|
Gemini::MyRule.get_matches('infinity',
|
|
267
|
-
{'rule_type'=>'
|
|
268
|
-
|
|
269
|
-
|
|
260
|
+
{ 'rule_type' => 'ComplexRule' },
|
|
261
|
+
'g_string' => 'def').first
|
|
262
|
+
end
|
|
263
|
+
let(:xyz) do
|
|
264
|
+
Gemini::XyzRule.get_matches('infinity',
|
|
265
|
+
{ 'rule_type' => 'ZRule' },
|
|
266
|
+
'g_integer' => 2).first
|
|
267
|
+
end
|
|
268
|
+
let(:simple) do
|
|
270
269
|
Gemini::MyRule.get_matches('infinity',
|
|
271
|
-
{'rule_type'=>'SimpleRule'},
|
|
272
|
-
|
|
273
|
-
|
|
270
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
271
|
+
'g_bool' => true, 'g_range' => 25).first
|
|
272
|
+
end
|
|
273
|
+
let(:simple2a) do
|
|
274
274
|
Gemini::MyRule.get_matches('infinity',
|
|
275
|
-
{'rule_type'=>'SimpleRule'},
|
|
276
|
-
|
|
277
|
-
|
|
275
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
276
|
+
'g_bool' => true, 'g_integer' => 99).first
|
|
277
|
+
end
|
|
278
|
+
let(:simple2b) do
|
|
279
|
+
Gemini::MyRule.get_matches('infinity',
|
|
280
|
+
{ 'rule_type' => 'SimpleRule' },
|
|
281
|
+
'g_bool' => true, 'g_integer' => 999).first
|
|
282
|
+
end
|
|
283
|
+
let(:altgridmethod) do
|
|
278
284
|
Gemini::MyRule.get_matches('infinity',
|
|
279
|
-
{'rule_type'=>'ComplexRule'},
|
|
280
|
-
|
|
281
|
-
|
|
285
|
+
{ 'rule_type' => 'ComplexRule' },
|
|
286
|
+
'g_integer' => 3757).first
|
|
287
|
+
end
|
|
288
|
+
let(:gridcomputedname) do
|
|
282
289
|
Gemini::MyRule.get_matches('infinity',
|
|
283
|
-
{'rule_type'=>'ComplexRule'},
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
expect(simple.fixed_results[
|
|
294
|
-
expect(simple.fixed_results[
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
290
|
+
{ 'rule_type' => 'ComplexRule' },
|
|
291
|
+
'g_string' => 'Hi Mom',
|
|
292
|
+
'g_integer' => 11).first
|
|
293
|
+
end
|
|
294
|
+
it 'computed guards work' do
|
|
295
|
+
c = complex.compute(@ruleopts_myrule, 'pt' => Time.zone.now,
|
|
296
|
+
'param2' => 'def')
|
|
297
|
+
expect(c).to eq('cguard2' => [false, 'a string'])
|
|
298
|
+
end
|
|
299
|
+
it 'returns simple results via #fixed_results' do
|
|
300
|
+
expect(simple.fixed_results['simple_result']).to eq('b value')
|
|
301
|
+
expect(simple.fixed_results['sr2']).to eq(true)
|
|
302
|
+
expect(simple.fixed_results['sr3']).to eq(123)
|
|
303
|
+
ssq = 'string with single quotes'
|
|
304
|
+
expect(simple.fixed_results['single_quote']).to eq(ssq)
|
|
305
|
+
swh = ' string that contains a # character'
|
|
306
|
+
expect(simple.fixed_results['stringwithhash']).to eq(swh)
|
|
299
307
|
expect(simple.fixed_results.count).to eq(5)
|
|
300
308
|
allow_any_instance_of(Delorean::Engine).
|
|
301
309
|
to receive(:evaluate).and_raise('hi mom')
|
|
302
|
-
expect
|
|
303
|
-
|
|
310
|
+
expect do
|
|
311
|
+
simple.compute(@ruleopts_myrule,
|
|
312
|
+
'pt' => Time.now)
|
|
313
|
+
end .to raise_error(/hi mom/)
|
|
304
314
|
# simple2a should return results without evaluation (they are all fixed)
|
|
305
|
-
expect(simple2a.compute(@ruleopts_myrule,
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
315
|
+
expect(simple2a.compute(@ruleopts_myrule, 'pt' => Time.zone.now)).to eq(
|
|
316
|
+
'simple_result' => 'b value',
|
|
317
|
+
'sr2' => true,
|
|
318
|
+
)
|
|
309
319
|
# simple2b should return grid results without evaluation
|
|
310
320
|
expect(simple2b.compute(@ruleopts_myrule,
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
to eq(
|
|
316
|
-
|
|
317
|
-
|
|
321
|
+
'pt' => Time.zone.now,
|
|
322
|
+
'param1' => 66,
|
|
323
|
+
'param2' => 'abc',
|
|
324
|
+
'paramb' => false)).
|
|
325
|
+
to eq('grid1_grid_result' => 3,
|
|
326
|
+
'grid2_grid_result' => 1300)
|
|
327
|
+
end
|
|
328
|
+
it 'returns computed results' do
|
|
329
|
+
c = complex.compute(@ruleopts_myrule, 'pt' => Time.zone.now,
|
|
330
|
+
'param1' => 66,
|
|
331
|
+
'param2' => 'abc',
|
|
332
|
+
'paramb' => false)
|
|
333
|
+
expect(c).to eq('simple_result' => 'c value',
|
|
334
|
+
'computed_value' => 19, 'grid1_grid_result' => 3,
|
|
335
|
+
'grid2_grid_result' => 1300)
|
|
336
|
+
end
|
|
337
|
+
it 'returns computed results (with delorean import)' do
|
|
338
|
+
c = xyz.compute(@ruleopts_xyz, 'pt' => Time.zone.now + 1,
|
|
339
|
+
'p1' => 12,
|
|
340
|
+
'p2' => 3,
|
|
341
|
+
'flavor' => 'cherry')
|
|
342
|
+
expect(c).to eq('bvlength' => 13, 'bv' => 'cherry --> 36',
|
|
343
|
+
'grid1_grid_result' => 19)
|
|
318
344
|
end
|
|
319
|
-
it
|
|
320
|
-
c = complex.compute(@ruleopts_myrule, {"pt"=>Time.zone.now,
|
|
321
|
-
'param1'=> 66,
|
|
322
|
-
'param2'=>'abc',
|
|
323
|
-
'paramb'=>false})
|
|
324
|
-
expect(c).to eq({"simple_result"=>"c value",
|
|
325
|
-
"computed_value"=>19, "grid1_grid_result"=>3,
|
|
326
|
-
"grid2_grid_result"=>1300})
|
|
327
|
-
end
|
|
328
|
-
it "returns computed results (with delorean import)" do
|
|
329
|
-
c = xyz.compute(@ruleopts_xyz, {"pt"=>Time.zone.now+1,
|
|
330
|
-
"p1"=>12,
|
|
331
|
-
"p2"=>3,
|
|
332
|
-
"flavor"=>"cherry"})
|
|
333
|
-
expect(c).to eq({"bvlength"=>13,"bv"=>"cherry --> 36",
|
|
334
|
-
"grid1_grid_result"=>19})
|
|
335
|
-
end
|
|
336
|
-
it "reports bad grid name" do
|
|
345
|
+
it 'reports bad grid name' do
|
|
337
346
|
exp = Regexp.new("Error .results. in rule '\\d+:Rule4': "\
|
|
338
|
-
|
|
339
|
-
expect
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
347
|
+
'DataGridX grid not found')
|
|
348
|
+
expect do
|
|
349
|
+
gridcomputedname.compute(@ruleopts_myrule,
|
|
350
|
+
'pt' => Time.zone.now,
|
|
351
|
+
'param1' => 66,
|
|
352
|
+
'param2' => 'abc',
|
|
353
|
+
'paramb' => false)
|
|
354
|
+
end .to raise_error(exp)
|
|
355
|
+
end
|
|
356
|
+
it 'grids embedded in result work properly and receive prior attrs' do
|
|
357
|
+
v = altgridmethod.compute(@ruleopts_myrule, 'pt' => Time.zone.now,
|
|
358
|
+
'param1' => 45,
|
|
359
|
+
'param2' => 1)
|
|
360
|
+
expect(v['final_value']).to eq(15)
|
|
361
|
+
end
|
|
362
|
+
it 'exceptions/logging' do
|
|
352
363
|
r6, r7, r8 = [6, 7, 8].map do |i|
|
|
353
364
|
Gemini::XyzRule.get_matches('infinity',
|
|
354
|
-
{'rule_type'=>'ZRule'},
|
|
355
|
-
|
|
365
|
+
{ 'rule_type' => 'ZRule' },
|
|
366
|
+
'g_integer' => i).first
|
|
356
367
|
end
|
|
357
|
-
pt = Time.zone.now+1
|
|
358
|
-
input = {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
368
|
+
pt = Time.zone.now + 1
|
|
369
|
+
input = { 'pt' => pt,
|
|
370
|
+
'p1' => 12,
|
|
371
|
+
'p2' => 3,
|
|
372
|
+
'flavor' => 'cherry' }
|
|
362
373
|
v1 = r6.compute(@ruleopts_xyz, input)
|
|
363
374
|
begin
|
|
364
375
|
v2 = r7.compute(@ruleopts_xyz, input)
|
|
@@ -366,12 +377,12 @@ module Marty::RuleSpec
|
|
|
366
377
|
exp = 'no implicit conversion of Integer into String'
|
|
367
378
|
expect(e.message).to include(exp)
|
|
368
379
|
expres = [/DELOREAN__XyzRule_\d+_1483228800.0:23:in .+'/,
|
|
369
|
-
|
|
370
|
-
|
|
380
|
+
/DELOREAN__XyzRule_\d+_1483228800.0:23:in .tmp_var4__D'/,
|
|
381
|
+
/DELOREAN__XyzRule_\d+_1483228800.0:27:in .bv__D'/]
|
|
371
382
|
expres.each_with_index do |expre, i|
|
|
372
383
|
expect(e.backtrace[i]).to match(expre)
|
|
373
384
|
end
|
|
374
|
-
expect(e.input).to eq(input + {'dgparams__'=>input})
|
|
385
|
+
expect(e.input).to eq(input + { 'dgparams__' => input })
|
|
375
386
|
expect(e.section).to eq('results')
|
|
376
387
|
end
|
|
377
388
|
begin
|
|
@@ -380,7 +391,7 @@ module Marty::RuleSpec
|
|
|
380
391
|
exp = 'divided by 0'
|
|
381
392
|
expect(e.message).to include(exp)
|
|
382
393
|
expres = [%r(DELOREAN__XyzRule_\d+_1483228800.0:5:in ./'),
|
|
383
|
-
|
|
394
|
+
/DELOREAN__XyzRule_\d+_1483228800.0:5:in .cg1__D'/]
|
|
384
395
|
expres.each_with_index do |expre, i|
|
|
385
396
|
expect(e.backtrace[i]).to match(expre)
|
|
386
397
|
end
|
|
@@ -388,54 +399,54 @@ module Marty::RuleSpec
|
|
|
388
399
|
expect(e.section).to eq('computed_guards')
|
|
389
400
|
end
|
|
390
401
|
log_ents = Marty::Log.all
|
|
391
|
-
expect(log_ents.map
|
|
392
|
-
|
|
393
|
-
|
|
402
|
+
expect(log_ents.map(&:message)).to eq(['Rule Log ZRule6',
|
|
403
|
+
'Rule Log ZRule7',
|
|
404
|
+
'Rule Log ZRule8'])
|
|
394
405
|
ptjson = pt.as_json
|
|
395
|
-
exp = {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
{
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
406
|
+
exp = { 'input' => { 'p1' => 12, 'p2' => 3,
|
|
407
|
+
'pt' => ptjson,
|
|
408
|
+
'flavor' => 'cherry' },
|
|
409
|
+
'dgparams' => { 'p1' => 12, 'p2' => 3,
|
|
410
|
+
'pt' => ptjson,
|
|
411
|
+
'flavor' => 'cherry' },
|
|
412
|
+
'gr_keys' => ['grid1_grid_result'],
|
|
413
|
+
'res_hash' =>
|
|
414
|
+
{ 'bv' => 'a stringa stringa stringa stringa stringa stringa stringa '\
|
|
415
|
+
'stringa stringa stringa stringa stringa stringa stringa '\
|
|
416
|
+
'stringa stringa stringa stringa stringa stringa stringa '\
|
|
417
|
+
'stringa stringa stringa stringa string',
|
|
418
|
+
'grid1_grid_result' => 19 } }
|
|
408
419
|
expect(log_ents[0].details).to eq(exp)
|
|
409
|
-
exp = {
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
+
exp = { 'input' => { 'p1' => 12, 'p2' => 3,
|
|
421
|
+
'pt' => ptjson,
|
|
422
|
+
'flavor' => 'cherry' },
|
|
423
|
+
'cg_hash' => { 'some_guard' => true },
|
|
424
|
+
'gr_keys' => ['grid1_grid_result'],
|
|
425
|
+
'dgparams' => { 'p1' => 12, 'p2' => 3,
|
|
426
|
+
'pt' => ptjson,
|
|
427
|
+
'flavor' => 'cherry' },
|
|
428
|
+
'res_keys' => ['bv', 'grid1_grid_result'],
|
|
429
|
+
'err_section' => 'results',
|
|
430
|
+
'err_message' => 'no implicit conversion of Integer into String' }
|
|
420
431
|
expect(log_ents[1].details.except('err_stack')).to eq(exp)
|
|
421
432
|
expres = [/DELOREAN__XyzRule_\d+_1483228800.0:23:in .+'/,
|
|
422
|
-
|
|
423
|
-
|
|
433
|
+
/DELOREAN__XyzRule_\d+_1483228800.0:23:in .tmp_var4__D'/,
|
|
434
|
+
/DELOREAN__XyzRule_\d+_1483228800.0:27:in .bv__D'/]
|
|
424
435
|
expres.each_with_index do |expre, i|
|
|
425
436
|
expect(log_ents[1].details['err_stack'][i]).to match(expre)
|
|
426
437
|
end
|
|
427
|
-
exp = {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
438
|
+
exp = { 'input' => { 'p1' => 12, 'p2' => 3,
|
|
439
|
+
'pt' => ptjson,
|
|
440
|
+
'flavor' => 'cherry' },
|
|
441
|
+
'cg_keys' => ['cg1'],
|
|
442
|
+
'dgparams' => { 'p1' => 12, 'p2' => 3,
|
|
443
|
+
'pt' => ptjson,
|
|
444
|
+
'flavor' => 'cherry' },
|
|
445
|
+
'err_section' => 'computed_guards',
|
|
446
|
+
'err_message' => 'divided by 0' }
|
|
436
447
|
expect(log_ents[2].details.except('err_stack')).to eq(exp)
|
|
437
448
|
expres = [%r(DELOREAN__XyzRule_\d+_1483228800.0:5:in ./'),
|
|
438
|
-
|
|
449
|
+
/DELOREAN__XyzRule_\d+_1483228800.0:5:in .cg1__D'/]
|
|
439
450
|
expres.each_with_index do |expre, i|
|
|
440
451
|
expect(log_ents[2].details['err_stack'][i]).to match(expre)
|
|
441
452
|
end
|