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
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
require
|
|
1
|
+
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
module Marty
|
|
4
|
-
|
|
5
|
-
bud_cats =<<EOF
|
|
4
|
+
bud_cats = <<EOF
|
|
6
5
|
name
|
|
7
6
|
Conv Fixed 30
|
|
8
7
|
Conv Fixed 20
|
|
9
8
|
EOF
|
|
10
9
|
|
|
11
|
-
fannie_bup
|
|
10
|
+
fannie_bup = <<EOF
|
|
12
11
|
bud_category note_rate buy_up buy_down settlement_mm settlement_yy
|
|
13
12
|
Conv Fixed 30 2.250 4.42000 7.24000 12 2012
|
|
14
13
|
Conv Fixed 30 2.375 4.42000 7.24000 12 2012
|
|
@@ -19,7 +18,7 @@ Conv Fixed 20 2.875 4.24800 6.95900 12 2012
|
|
|
19
18
|
Conv Fixed 20 2.875 4.24800 6.95900 11 2012
|
|
20
19
|
EOF
|
|
21
20
|
|
|
22
|
-
script
|
|
21
|
+
script = <<EOF
|
|
23
22
|
A:
|
|
24
23
|
c = Gemini::FannieBup.
|
|
25
24
|
joins("bud_category").
|
|
@@ -75,119 +74,118 @@ A:
|
|
|
75
74
|
mcfly_pt('01-01-2003').count
|
|
76
75
|
EOF
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
first.note_rate
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
it "perfroms order+find_by" do
|
|
146
|
-
res = @engine.evaluate("A", "oo", {})
|
|
147
|
-
|
|
148
|
-
expect(res).to eq Gemini::FannieBup.
|
|
149
|
-
order("note_rate", "buy_down ASC").
|
|
150
|
-
select("note_rate").
|
|
151
|
-
find_by("obsoleted_dt = 'infinity'").
|
|
152
|
-
note_rate
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
it "perfroms find_by on class" do
|
|
156
|
-
res = @engine.evaluate("A", "ooo", {})
|
|
157
|
-
|
|
158
|
-
expect(res).to eq Gemini::FannieBup.find_by(id: -1)
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
it "perfroms group+count" do
|
|
162
|
-
res = @engine.evaluate("A", "gg", {})
|
|
163
|
-
|
|
164
|
-
expect(res).
|
|
165
|
-
to eq Gemini::FannieBup.
|
|
166
|
-
select("settlement_yy*settlement_mm AS x, count(*) AS c").
|
|
167
|
-
group("settlement_mm", "settlement_yy").
|
|
168
|
-
order("settlement_mm").
|
|
169
|
-
map(&:attributes)
|
|
170
|
-
end
|
|
171
|
-
|
|
172
|
-
it "perfroms where+not" do
|
|
173
|
-
res = @engine.evaluate("A", "n", {})
|
|
174
|
-
|
|
175
|
-
expect(res).to eq Gemini::FannieBup.where.not("settlement_mm < 12").count
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
it "perfroms query+query" do
|
|
179
|
-
res = @engine.evaluate("A", ["q1", "q2"], {})
|
|
180
|
-
|
|
181
|
-
expect(res).to eq [
|
|
182
|
-
[2.25, 2.375, 2.5, 2.625, 2.75, 2.875],
|
|
183
|
-
[2.875, 2.75, 2.625, 2.5, 2.375, 2.25],
|
|
184
|
-
]
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
it "handle query params" do
|
|
188
|
-
res = @engine.evaluate("A", "pq",
|
|
189
|
-
{"settlement_mm" => 12, "note_rate" => 2.5})
|
|
190
|
-
expect(res).to eq [2.625, 2.75, 2.875]
|
|
191
|
-
end
|
|
77
|
+
describe 'DeloreanQuery' do
|
|
78
|
+
before(:all) do
|
|
79
|
+
@clean_file = "/tmp/clean_#{Process.pid}.psql"
|
|
80
|
+
save_clean_db(@clean_file)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
before(:each) do
|
|
84
|
+
marty_whodunnit
|
|
85
|
+
Marty::DataImporter.do_import_summary(Gemini::BudCategory, bud_cats)
|
|
86
|
+
Marty::DataImporter.do_import_summary(Gemini::FannieBup, fannie_bup)
|
|
87
|
+
|
|
88
|
+
Marty::Script.load_script_bodies(
|
|
89
|
+
{
|
|
90
|
+
'A' => script,
|
|
91
|
+
}, Date.today)
|
|
92
|
+
|
|
93
|
+
@engine = Marty::ScriptSet.new.get_engine('A')
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
after(:all) do
|
|
97
|
+
restore_clean_db(@clean_file)
|
|
98
|
+
Marty::ScriptSet.clear_cache
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it 'perfroms join+count' do
|
|
102
|
+
res = @engine.evaluate('A', 'c', {})
|
|
103
|
+
|
|
104
|
+
expect(res).to eq Gemini::FannieBup.
|
|
105
|
+
joins('bud_category').
|
|
106
|
+
where("name LIKE '%30'").
|
|
107
|
+
count
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
it 'perfroms select+distinct' do
|
|
111
|
+
res = @engine.evaluate('A', 's', {})
|
|
112
|
+
|
|
113
|
+
expect(res).to eq Gemini::FannieBup.
|
|
114
|
+
joins('bud_category').
|
|
115
|
+
select('name').
|
|
116
|
+
distinct('name').
|
|
117
|
+
pluck('name')
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
it 'perfroms mcfly_pt' do
|
|
121
|
+
res = @engine.evaluate('A', ['m', 'mm'], {})
|
|
122
|
+
|
|
123
|
+
expect(res).to eq [
|
|
124
|
+
Gemini::FannieBup.
|
|
125
|
+
joins('bud_category').
|
|
126
|
+
mcfly_pt('infinity').
|
|
127
|
+
select('name').
|
|
128
|
+
pluck('name'),
|
|
129
|
+
Gemini::FannieBup.
|
|
130
|
+
mcfly_pt('01-01-2003').count,
|
|
131
|
+
]
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
it 'perfroms order+first' do
|
|
135
|
+
res = @engine.evaluate('A', 'o', {})
|
|
136
|
+
|
|
137
|
+
expect(res).to eq Gemini::FannieBup.
|
|
138
|
+
order('note_rate DESC', 'buy_down ASC').
|
|
139
|
+
select('note_rate').
|
|
140
|
+
first.note_rate
|
|
192
141
|
end
|
|
142
|
+
|
|
143
|
+
it 'perfroms order+find_by' do
|
|
144
|
+
res = @engine.evaluate('A', 'oo', {})
|
|
145
|
+
|
|
146
|
+
expect(res).to eq Gemini::FannieBup.
|
|
147
|
+
order('note_rate', 'buy_down ASC').
|
|
148
|
+
select('note_rate').
|
|
149
|
+
find_by("obsoleted_dt = 'infinity'").
|
|
150
|
+
note_rate
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
it 'perfroms find_by on class' do
|
|
154
|
+
res = @engine.evaluate('A', 'ooo', {})
|
|
155
|
+
|
|
156
|
+
expect(res).to eq Gemini::FannieBup.find_by(id: -1)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
it 'perfroms group+count' do
|
|
160
|
+
res = @engine.evaluate('A', 'gg', {})
|
|
161
|
+
|
|
162
|
+
expect(res).
|
|
163
|
+
to eq Gemini::FannieBup.
|
|
164
|
+
select('settlement_yy*settlement_mm AS x, count(*) AS c').
|
|
165
|
+
group('settlement_mm', 'settlement_yy').
|
|
166
|
+
order('settlement_mm').
|
|
167
|
+
map(&:attributes)
|
|
168
|
+
end
|
|
169
|
+
|
|
170
|
+
it 'perfroms where+not' do
|
|
171
|
+
res = @engine.evaluate('A', 'n', {})
|
|
172
|
+
|
|
173
|
+
expect(res).to eq Gemini::FannieBup.where.not('settlement_mm < 12').count
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it 'perfroms query+query' do
|
|
177
|
+
res = @engine.evaluate('A', ['q1', 'q2'], {})
|
|
178
|
+
|
|
179
|
+
expect(res).to eq [
|
|
180
|
+
[2.25, 2.375, 2.5, 2.625, 2.75, 2.875],
|
|
181
|
+
[2.875, 2.75, 2.625, 2.5, 2.375, 2.25],
|
|
182
|
+
]
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
it 'handle query params' do
|
|
186
|
+
res = @engine.evaluate('A', 'pq',
|
|
187
|
+
'settlement_mm' => 12, 'note_rate' => 2.5)
|
|
188
|
+
expect(res).to eq [2.625, 2.75, 2.875]
|
|
189
|
+
end
|
|
190
|
+
end
|
|
193
191
|
end
|
|
@@ -1,55 +1,52 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
3
|
class MammalEnum
|
|
4
|
-
VALUES=Set['Dog','Cat','Human','Cow','Bear']
|
|
4
|
+
VALUES = Set['Dog', 'Cat', 'Human', 'Cow', 'Bear']
|
|
5
5
|
end
|
|
6
6
|
|
|
7
7
|
class ElectronicsEnum
|
|
8
|
-
VALUES=Set['Phone','Keyboard','Terminator']
|
|
8
|
+
VALUES = Set['Phone', 'Keyboard', 'Terminator']
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
class NotAnEnum
|
|
12
|
-
HI =
|
|
12
|
+
HI = 'MOM'
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
module Marty
|
|
16
|
-
|
|
17
16
|
describe JsonSchema do
|
|
18
|
-
|
|
19
17
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
20
18
|
### Generic, simple data ###
|
|
21
19
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
22
20
|
|
|
23
21
|
simple_schema = {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
23
|
+
'properties' => {
|
|
24
|
+
'a' => {
|
|
25
|
+
'type' => 'integer'
|
|
28
26
|
},
|
|
29
27
|
}
|
|
30
28
|
}
|
|
31
|
-
opt = { :validate_schema
|
|
29
|
+
opt = { :validate_schema => true,
|
|
32
30
|
:errors_as_objects => false,
|
|
33
31
|
:version => Marty::JsonSchema::RAW_URI }
|
|
34
32
|
|
|
35
|
-
it
|
|
36
|
-
data = {
|
|
33
|
+
it 'returns no error on correct simple data' do
|
|
34
|
+
data = { 'a' => 5 }
|
|
37
35
|
expect(JSON::Validator.fully_validate(simple_schema, data, opt)).to eq([])
|
|
38
36
|
end
|
|
39
37
|
|
|
40
|
-
it
|
|
41
|
-
data = {
|
|
38
|
+
it 'returns error on incorrect simple data -- 1' do
|
|
39
|
+
data = { 'a' => 5.2 }
|
|
42
40
|
expect(JSON::Validator.
|
|
43
41
|
fully_validate(simple_schema, data, opt)[0]).to include(
|
|
44
|
-
|
|
42
|
+
"property '#/a' of type number did not match the following type: integer")
|
|
45
43
|
end
|
|
46
44
|
|
|
47
|
-
it
|
|
48
|
-
data = {
|
|
45
|
+
it 'returns error on incorrect simple data -- 2' do
|
|
46
|
+
data = { 'a' => 'Kangaroo' }
|
|
49
47
|
expect(JSON::Validator.
|
|
50
48
|
fully_validate(simple_schema, data, opt)[0]).to include(
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
"property '#/a' of type string did not match the following type: integer")
|
|
53
50
|
end
|
|
54
51
|
|
|
55
52
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
@@ -57,99 +54,99 @@ module Marty
|
|
|
57
54
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
58
55
|
|
|
59
56
|
pg_schema_opt = {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
58
|
+
'properties' => {
|
|
59
|
+
'a' => {
|
|
60
|
+
'pg_enum' => 'MammalEnum'
|
|
64
61
|
},
|
|
65
62
|
}
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
it
|
|
69
|
-
data = {
|
|
65
|
+
it 'returns no error on correct existing enums' do
|
|
66
|
+
data = { 'a' => 'Dog' }
|
|
70
67
|
expect(JSON::Validator.fully_validate(pg_schema_opt, data, opt)).to eq([])
|
|
71
68
|
end
|
|
72
69
|
|
|
73
|
-
it
|
|
74
|
-
data = {
|
|
70
|
+
it 'vacuously returns no error on a field not validated' do
|
|
71
|
+
data = { 'b' => 'Dawg' }
|
|
75
72
|
expect(JSON::Validator.fully_validate(pg_schema_opt, data, opt)).to eq([])
|
|
76
73
|
end
|
|
77
74
|
|
|
78
|
-
it
|
|
79
|
-
data = {
|
|
75
|
+
it 'returns error on non-existant enums' do
|
|
76
|
+
data = { 'a' => 'Beer' }
|
|
80
77
|
expect(JSON::Validator.
|
|
81
78
|
fully_validate(pg_schema_opt, data, opt)[0]).to include(
|
|
82
|
-
|
|
79
|
+
"property '#/a' value 'Beer' not contained in MammalEnum")
|
|
83
80
|
end
|
|
84
81
|
|
|
85
|
-
it
|
|
82
|
+
it 'returns no error when a optional field is not suppplied' do
|
|
86
83
|
data = {}
|
|
87
84
|
expect(JSON::Validator.fully_validate(pg_schema_opt, data, opt)).to eq([])
|
|
88
85
|
end
|
|
89
86
|
|
|
90
|
-
it
|
|
91
|
-
data = {
|
|
87
|
+
it 'returns error when a nil enum is passed even when enum is optional' do
|
|
88
|
+
data = { 'a' => nil }
|
|
92
89
|
expect(JSON::Validator.
|
|
93
90
|
fully_validate(pg_schema_opt, data, opt)[0]).to include(
|
|
94
|
-
|
|
91
|
+
"property '#/a' value '' not contained in MammalEnum")
|
|
95
92
|
end
|
|
96
93
|
|
|
97
94
|
pg_schema_req = {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
95
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
96
|
+
'required' => ['a'],
|
|
97
|
+
'properties' => {
|
|
98
|
+
'a' => {
|
|
99
|
+
'pg_enum' => 'MammalEnum'
|
|
103
100
|
},
|
|
104
101
|
}
|
|
105
102
|
}
|
|
106
103
|
|
|
107
|
-
it
|
|
104
|
+
it 'returns error when a required field is not supplied' do
|
|
108
105
|
data = {}
|
|
109
106
|
expect(JSON::Validator.
|
|
110
107
|
fully_validate(pg_schema_req, data, opt)[0]).to include(
|
|
111
|
-
|
|
108
|
+
"property '#/' did not contain a required property of 'a'")
|
|
112
109
|
end
|
|
113
110
|
|
|
114
|
-
it
|
|
115
|
-
data = {
|
|
111
|
+
it 'returns error when a nil enum is passed when enum is required' do
|
|
112
|
+
data = { 'a' => nil }
|
|
116
113
|
expect(JSON::Validator.
|
|
117
114
|
fully_validate(pg_schema_req, data, opt)[0]).to include(
|
|
118
|
-
|
|
115
|
+
"property '#/a' value '' not contained in MammalEnum")
|
|
119
116
|
end
|
|
120
117
|
|
|
121
118
|
pg_schema_req_bad = {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
120
|
+
'required' => ['a'],
|
|
121
|
+
'properties' => {
|
|
122
|
+
'a' => {
|
|
123
|
+
'pg_enum' => 'NotAnEnum'
|
|
127
124
|
},
|
|
128
125
|
}
|
|
129
126
|
}
|
|
130
127
|
|
|
131
|
-
it
|
|
132
|
-
data = {
|
|
128
|
+
it 'returns raises meaningful error on schema enum error' do
|
|
129
|
+
data = { 'a' => nil }
|
|
133
130
|
expect(JSON::Validator.
|
|
134
131
|
fully_validate(pg_schema_req_bad, data, opt)[0]).to include(
|
|
135
|
-
|
|
132
|
+
"property '#/a': 'NotAnEnum' is not a pg_enum class")
|
|
136
133
|
end
|
|
137
134
|
|
|
138
135
|
pg_schema_req_bad2 = {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
136
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
137
|
+
'required' => ['a'],
|
|
138
|
+
'properties' => {
|
|
139
|
+
'a' => {
|
|
140
|
+
'pg_enum' => 'NotEvenAClass'
|
|
144
141
|
},
|
|
145
142
|
}
|
|
146
143
|
}
|
|
147
144
|
|
|
148
|
-
it
|
|
149
|
-
data = {
|
|
145
|
+
it 'returns raises meaningful error on schema enum error' do
|
|
146
|
+
data = { 'a' => nil }
|
|
150
147
|
expect(JSON::Validator.
|
|
151
148
|
fully_validate(pg_schema_req_bad2, data, opt)[0]).to include(
|
|
152
|
-
|
|
149
|
+
"property '#/a': 'NotEvenAClass' is not a pg_enum class")
|
|
153
150
|
end
|
|
154
151
|
|
|
155
152
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
@@ -157,74 +154,74 @@ module Marty
|
|
|
157
154
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
158
155
|
|
|
159
156
|
date_schema_opt = {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
158
|
+
'properties' => {
|
|
159
|
+
'a' => {
|
|
160
|
+
'type' => 'string',
|
|
161
|
+
'format' => 'date'
|
|
165
162
|
}
|
|
166
163
|
}
|
|
167
164
|
}
|
|
168
165
|
|
|
169
|
-
it
|
|
170
|
-
data = {
|
|
166
|
+
it 'returns true on a properly formatted date' do
|
|
167
|
+
data = { 'a' => '2017-05-22' }
|
|
171
168
|
expect(JSON::Validator.validate(date_schema_opt, data)).to be true
|
|
172
169
|
end
|
|
173
170
|
|
|
174
|
-
it
|
|
175
|
-
data = {
|
|
171
|
+
it 'vacuously returns true on a field not validated' do
|
|
172
|
+
data = { 'b' => 'Today is May 22nd' }
|
|
176
173
|
expect(JSON::Validator.validate(date_schema_opt, data)).to be true
|
|
177
174
|
end
|
|
178
175
|
|
|
179
|
-
it
|
|
180
|
-
data = {
|
|
176
|
+
it 'returns error on an improperly formatted date' do
|
|
177
|
+
data = { 'a' => '2017-05-32' }
|
|
181
178
|
expect(JSON::Validator.
|
|
182
179
|
fully_validate(date_schema_opt, data, opt)[0]).to include(
|
|
183
|
-
|
|
180
|
+
"property '#/a' must be a date in the format of YYYY-MM-DD")
|
|
184
181
|
end
|
|
185
182
|
|
|
186
|
-
it
|
|
187
|
-
data = {
|
|
183
|
+
it 'returns error on an properly formatted datetime' do
|
|
184
|
+
data = { 'a' => '2017-05-22T14:51:44Z' }
|
|
188
185
|
expect(JSON::Validator.
|
|
189
186
|
fully_validate(date_schema_opt, data, opt)[0]).to include(
|
|
190
|
-
|
|
187
|
+
"property '#/a' must be a date in the format of YYYY-MM-DD")
|
|
191
188
|
end
|
|
192
189
|
|
|
193
|
-
it
|
|
190
|
+
it 'returns true when an optional date is not supplied' do
|
|
194
191
|
data = {}
|
|
195
192
|
expect(JSON::Validator.validate(date_schema_opt, data)).to be true
|
|
196
193
|
end
|
|
197
194
|
|
|
198
|
-
it
|
|
199
|
-
data = {
|
|
195
|
+
it 'returns error when a nil date is passed even when date is optional' do
|
|
196
|
+
data = { 'a' => nil }
|
|
200
197
|
expect(JSON::Validator.
|
|
201
198
|
fully_validate(date_schema_opt, data, opt)[0]).to include(
|
|
202
|
-
|
|
199
|
+
"property '#/a' of type null did not match the following type: string")
|
|
203
200
|
end
|
|
204
201
|
|
|
205
202
|
date_schema_req = {
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
203
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
204
|
+
'required' => ['a'],
|
|
205
|
+
'properties' => {
|
|
206
|
+
'a' => {
|
|
207
|
+
'type' => 'string',
|
|
208
|
+
'format' => 'date'
|
|
212
209
|
}
|
|
213
210
|
}
|
|
214
211
|
}
|
|
215
212
|
|
|
216
|
-
it
|
|
213
|
+
it 'returns error when a required date field is not supplied' do
|
|
217
214
|
data = {}
|
|
218
215
|
expect(JSON::Validator.
|
|
219
216
|
fully_validate(date_schema_req, data, opt)[0]).to include(
|
|
220
|
-
|
|
217
|
+
"property '#/' did not contain a required property of 'a'")
|
|
221
218
|
end
|
|
222
219
|
|
|
223
|
-
it
|
|
224
|
-
data = {
|
|
220
|
+
it 'returns error when a nil date is passed when date is required' do
|
|
221
|
+
data = { 'a' => nil }
|
|
225
222
|
expect(JSON::Validator.
|
|
226
223
|
fully_validate(date_schema_req, data, opt)[0]).to include(
|
|
227
|
-
|
|
224
|
+
"property '#/a' of type null did not match the following type: string")
|
|
228
225
|
end
|
|
229
226
|
|
|
230
227
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
@@ -232,67 +229,67 @@ module Marty
|
|
|
232
229
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
233
230
|
|
|
234
231
|
datetime_schema_opt = {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
232
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
233
|
+
'properties' => {
|
|
234
|
+
'a' => {
|
|
235
|
+
'type' => 'string',
|
|
236
|
+
'format' => 'date-time'
|
|
240
237
|
}
|
|
241
238
|
}
|
|
242
239
|
}
|
|
243
240
|
|
|
244
|
-
it
|
|
245
|
-
data = {
|
|
241
|
+
it 'returns true on a properly formatted datetime' do
|
|
242
|
+
data = { 'a' => '2017-05-22T14:51:44Z' }
|
|
246
243
|
expect(JSON::Validator.validate(datetime_schema_opt, data)).to be true
|
|
247
244
|
end
|
|
248
245
|
|
|
249
|
-
it
|
|
250
|
-
data = {
|
|
246
|
+
it 'vacuously returns true on a field not validated' do
|
|
247
|
+
data = { 'b' => 'Today is May 22nd' }
|
|
251
248
|
expect(JSON::Validator.validate(datetime_schema_opt, data)).to be true
|
|
252
249
|
end
|
|
253
250
|
|
|
254
|
-
it
|
|
255
|
-
data = {
|
|
251
|
+
it 'returns error on an improperly formatted datetime' do
|
|
252
|
+
data = { 'a' => '2017-30-22T14:51:44Z' }
|
|
256
253
|
expect(JSON::Validator.
|
|
257
254
|
fully_validate(datetime_schema_opt, data, opt)[0]).to include(
|
|
258
|
-
|
|
255
|
+
"property '#/a' must be a date/time in the ISO-8601 format")
|
|
259
256
|
end
|
|
260
257
|
|
|
261
|
-
it
|
|
258
|
+
it 'returns true when an opt field is not supplied' do
|
|
262
259
|
data = {}
|
|
263
260
|
expect(JSON::Validator.validate(datetime_schema_opt, data)).to be true
|
|
264
261
|
end
|
|
265
262
|
|
|
266
|
-
it
|
|
267
|
-
data = {
|
|
263
|
+
it 'returns error when a nil dt is passed even when dt is opt' do
|
|
264
|
+
data = { 'a' => nil }
|
|
268
265
|
expect(JSON::Validator.
|
|
269
266
|
fully_validate(datetime_schema_opt, data, opt)[0]).to include(
|
|
270
|
-
|
|
267
|
+
"property '#/a' of type null did not match the following type: string")
|
|
271
268
|
end
|
|
272
269
|
|
|
273
270
|
datetime_schema_req = {
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
271
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
272
|
+
'required' => ['a'],
|
|
273
|
+
'properties' => {
|
|
274
|
+
'a' => {
|
|
275
|
+
'type' => 'string',
|
|
276
|
+
'format' => 'date-time'
|
|
280
277
|
}
|
|
281
278
|
}
|
|
282
279
|
}
|
|
283
280
|
|
|
284
|
-
it
|
|
281
|
+
it 'returns error when a required field is not supplied' do
|
|
285
282
|
data = {}
|
|
286
283
|
expect(JSON::Validator.
|
|
287
284
|
fully_validate(datetime_schema_req, data, opt)[0]).to include(
|
|
288
|
-
|
|
285
|
+
"property '#/' did not contain a required property of 'a'")
|
|
289
286
|
end
|
|
290
287
|
|
|
291
|
-
it
|
|
292
|
-
data = {
|
|
288
|
+
it 'returns error when a nil dt is passed when dt is required' do
|
|
289
|
+
data = { 'a' => nil }
|
|
293
290
|
expect(JSON::Validator.
|
|
294
291
|
fully_validate(datetime_schema_req, data, opt)[0]).to include(
|
|
295
|
-
|
|
292
|
+
"property '#/a' of type null did not match the following type: string")
|
|
296
293
|
end
|
|
297
294
|
|
|
298
295
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
@@ -300,119 +297,119 @@ module Marty
|
|
|
300
297
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
301
298
|
|
|
302
299
|
pg_dt_schema = {
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
300
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
301
|
+
'properties' => {
|
|
302
|
+
'a' => {
|
|
303
|
+
'pg_enum' => 'MammalEnum'
|
|
307
304
|
},
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
305
|
+
'b' => {
|
|
306
|
+
'type' => 'string',
|
|
307
|
+
'format' => 'date-time'
|
|
311
308
|
},
|
|
312
309
|
}
|
|
313
310
|
}
|
|
314
311
|
|
|
315
|
-
it
|
|
316
|
-
data = {
|
|
312
|
+
it 'validates both pg_enum and dt format when both are correct' do
|
|
313
|
+
data = { 'a' => 'Dog', 'b' => '2017-05-22T14:51:44Z' }
|
|
317
314
|
expect(JSON::Validator.validate(pg_dt_schema, data)).to be true
|
|
318
315
|
end
|
|
319
316
|
|
|
320
|
-
it
|
|
321
|
-
data = {
|
|
317
|
+
it 'validates both pg_enum and dt format when only enum is correct' do
|
|
318
|
+
data = { 'a' => 'Dog', 'b' => '2017-55-22T14:51:44Z' }
|
|
322
319
|
expect(JSON::Validator.validate(pg_dt_schema, data)).to be false
|
|
323
320
|
end
|
|
324
321
|
|
|
325
|
-
it
|
|
326
|
-
data = {
|
|
322
|
+
it 'validates both pg_enum and dt format when only dt is correct' do
|
|
323
|
+
data = { 'a' => 'Dogg', 'b' => '2017-05-22T14:51:44Z' }
|
|
327
324
|
expect(JSON::Validator.validate(pg_dt_schema, data)).to be false
|
|
328
325
|
end
|
|
329
326
|
|
|
330
|
-
it
|
|
331
|
-
data = {
|
|
327
|
+
it 'validates both pg_enum and dt format when neither is correct' do
|
|
328
|
+
data = { 'a' => 'Dogg', 'b' => '2017-55-22T14:51:44Z' }
|
|
332
329
|
expect(JSON::Validator.validate(pg_dt_schema, data)).to be false
|
|
333
330
|
end
|
|
334
331
|
|
|
335
332
|
pg_dt_int_schema = {
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
333
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
334
|
+
'properties' => {
|
|
335
|
+
'a' => {
|
|
336
|
+
'pg_enum' => 'MammalEnum'
|
|
340
337
|
},
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
338
|
+
'b' => {
|
|
339
|
+
'type' => 'string',
|
|
340
|
+
'format' => 'date-time'
|
|
344
341
|
},
|
|
345
|
-
|
|
346
|
-
|
|
342
|
+
'c' => {
|
|
343
|
+
'type' => 'integer'
|
|
347
344
|
},
|
|
348
345
|
}
|
|
349
346
|
}
|
|
350
347
|
|
|
351
|
-
it
|
|
352
|
-
data = {
|
|
348
|
+
it 'validates pg_enum, dt format and int when they are correct' do
|
|
349
|
+
data = { 'a' => 'Dog', 'b' => '2017-05-22T14:51:44Z', 'c' => 5 }
|
|
353
350
|
expect(JSON::Validator.validate(pg_dt_int_schema, data)).to be true
|
|
354
351
|
end
|
|
355
352
|
|
|
356
|
-
it
|
|
357
|
-
data = {
|
|
353
|
+
it 'validates pg_enum, dt format and int when one is incorrect' do
|
|
354
|
+
data = { 'a' => 'Chair', 'b' => '2017-05-22T14:51:44Z', 'c' => 5 }
|
|
358
355
|
expect(JSON::Validator.validate(pg_dt_int_schema, data)).to be false
|
|
359
356
|
end
|
|
360
357
|
|
|
361
358
|
pg_dt_int_schema_req = {
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
359
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
360
|
+
'required' => ['b'],
|
|
361
|
+
'properties' => {
|
|
362
|
+
'a' => {
|
|
363
|
+
'pg_enum' => 'MammalEnum'
|
|
367
364
|
},
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
365
|
+
'b' => {
|
|
366
|
+
'type' => 'string',
|
|
367
|
+
'format' => 'date-time'
|
|
371
368
|
},
|
|
372
|
-
|
|
373
|
-
|
|
369
|
+
'c' => {
|
|
370
|
+
'type' => 'integer'
|
|
374
371
|
},
|
|
375
372
|
}
|
|
376
373
|
}
|
|
377
374
|
|
|
378
|
-
it
|
|
379
|
-
data = {
|
|
375
|
+
it 'validates pg_enum, dt format and int when dt is required' do
|
|
376
|
+
data = { 'a' => 'Dog', 'd' => '2017-05-22T14:51:44Z', 'c' => 5 }
|
|
380
377
|
expect(JSON::Validator.validate(pg_dt_int_schema_req, data)).to be false
|
|
381
378
|
end
|
|
382
379
|
|
|
383
380
|
pg_dt_pg_int_schema = {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
381
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
382
|
+
'required' => ['c'],
|
|
383
|
+
'properties' => {
|
|
384
|
+
'a' => {
|
|
385
|
+
'pg_enum' => 'MammalEnum'
|
|
389
386
|
},
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
387
|
+
'b' => {
|
|
388
|
+
'type' => 'string',
|
|
389
|
+
'format' => 'date-time'
|
|
393
390
|
},
|
|
394
|
-
|
|
395
|
-
|
|
391
|
+
'c' => {
|
|
392
|
+
'pg_enum' => 'ElectronicsEnum'
|
|
396
393
|
},
|
|
397
|
-
|
|
398
|
-
|
|
394
|
+
'd' => {
|
|
395
|
+
'type' => 'integer'
|
|
399
396
|
},
|
|
400
397
|
}
|
|
401
398
|
}
|
|
402
399
|
|
|
403
|
-
it
|
|
404
|
-
data = {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
400
|
+
it 'validates a schema containing 2 pg_enums, one that is required' do
|
|
401
|
+
data = { 'a' => 'Dog',
|
|
402
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
403
|
+
'c' => 'Phone',
|
|
404
|
+
'd' => 5 }
|
|
408
405
|
expect(JSON::Validator.validate(pg_dt_pg_int_schema, data)).to be true
|
|
409
406
|
end
|
|
410
407
|
|
|
411
|
-
it
|
|
412
|
-
data = {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
408
|
+
it 'validates a schema containing 2 pg_enums, one that is required' do
|
|
409
|
+
data = { 'a' => 'Dog',
|
|
410
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
411
|
+
'e' => 'Phone',
|
|
412
|
+
'd' => 5 }
|
|
416
413
|
expect(JSON::Validator.validate(pg_dt_pg_int_schema, data)).to be false
|
|
417
414
|
end
|
|
418
415
|
|
|
@@ -421,207 +418,206 @@ module Marty
|
|
|
421
418
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
422
419
|
|
|
423
420
|
nested_schema = {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
421
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
422
|
+
'required' => ['a', 'b', 'c', 'd', 'root1', 'root2'],
|
|
423
|
+
'properties' => {
|
|
424
|
+
'a' => {
|
|
425
|
+
'pg_enum' => 'MammalEnum'
|
|
429
426
|
},
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
427
|
+
'b' => {
|
|
428
|
+
'type' => 'string',
|
|
429
|
+
'format' => 'date-time'
|
|
433
430
|
},
|
|
434
|
-
|
|
435
|
-
|
|
431
|
+
'c' => {
|
|
432
|
+
'pg_enum' => 'ElectronicsEnum'
|
|
436
433
|
},
|
|
437
|
-
|
|
438
|
-
|
|
434
|
+
'd' => {
|
|
435
|
+
'type' => 'integer'
|
|
439
436
|
},
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
437
|
+
'root1' => {
|
|
438
|
+
'type' => 'array',
|
|
439
|
+
'minItems' => 3,
|
|
440
|
+
'items' => {
|
|
441
|
+
'required' => ['x', 'y'],
|
|
442
|
+
'properties' => {
|
|
443
|
+
'x' => { 'type' => 'object',
|
|
444
|
+
'required' => ['w', 't', 'f'],
|
|
445
|
+
'properties' => { 'w' => { 'type' => 'integer',
|
|
446
|
+
'minimum' => 0,
|
|
447
|
+
'maximum' => 3 },
|
|
448
|
+
't' => { 'pg_enum' => 'MammalEnum' },
|
|
449
|
+
'f' => { 'type' => ['number'],
|
|
450
|
+
'minimum' => 0,
|
|
451
|
+
'maximum' => 100,
|
|
452
|
+
'multipleOf' => 5.0 } }
|
|
456
453
|
},
|
|
457
|
-
|
|
454
|
+
'y' => { 'pg_enum' => 'ElectronicsEnum' }
|
|
458
455
|
}
|
|
459
456
|
}
|
|
460
457
|
},
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
458
|
+
'root2' => {
|
|
459
|
+
'type' => 'array',
|
|
460
|
+
'minItems' => 2,
|
|
461
|
+
'items' => {
|
|
462
|
+
'required' => ['m1', 'e', 'm2'],
|
|
463
|
+
'properties' => {
|
|
464
|
+
'm1' => { 'pg_enum' => 'MammalEnum' },
|
|
465
|
+
'e' => { 'pg_enum' => 'ElectronicsEnum' },
|
|
466
|
+
'm2' => { 'pg_enum' => 'MammalEnum' },
|
|
470
467
|
}
|
|
471
468
|
},
|
|
472
469
|
},
|
|
473
470
|
}
|
|
474
471
|
}
|
|
475
472
|
|
|
476
|
-
it
|
|
477
|
-
data = {
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
473
|
+
it 'validates a complex nested schema when correct' do
|
|
474
|
+
data = { 'a' => 'Dog',
|
|
475
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
476
|
+
'root1' => [{ 'x' => { 'w' => 0, 't' => 'Bear', 'f' => 0.0 },
|
|
477
|
+
'y' => 'Phone' },
|
|
478
|
+
{ 'x' => { 'w' => 1, 't' => 'Human', 'f' => 5.0 },
|
|
479
|
+
'y' => 'Terminator' },
|
|
480
|
+
{ 'x' => { 'w' => 2, 't' => 'Dog', 'f' => 65.0 },
|
|
481
|
+
'y' => 'Phone' }],
|
|
482
|
+
'root2' => [{ 'm1' => 'Cat', 'e' => 'Keyboard', 'm2' => 'Dog' },
|
|
483
|
+
{ 'm1' => 'Dog', 'e' => 'Phone', 'm2' => 'Cow' }],
|
|
484
|
+
'c' => 'Terminator',
|
|
485
|
+
'd' => 5
|
|
489
486
|
}
|
|
490
487
|
expect(JSON::Validator.validate(nested_schema, data)).to be true
|
|
491
488
|
end
|
|
492
489
|
|
|
493
|
-
it
|
|
494
|
-
data = {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
490
|
+
it 'validates a complex nested schema when incorrect -- 1' do
|
|
491
|
+
data = { 'a' => 'Dog',
|
|
492
|
+
'b' => '2017-05-32T14:51:44Z', # note DD
|
|
493
|
+
'root1' => [{ 'x' => { 'w' => 0, 't' => 'Bear', 'f' => 0.0 },
|
|
494
|
+
'y' => 'Phone' },
|
|
495
|
+
{ 'x' => { 'w' => 1, 't' => 'Human', 'f' => 5.0 },
|
|
496
|
+
'y' => 'Terminator' },
|
|
497
|
+
{ 'x' => { 'w' => 2, 't' => 'Dog', 'f' => 65.0 },
|
|
498
|
+
'y' => 'Phone' }],
|
|
499
|
+
'root2' => [{ 'm1' => 'Cat', 'e' => 'Keyboard', 'm2' => 'Dog' },
|
|
500
|
+
{ 'm1' => 'Dog', 'e' => 'Phone', 'm2' => 'Cow' }],
|
|
501
|
+
'c' => 'Terminator',
|
|
502
|
+
'd' => 5
|
|
506
503
|
}
|
|
507
504
|
expect(JSON::Validator.validate(nested_schema, data)).to be false
|
|
508
505
|
end
|
|
509
506
|
|
|
510
|
-
it
|
|
511
|
-
data = {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
507
|
+
it 'validates a complex nested schema when incorrect -- 2' do
|
|
508
|
+
data = { 'a' => 'Dog',
|
|
509
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
510
|
+
'root1' => [{ 'x' => { 'w' => 0, 't' => 'Bar', 'f' => 0.0 },
|
|
511
|
+
'y' => 'Phone' },
|
|
512
|
+
{ 'x' => { 'w' => 1, 't' => 'Human', 'f' => 5 },
|
|
513
|
+
'y' => 'Terminator' },
|
|
514
|
+
{ 'x' => { 'w' => 2, 't' => 'Dog', 'f' => 65.0 },
|
|
515
|
+
'y' => 'Phone' }],
|
|
516
|
+
'root2' => [{ 'm1' => 'Cat', 'e' => 'Keyboard', 'm2' => 'Dog' },
|
|
517
|
+
{ 'm1' => 'Dog', 'e' => 'Phone', 'm2' => 'Cow' }],
|
|
518
|
+
'c' => 'Terminator',
|
|
519
|
+
'd' => 5
|
|
523
520
|
}
|
|
524
521
|
expect(JSON::Validator.
|
|
525
522
|
fully_validate(nested_schema, data, opt)[0]).to include(
|
|
526
|
-
|
|
527
|
-
end
|
|
528
|
-
|
|
529
|
-
it
|
|
530
|
-
data = {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
523
|
+
"property '#/root1/0/x/t' value 'Bar' not contained in MammalEnum")
|
|
524
|
+
end
|
|
525
|
+
|
|
526
|
+
it 'validates a complex nested schema when incorrect -- 3' do
|
|
527
|
+
data = { 'a' => 'Dog',
|
|
528
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
529
|
+
'root1' => [{ 'x' => { 'w' => 0, 't' => 'Bear', 'f' => 0.0 },
|
|
530
|
+
'y' => 'Phone' },
|
|
531
|
+
{ 'x' => { 'w' => 1, 't' => 'Human', 'f' => 6.0 },
|
|
532
|
+
'y' => 'Terminator' },
|
|
533
|
+
{ 'x' => { 'w' => 2, 't' => 'Dog', 'f' => 65.0 },
|
|
534
|
+
'y' => 'Phone' }],
|
|
535
|
+
'root2' => [{ 'm1' => 'Cat', 'e' => 'Keyboard', 'm2' => 'Dog' },
|
|
536
|
+
{ 'm1' => 'Dog', 'e' => 'Phone', 'm2' => 'Cow' }],
|
|
537
|
+
'c' => 'Terminator',
|
|
538
|
+
'd' => 5
|
|
542
539
|
}
|
|
543
540
|
expect(JSON::Validator.
|
|
544
541
|
fully_validate(nested_schema, data, opt)[0]).to include(
|
|
545
|
-
|
|
546
|
-
end
|
|
547
|
-
|
|
548
|
-
it
|
|
549
|
-
data = {
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
542
|
+
"property '#/root1/1/x/f' was not divisible by 5.0")
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
it 'validates a complex nested schema when incorrect -- 4' do
|
|
546
|
+
data = { 'a' => 'Dog',
|
|
547
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
548
|
+
'root1' => [{ 'x' => { 'w' => 0, 't' => 'Bear', 'f' => 0.0 },
|
|
549
|
+
'y' => 'Phone' },
|
|
550
|
+
{ 'x' => { 'w' => 1, 't' => 'Human', 'f' => 5.0 },
|
|
551
|
+
'y' => 'Trminator' },
|
|
552
|
+
{ 'x' => { 'w' => 2, 't' => 'Dog', 'f' => 65.0 },
|
|
553
|
+
'y' => 'Phone' }],
|
|
554
|
+
'root2' => [{ 'm1' => 'Cat', 'e' => 'Keyboard', 'm2' => 'Dog' },
|
|
555
|
+
{ 'm1' => 'Dog', 'e' => 'Phone', 'm2' => 'Cow' }],
|
|
556
|
+
'c' => 'Terminator',
|
|
557
|
+
'd' => 5
|
|
561
558
|
}
|
|
562
559
|
expect(JSON::Validator.
|
|
563
560
|
fully_validate(nested_schema, data, opt)[0]).to include(
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
end
|
|
567
|
-
|
|
568
|
-
it
|
|
569
|
-
data = {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
561
|
+
"property '#/root1/1/y' value 'Trminator' not contained "\
|
|
562
|
+
'in ElectronicsEnum')
|
|
563
|
+
end
|
|
564
|
+
|
|
565
|
+
it 'validates a complex nested schema when incorrect -- 5' do
|
|
566
|
+
data = { 'a' => 'Dog',
|
|
567
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
568
|
+
'root1' => [{ 'x' => { 'w' => 0, 't' => 'Bear', 'f' => 0.0 },
|
|
569
|
+
'y' => 'Phone' },
|
|
570
|
+
{ 'x' => { 'w' => 1, 't' => 'Human', 'f' => 5.0 },
|
|
571
|
+
'y' => 'Terminator' },
|
|
572
|
+
{ 'x' => { 'w' => 5, 't' => 'Dog', 'f' => 65.0 },
|
|
573
|
+
'y' => 'Phone' }],
|
|
574
|
+
'root2' => [{ 'm1' => 'Cat', 'e' => 'Keyboard', 'm2' => 'Dog' },
|
|
575
|
+
{ 'm1' => 'Dog', 'e' => 'Phone', 'm2' => 'Cow' }],
|
|
576
|
+
'c' => 'Terminator',
|
|
577
|
+
'd' => 5
|
|
581
578
|
}
|
|
582
579
|
expect(JSON::Validator.
|
|
583
580
|
fully_validate(nested_schema, data, opt)[0]).to include(
|
|
584
|
-
|
|
585
|
-
end
|
|
586
|
-
|
|
587
|
-
it
|
|
588
|
-
data = {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
581
|
+
"property '#/root1/2/x/w' did not have a maximum value of 3, inclusively")
|
|
582
|
+
end
|
|
583
|
+
|
|
584
|
+
it 'validates a complex nested schema when incorrect -- 6' do
|
|
585
|
+
data = { 'a' => 'Dog',
|
|
586
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
587
|
+
'root1' => [{ 'x' => { 'w' => 0, 't' => 'Bear', 'f' => 0.0 },
|
|
588
|
+
'y' => 'Phone' },
|
|
589
|
+
{ 'x' => { 'w' => 1, 't' => 'Human', 'f' => 5.0 },
|
|
590
|
+
'y' => 'Terminator' },
|
|
591
|
+
{ 'x' => { 'w' => -5, 't' => 'Dog', 'f' => 65.0 },
|
|
592
|
+
'y' => 'Phone' }],
|
|
593
|
+
'root2' => [{ 'm1' => 'Cat', 'e' => 'Keyboard', 'm2' => 'Dog' },
|
|
594
|
+
{ 'm1' => 'Dog', 'e' => 'Phone', 'm2' => 'Cow' }],
|
|
595
|
+
'c' => 'Terminator',
|
|
596
|
+
'd' => 5
|
|
600
597
|
}
|
|
601
598
|
expect(JSON::Validator.
|
|
602
599
|
fully_validate(nested_schema, data, opt)[0]).to include(
|
|
603
|
-
|
|
604
|
-
end
|
|
605
|
-
|
|
606
|
-
it
|
|
607
|
-
data = {
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
600
|
+
"property '#/root1/2/x/w' did not have a minimum value of 0, inclusively")
|
|
601
|
+
end
|
|
602
|
+
|
|
603
|
+
it 'validates a complex nested schema when incorrect -- 7' do
|
|
604
|
+
data = { 'a' => 'Dog',
|
|
605
|
+
'b' => '2017-05-22T14:51:44Z',
|
|
606
|
+
'root1' => [{ 'x' => { 'w' => 0, 't' => 'Bear', 'f' => 0.0 },
|
|
607
|
+
'y' => 'Phone' },
|
|
608
|
+
{ 'x' => { 'w' => 1, 't' => 'Human', 'f' => 5.0 },
|
|
609
|
+
'y' => 'Terminator' },
|
|
610
|
+
{ 'x' => { 'w' => 2, 't' => 'Dog', 'f' => 65.0 },
|
|
611
|
+
'y' => 'Phone' }],
|
|
612
|
+
'root2' => [{ 'm1' => 'Cat', 'e' => 'Keyboard', 'm2' => 'Dog' },
|
|
613
|
+
{ 'm1' => 'Dog', 'e' => 'Dog', 'm2' => 'Cow' }],
|
|
614
|
+
'c' => 'Terminator',
|
|
615
|
+
'd' => 5
|
|
619
616
|
}
|
|
620
617
|
expect(JSON::Validator.
|
|
621
618
|
fully_validate(nested_schema, data, opt)[0]).to include(
|
|
622
|
-
|
|
619
|
+
"property '#/root2/1/e' value 'Dog' not contained in ElectronicsEnum")
|
|
623
620
|
end
|
|
624
|
-
|
|
625
621
|
end
|
|
626
622
|
|
|
627
623
|
### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
|
|
@@ -631,7 +627,7 @@ module Marty
|
|
|
631
627
|
class FloorOf8 < JSON::Schema::Attribute
|
|
632
628
|
def self.validate(curr_schema, data, frag, processor, validator, opt)
|
|
633
629
|
if data < 8
|
|
634
|
-
msg =
|
|
630
|
+
msg = 'Error at FloorOf8: Value is below 8'
|
|
635
631
|
validation_error(processor,
|
|
636
632
|
msg,
|
|
637
633
|
frag,
|
|
@@ -645,7 +641,7 @@ module Marty
|
|
|
645
641
|
class CeilingOf20 < JSON::Schema::Attribute
|
|
646
642
|
def self.validate(curr_schema, data, frag, processor, validator, opt)
|
|
647
643
|
if data > 20
|
|
648
|
-
msg =
|
|
644
|
+
msg = 'Error at CeilingOf20: Value exceeds 20'
|
|
649
645
|
validation_error(processor,
|
|
650
646
|
msg,
|
|
651
647
|
frag,
|
|
@@ -656,121 +652,115 @@ module Marty
|
|
|
656
652
|
end
|
|
657
653
|
end
|
|
658
654
|
|
|
659
|
-
|
|
660
|
-
describe "how @uri behaves as a key to a set of attributes" do
|
|
661
|
-
|
|
655
|
+
describe 'how @uri behaves as a key to a set of attributes' do
|
|
662
656
|
class BoundSchema < JSON::Schema::Draft4
|
|
663
657
|
def initialize
|
|
664
658
|
super
|
|
665
|
-
@attributes[
|
|
666
|
-
uri =
|
|
659
|
+
@attributes['bound'] = CeilingOf20
|
|
660
|
+
uri = 'http://json-schema.org/bound-draft/schema#'
|
|
667
661
|
@uri = JSON::Util::URI.parse(uri)
|
|
668
662
|
end
|
|
669
663
|
|
|
670
|
-
JSON::Validator.register_validator(
|
|
664
|
+
JSON::Validator.register_validator(new)
|
|
671
665
|
end
|
|
672
666
|
|
|
673
667
|
marty_uri = {
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
668
|
+
'$schema' => 'http://json-schema.org/marty-draft/schema#',
|
|
669
|
+
'required' => ['a'],
|
|
670
|
+
'properties' => {
|
|
671
|
+
'a' => {
|
|
672
|
+
'pg_enum' => 'MammalEnum',
|
|
679
673
|
},
|
|
680
674
|
}
|
|
681
675
|
}
|
|
682
676
|
|
|
683
677
|
bound_uri = {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
678
|
+
'$schema' => 'http://json-schema.org/bound-draft/schema#',
|
|
679
|
+
'required' => ['a'],
|
|
680
|
+
'properties' => {
|
|
681
|
+
'a' => {
|
|
682
|
+
'pg_enum' => 'MammalEnum',
|
|
689
683
|
},
|
|
690
684
|
}
|
|
691
685
|
}
|
|
692
686
|
|
|
693
|
-
it
|
|
694
|
-
data = {
|
|
687
|
+
it 'validates an attribute dictated by its uri (Positive)' do
|
|
688
|
+
data = { 'a' => 'Dog' }
|
|
695
689
|
expect(JSON::Validator.validate(marty_uri, data)).to be true
|
|
696
690
|
end
|
|
697
691
|
|
|
698
|
-
it
|
|
699
|
-
data = {
|
|
692
|
+
it 'validates an attribute dictated by its uri (Negative)' do
|
|
693
|
+
data = { 'a' => 'Table' }
|
|
700
694
|
expect(JSON::Validator.validate(marty_uri, data)).to be false
|
|
701
695
|
end
|
|
702
696
|
|
|
703
|
-
it
|
|
704
|
-
data = {
|
|
697
|
+
it 'incorrectly validates an attribute not part of its uri' do
|
|
698
|
+
data = { 'a' => 'Table' }
|
|
705
699
|
expect(JSON::Validator.validate(bound_uri, data)).to be true
|
|
706
700
|
end
|
|
707
|
-
|
|
708
701
|
end
|
|
709
702
|
|
|
710
|
-
describe
|
|
711
|
-
|
|
703
|
+
describe 'how @uri also behaves as namespace' do
|
|
712
704
|
class BoundFloorSchema < JSON::Schema::Draft4
|
|
713
705
|
def initialize
|
|
714
706
|
super
|
|
715
|
-
@attributes[
|
|
716
|
-
uri =
|
|
707
|
+
@attributes['bound'] = FloorOf8
|
|
708
|
+
uri = 'http://json-schema.org/bound-floor-draft/schema#'
|
|
717
709
|
@uri = JSON::Util::URI.parse(uri)
|
|
718
710
|
end
|
|
719
711
|
|
|
720
|
-
JSON::Validator.register_validator(
|
|
712
|
+
JSON::Validator.register_validator(new)
|
|
721
713
|
end
|
|
722
714
|
|
|
723
715
|
class BoundCeilingSchema < JSON::Schema::Draft4
|
|
724
716
|
def initialize
|
|
725
717
|
super
|
|
726
|
-
@attributes[
|
|
727
|
-
uri =
|
|
718
|
+
@attributes['bound'] = CeilingOf20
|
|
719
|
+
uri = 'http://json-schema.org/bound-ceiling-draft/schema#'
|
|
728
720
|
@uri = JSON::Util::URI.parse(uri)
|
|
729
721
|
end
|
|
730
722
|
|
|
731
|
-
JSON::Validator.register_validator(
|
|
723
|
+
JSON::Validator.register_validator(new)
|
|
732
724
|
end
|
|
733
725
|
|
|
734
726
|
bound_floor_schema = {
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
727
|
+
'$schema' => 'http://json-schema.org/bound-floor-draft/schema#',
|
|
728
|
+
'required' => ['a'],
|
|
729
|
+
'properties' => {
|
|
730
|
+
'a' => {
|
|
731
|
+
'bound' => '',
|
|
740
732
|
},
|
|
741
733
|
}
|
|
742
734
|
}
|
|
743
735
|
|
|
744
736
|
bound_ceiling_schema = {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
737
|
+
'$schema' => 'http://json-schema.org/bound-ceiling-draft/schema#',
|
|
738
|
+
'required' => ['a'],
|
|
739
|
+
'properties' => {
|
|
740
|
+
'a' => {
|
|
741
|
+
'bound' => '',
|
|
750
742
|
},
|
|
751
743
|
}
|
|
752
744
|
}
|
|
753
745
|
|
|
754
|
-
it
|
|
755
|
-
data = {
|
|
746
|
+
it 'validates BoundFloorSchema when called with its uri (Positive)' do
|
|
747
|
+
data = { 'a' => 9 }
|
|
756
748
|
expect(JSON::Validator.validate(bound_floor_schema, data)).to be true
|
|
757
749
|
end
|
|
758
750
|
|
|
759
|
-
it
|
|
760
|
-
data = {
|
|
751
|
+
it 'validates BoundFloorSchema when called with its uri (Negative)' do
|
|
752
|
+
data = { 'a' => 7 }
|
|
761
753
|
expect(JSON::Validator.validate(bound_floor_schema, data)).to be false
|
|
762
754
|
end
|
|
763
755
|
|
|
764
|
-
it
|
|
765
|
-
data = {
|
|
756
|
+
it 'validates BoundCeilingSchema when called with its uri (Positive)' do
|
|
757
|
+
data = { 'a' => 19 }
|
|
766
758
|
expect(JSON::Validator.validate(bound_ceiling_schema, data)).to be true
|
|
767
759
|
end
|
|
768
760
|
|
|
769
|
-
it
|
|
770
|
-
data = {
|
|
761
|
+
it 'validates BoundCielingSchema when called with its uri (Negative)' do
|
|
762
|
+
data = { 'a' => 21 }
|
|
771
763
|
expect(JSON::Validator.validate(bound_ceiling_schema, data)).to be false
|
|
772
764
|
end
|
|
773
|
-
|
|
774
765
|
end
|
|
775
|
-
|
|
776
766
|
end
|