quby 4.0.4 → 5.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/quby/questionnaires.rb +1 -0
- data/lib/quby/questionnaires/api.rb +5 -1
- data/lib/quby/questionnaires/deserializer.rb +433 -0
- data/lib/quby/questionnaires/dsl.rb +10 -15
- data/lib/quby/questionnaires/entities.rb +1 -0
- data/lib/quby/questionnaires/entities/charting/line_chart.rb +23 -0
- data/lib/quby/questionnaires/entities/charting/overview_chart.rb +3 -1
- data/lib/quby/questionnaires/entities/definition.rb +3 -5
- data/lib/quby/questionnaires/entities/fields.rb +0 -15
- data/lib/quby/questionnaires/entities/question.rb +9 -32
- data/lib/quby/questionnaires/entities/questionnaire.rb +4 -15
- data/lib/quby/questionnaires/entities/questions/checkbox_question.rb +0 -24
- data/lib/quby/questionnaires/entities/questions/date_question.rb +0 -8
- data/lib/quby/questionnaires/entities/score_calculation.rb +36 -3
- data/lib/quby/questionnaires/repos.rb +1 -0
- data/lib/quby/questionnaires/repos/bundle_disk_repo.rb +51 -0
- data/lib/quby/version.rb +1 -1
- data/spec/internal/log/test-events.log +0 -451
- data/spec/internal/log/test.log +0 -18003
- data/spec/quby/answers/services/answer_validations_spec.rb +8 -8
- data/spec/quby/questionnaires/deserializer/questionnaire_spec.rb +237 -0
- data/spec/quby/questionnaires/dsl_spec.rb +0 -9
- data/spec/quby/questionnaires/entities/fields_spec.rb +3 -3
- data/spec/quby/questionnaires/entities/question_spec.rb +0 -8
- data/spec/quby/questionnaires/entities/questionnaire_spec.rb +2 -26
- data/spec/quby/table_backend/range_tree_spec.rb +7 -0
- data/spec/spec_helper.rb +1 -0
- metadata +22 -139
- data/lib/quby/questionnaires/dsl/base.rb +0 -20
- data/lib/quby/questionnaires/dsl/calls_custom_methods.rb +0 -29
- data/lib/quby/questionnaires/dsl/charting/bar_chart_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/charting/chart_builder.rb +0 -91
- data/lib/quby/questionnaires/dsl/charting/line_chart_builder.rb +0 -57
- data/lib/quby/questionnaires/dsl/charting/overview_chart_builder.rb +0 -31
- data/lib/quby/questionnaires/dsl/charting/radar_chart_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/helpers.rb +0 -51
- data/lib/quby/questionnaires/dsl/panel_builder.rb +0 -80
- data/lib/quby/questionnaires/dsl/question_builder.rb +0 -40
- data/lib/quby/questionnaires/dsl/questionnaire_builder.rb +0 -260
- data/lib/quby/questionnaires/dsl/questions/base.rb +0 -179
- data/lib/quby/questionnaires/dsl/questions/checkbox_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/date_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/deprecated_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/float_question_builder.rb +0 -21
- data/lib/quby/questionnaires/dsl/questions/integer_question_builder.rb +0 -21
- data/lib/quby/questionnaires/dsl/questions/radio_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/select_question_builder.rb +0 -18
- data/lib/quby/questionnaires/dsl/questions/string_question_builder.rb +0 -20
- data/lib/quby/questionnaires/dsl/questions/text_question_builder.rb +0 -22
- data/lib/quby/questionnaires/dsl/score_builder.rb +0 -22
- data/lib/quby/questionnaires/dsl/standardized_panel_generators.rb +0 -33
- data/lib/quby/questionnaires/dsl/table_builder.rb +0 -48
- data/lib/quby/questionnaires/services/definition_validator.rb +0 -298
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-21-57.510.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-21-57.510.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-23-56.006.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-23-56.006.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-24-43.842.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-24-43.842.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-04.631.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-04.631.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-11.690.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-25-11.690.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-25.111.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-25.111.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-57.026.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-26-57.026.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-13.545.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-13.545.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-45.475.html +0 -12
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-27-45.475.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-32-13.907.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-10-27-18-32-13.907.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-16-31.954.html +0 -207
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-16-31.954.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-16-59.938.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-16-59.938.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-08.700.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-08.700.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-11.550.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-11.550.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-14.413.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-14.413.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-17.275.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-17.275.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-20.191.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-20.191.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-23.042.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-23.042.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-25.927.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-25.927.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-28.735.html +0 -323
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-17-28.735.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-40-20.422.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-40-20.422.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-40-20.738.html +0 -1
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-40-20.738.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-41-16.971.html +0 -207
- data/spec/internal/tmp/capybara/screenshot_2020-11-04-13-41-16.971.png +0 -0
- data/spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb +0 -38
- data/spec/quby/questionnaires/dsl/charting/bar_chart_builder_spec.rb +0 -41
- data/spec/quby/questionnaires/dsl/charting/chart_builder_spec.rb +0 -127
- data/spec/quby/questionnaires/dsl/charting/line_chart_builder_spec.rb +0 -66
- data/spec/quby/questionnaires/dsl/charting/radar_chart_builder_spec.rb +0 -41
- data/spec/quby/questionnaires/dsl/helpers_spec.rb +0 -80
- data/spec/quby/questionnaires/dsl/questionnaire_builder_spec.rb +0 -480
- data/spec/quby/questionnaires/services/definition_validator_spec.rb +0 -793
- data/spec/support/examples_for_chart_builders.rb +0 -59
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
<html><head></head><body></body></html>
|
Binary file
|
@@ -1 +0,0 @@
|
|
1
|
-
<html><head></head><body></body></html>
|
Binary file
|
@@ -1,207 +0,0 @@
|
|
1
|
-
<html class="no-js"><!-- <![endif]--><head>
|
2
|
-
<meta content="text/html; charset=utf-8" http-equiv="content-type">
|
3
|
-
<meta content="IE=edge" http-equiv="X-UA-Compatible">
|
4
|
-
<title>Vragenlijst</title>
|
5
|
-
<meta content="width=device-width, initial-scale=1.0 , user-scalable=no" name="viewport">
|
6
|
-
<link rel="stylesheet" media="screen, projection" href="/assets/quby/application-613d22026324a8ae8b7c205fd32e0719011164fdd9ca34aad1483b1b74721932.css">
|
7
|
-
<link rel="stylesheet" media="print" href="/assets/quby/print-2c9d02886ac8119671ccec3fe13a025efd1086b5355927d242d524ffbb358ab4.css">
|
8
|
-
|
9
|
-
<script src="/assets/quby/application-ac694f928c966ab7ccbc92caffa6581288a3669caf09163778be2cfaf3e47ba2.js"></script>
|
10
|
-
<script src="/assets/quby/disable_keys-72d21d5eab421fd3b0709bf0f5ead2bfe5e824a2060d20ce56e2c3ecf3edf8aa.js"></script>
|
11
|
-
<script src="/assets/quby/answers-72b3815aba9fa0fcc608ae7405efb641abedfa5cd62c60a8c824063a3ff22137.js"></script>
|
12
|
-
<style>
|
13
|
-
|
14
|
-
</style>
|
15
|
-
<script>
|
16
|
-
$(function() {
|
17
|
-
if (navigator.userAgent.indexOf("Trident/5") > -1)
|
18
|
-
$("html").addClass("lt-ie9")
|
19
|
-
});
|
20
|
-
</script>
|
21
|
-
</head>
|
22
|
-
<body>
|
23
|
-
<div id="masthead"></div>
|
24
|
-
<div id="content">
|
25
|
-
<div class="flash">
|
26
|
-
</div>
|
27
|
-
<script>
|
28
|
-
window.panel_validations = {};
|
29
|
-
// for setting values of raw_content
|
30
|
-
window.extra_question_values = {};
|
31
|
-
// for showing validations of raw content
|
32
|
-
window.extra_failed_validations = {};
|
33
|
-
</script>
|
34
|
-
<form class="test paged" autocomplete="off" id="questionnaire-form" action="/quby/questionnaires/test/answers/a98c8755-a89c-47ce-8a7c-12fa11e452b2" accept-charset="UTF-8" data-remote="true" method="post"><input name="utf8" type="hidden" value="✓"><input type="hidden" name="_method" value="put">
|
35
|
-
<input type="hidden" name="token" id="token">
|
36
|
-
<input type="hidden" name="hmac" id="hmac">
|
37
|
-
<input type="hidden" name="timestamp" id="timestamp">
|
38
|
-
<input type="hidden" name="return_url" id="return_url">
|
39
|
-
<input type="hidden" name="return_token" id="return_token">
|
40
|
-
<input type="hidden" name="display_mode" id="display_mode" value="paged">
|
41
|
-
<input type="hidden" name="rendered_at" id="rendered_at" value="1604493676">
|
42
|
-
|
43
|
-
<!-- Begin _panel.html.haml -->
|
44
|
-
<fieldset class="panel hidden first last-panel current" id="panel0" style="display: block;">
|
45
|
-
<div class="panel-action-links">
|
46
|
-
|
47
|
-
</div>
|
48
|
-
<script>
|
49
|
-
panel_validations["panel0"] = {"v_1_a1_val":[{"type":"requires_answer","explanation":null},{"type":"valid_integer","explanation":null}],"v_1_a2_val":[{"type":"requires_answer","explanation":null},{"type":"valid_integer","explanation":null}],"v_1":[{"type":"requires_answer","explanation":null}]};
|
50
|
-
</script>
|
51
|
-
<script>
|
52
|
-
$(function() {
|
53
|
-
Quby.currentPanelQuestions = new Quby.Collections.Questions;
|
54
|
-
var questions = [{"class":"Quby::Questionnaires::Entities::Questions::RadioQuestion","key":"v_1","title":"\u003cp\u003eA select box\u003c/p\u003e","description":"","type":"radio","unit":null,"size":null,"hidden":null,"displayModes":null,"defaultInvisible":false,"viewSelector":"#item_v_1","parentKey":null,"parentOptionKey":null,"deselectable":true,"presentation":"vertical","as":null,"questionGroup":null,"options":[{"key":"a1","value":1,"description":"\u003cp\u003eJa\u003c/p\u003e","context_free_description":"\u003cp\u003eJa\u003c/p\u003e","questions":[{"class":"Quby::Questionnaires::Entities::Questions::IntegerQuestion","key":"v_1_a1_val","title":"","description":"","type":"integer","unit":null,"size":30,"hidden":null,"displayModes":null,"defaultInvisible":false,"viewSelector":"#item_v_1_a1_val","parentKey":"v_1","parentOptionKey":"a1","deselectable":true,"presentation":"vertical","as":null,"questionGroup":null}],"innerTitle":null,"hidesQuestions":[],"showsQuestions":[],"hidden":false,"placeholder":false,"viewId":"answer_v_1_a1","startChosen":false},{"key":"a2","value":2,"description":"\u003cp\u003eNee\u003c/p\u003e","context_free_description":"\u003cp\u003eNee\u003c/p\u003e","questions":[{"class":"Quby::Questionnaires::Entities::Questions::IntegerQuestion","key":"v_1_a2_val","title":"","description":"","type":"integer","unit":null,"size":30,"hidden":null,"displayModes":null,"defaultInvisible":false,"viewSelector":"#item_v_1_a2_val","parentKey":"v_1","parentOptionKey":"a2","deselectable":true,"presentation":"vertical","as":null,"questionGroup":null}],"innerTitle":null,"hidesQuestions":[],"showsQuestions":[],"hidden":false,"placeholder":false,"viewId":"answer_v_1_a2","startChosen":true}]}];
|
55
|
-
var initializer = new Quby.Logic.InitQuestions(questions);
|
56
|
-
Quby.currentPanelQuestions = initializer.initializeQuestions();
|
57
|
-
Quby.questions.addQuestions(Quby.currentPanelQuestions);
|
58
|
-
panelProps = {panelId: 'panel0', questions: Quby.currentPanelQuestions}
|
59
|
-
Quby.panels.add(new Quby.Models.Panel(panelProps));
|
60
|
-
});
|
61
|
-
</script>
|
62
|
-
|
63
|
-
<!-- .panel_index= panel_counter + 1 -->
|
64
|
-
<!-- Begin _item.html.haml -->
|
65
|
-
<div class="item radio vertical" id="item_v_1">
|
66
|
-
<div class="error requires_answer hidden">Deze vraag moet beantwoord worden.</div>
|
67
|
-
|
68
|
-
<div class="main" data-for="v_1">
|
69
|
-
<label for="answer_v_1"><p>A select box</p></label>
|
70
|
-
</div>
|
71
|
-
|
72
|
-
<div class="description-and-fields">
|
73
|
-
<div class="description">
|
74
|
-
</div>
|
75
|
-
<div class="fields" id="answer_v_1_input">
|
76
|
-
<div class="option" for="v_1">
|
77
|
-
<div class="radiocheckwrapper">
|
78
|
-
<input class="radio deselectable" data-field-key="v_1" type="radio" value="a1" name="answer[v_1]" id="answer_v_1_a1">
|
79
|
-
</div>
|
80
|
-
<div class="labelwrapper">
|
81
|
-
<label for="answer_v_1_a1">
|
82
|
-
<span>
|
83
|
-
<p>Ja</p>
|
84
|
-
</span>
|
85
|
-
</label>
|
86
|
-
</div>
|
87
|
-
<div class="subquestions"><!-- Begin _item.html.haml -->
|
88
|
-
<div class="item integer vertical subitem" id="item_v_1_a1_val">
|
89
|
-
<div class="error requires_answer hidden">Deze vraag moet beantwoord worden.</div>
|
90
|
-
<div class="error valid_integer hidden">Uw antwoord moet een afgerond getal zijn.</div>
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
<div class="description-and-fields">
|
95
|
-
<div class="description">
|
96
|
-
</div>
|
97
|
-
<div class="fields" id="answer_v_1_a1_val_input">
|
98
|
-
<input autocomplete="off" class="integer subinput" disabled="disabled" size="30" data-show-values="false" data-field-key="v_1_a1_val" type="text" name="answer[v_1_a1_val]" id="answer_v_1_a1_val">
|
99
|
-
<span class="unit"></span>
|
100
|
-
</div>
|
101
|
-
</div>
|
102
|
-
|
103
|
-
</div>
|
104
|
-
<!-- End _item.html.haml -->
|
105
|
-
</div>
|
106
|
-
</div>
|
107
|
-
<div class="option" for="v_1">
|
108
|
-
<div class="radiocheckwrapper">
|
109
|
-
<input class="radio deselectable" data-field-key="v_1" type="radio" value="a2" checked="checked" name="answer[v_1]" id="answer_v_1_a2">
|
110
|
-
</div>
|
111
|
-
<div class="labelwrapper">
|
112
|
-
<label for="answer_v_1_a2">
|
113
|
-
<span>
|
114
|
-
<p>Nee</p>
|
115
|
-
</span>
|
116
|
-
</label>
|
117
|
-
</div>
|
118
|
-
<div class="subquestions"><!-- Begin _item.html.haml -->
|
119
|
-
<div class="item integer vertical subitem" id="item_v_1_a2_val">
|
120
|
-
<div class="error requires_answer hidden">Deze vraag moet beantwoord worden.</div>
|
121
|
-
<div class="error valid_integer hidden">Uw antwoord moet een afgerond getal zijn.</div>
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
<div class="description-and-fields">
|
126
|
-
<div class="description">
|
127
|
-
</div>
|
128
|
-
<div class="fields" id="answer_v_1_a2_val_input">
|
129
|
-
<input autocomplete="off" class="integer subinput" size="30" data-show-values="false" data-field-key="v_1_a2_val" type="text" name="answer[v_1_a2_val]" id="answer_v_1_a2_val">
|
130
|
-
<span class="unit"></span>
|
131
|
-
</div>
|
132
|
-
</div>
|
133
|
-
|
134
|
-
</div>
|
135
|
-
<!-- End _item.html.haml -->
|
136
|
-
</div>
|
137
|
-
</div>
|
138
|
-
</div>
|
139
|
-
</div>
|
140
|
-
|
141
|
-
</div>
|
142
|
-
<!-- End _item.html.haml -->
|
143
|
-
|
144
|
-
<div class="buttons">
|
145
|
-
<div class="prev" style="visibility: hidden;">
|
146
|
-
<input type="submit" name="previous" value="← Terug" id="prevButton0" tabindex="-1" data-disable-with="← Terug">
|
147
|
-
</div>
|
148
|
-
<div class="abort">
|
149
|
-
|
150
|
-
</div>
|
151
|
-
<div class="save">
|
152
|
-
<input type="submit" name="done" value="Klaar" id="done-button" data-disable-with="Klaar">
|
153
|
-
</div>
|
154
|
-
<div class="print">
|
155
|
-
<a class="print_button" data-url="/quby/questionnaires/test/answers/a98c8755-a89c-47ce-8a7c-12fa11e452b2/pdf" href="#" id="print-button">
|
156
|
-
<img src="/assets/quby/pdf-f359df32ce6a12283052679fb5f48e210c5441400f1ddee7edca611fdf722864.gif">
|
157
|
-
Download als PDF
|
158
|
-
</a>
|
159
|
-
<div class="hidden" id="ios-download-instruction">
|
160
|
-
Er opent een nieuw tabblad waarop de download wordt gestart.
|
161
|
-
|
162
|
-
Sla het bestand op in Boeken/iBooks. Keer dan terug naar de browser met de knop '< Safari' geheel linksboven.
|
163
|
-
|
164
|
-
Ga in de browser terug met de terug knop '<' en druk op 'Klaar' om je invulling vast te leggen.
|
165
|
-
</div>
|
166
|
-
</div>
|
167
|
-
|
168
|
-
</div>
|
169
|
-
</fieldset>
|
170
|
-
<!-- End _panel.html.haml -->
|
171
|
-
|
172
|
-
</form>
|
173
|
-
|
174
|
-
<script>
|
175
|
-
$(function() {
|
176
|
-
Quby.init({
|
177
|
-
questionnaire_key: "test",
|
178
|
-
answer_value: {"v_1":"a2"},
|
179
|
-
flag_definitions: {},
|
180
|
-
flag_values: {},
|
181
|
-
textvars: {}
|
182
|
-
});
|
183
|
-
|
184
|
-
// Initialize all panels in bulk, activate first panel otherwise
|
185
|
-
if(isBulkOrSinglePage) {
|
186
|
-
initShowsHides("all_panels");
|
187
|
-
} else {
|
188
|
-
activatePanel($(".panel:first"), true);
|
189
|
-
}
|
190
|
-
});
|
191
|
-
</script>
|
192
|
-
|
193
|
-
<div class="hidden" id="modalFrameDialog">
|
194
|
-
<iframe id="modalFrame"></iframe>
|
195
|
-
</div>
|
196
|
-
|
197
|
-
|
198
|
-
<div class="flash">
|
199
|
-
</div>
|
200
|
-
</div>
|
201
|
-
<div class="x_container"></div>
|
202
|
-
<noscript>
|
203
|
-
<div id='noscript-warning'>Deze vragenlijst heeft ondersteuning voor JavaScript nodig.</div>
|
204
|
-
</noscript>
|
205
|
-
|
206
|
-
|
207
|
-
</body></html>
|
Binary file
|
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module Quby::Questionnaires::DSL
|
6
|
-
describe CallsCustomMethods do
|
7
|
-
|
8
|
-
class TestCustomMethod
|
9
|
-
prepend CallsCustomMethods
|
10
|
-
|
11
|
-
attr_reader :test
|
12
|
-
def initialize(*args)
|
13
|
-
@test = 'attribute'
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:custom_methods) { {custom: -> { 'custom_method' }} }
|
18
|
-
let(:test_object) { TestCustomMethod.new(custom_methods: custom_methods) }
|
19
|
-
|
20
|
-
describe 'prepending' do
|
21
|
-
it 'does not skip the actual initializer' do
|
22
|
-
expect(test_object.test).to eq('attribute')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe '#method_missing' do
|
27
|
-
it 'allows the class to receive messages defined in custom_methods' do
|
28
|
-
expect(test_object.custom).to eq('custom_method')
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe '#respond_to_missing?' do
|
33
|
-
it 'also considers custom methods' do
|
34
|
-
expect(test_object.send(:respond_to_missing?, :custom)).to eq(true)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module Quby::Questionnaires::DSL
|
6
|
-
describe BarChartBuilder do
|
7
|
-
it_behaves_like ChartBuilder
|
8
|
-
|
9
|
-
let(:questionnaire) { double(key: 'questionnaire_key') }
|
10
|
-
|
11
|
-
it 'makes a bar chart' do
|
12
|
-
expect(dsl { }).to be_an_instance_of(::Quby::Questionnaires::Entities::Charting::BarChart)
|
13
|
-
end
|
14
|
-
|
15
|
-
def dsl(key = :test, options = {}, &block)
|
16
|
-
builder = BarChartBuilder.new(questionnaire, key, options)
|
17
|
-
builder.build(&block)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'sets y-axis range' do
|
21
|
-
expect(dsl { range 0..40 }.y_range).to eq (0..40)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'sets y-axis tick interval' do
|
25
|
-
expect(dsl { tick_interval 1 }.tick_interval).to eq 1
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'sets plotlines' do
|
29
|
-
plotlines =
|
30
|
-
dsl do
|
31
|
-
plotline 40, :orange
|
32
|
-
plotline 60, :red
|
33
|
-
end.plotlines
|
34
|
-
|
35
|
-
expect(plotlines).to eq [
|
36
|
-
{value: 40, color: :orange, width: 1, zIndex: 3},
|
37
|
-
{value: 60, color: :red, width: 1, zIndex: 3}
|
38
|
-
]
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module Quby::Questionnaires::DSL
|
6
|
-
describe ChartBuilder do
|
7
|
-
|
8
|
-
let(:plottable_key) { :some_key }
|
9
|
-
let(:plottable) { Quby::Questionnaires::Entities::ScoreCalculation.new plottable_key, {} }
|
10
|
-
let(:questionnaire) do
|
11
|
-
double(key: 'questionnaire_key').tap do |questionnaire|
|
12
|
-
allow(questionnaire).to receive(:find_plottable).with(plottable_key).and_return plottable
|
13
|
-
end
|
14
|
-
end
|
15
|
-
let(:chart_plottables) { [] }
|
16
|
-
let(:chart_class) { Quby::Questionnaires::Entities::Charting::Chart }
|
17
|
-
before { ChartBuilder.set_chart_class(chart_class) }
|
18
|
-
let(:chart_builder) { ChartBuilder.new questionnaire, 'chart_key' }
|
19
|
-
|
20
|
-
def dsl(key = :test, options = {}, &block)
|
21
|
-
builder = ChartBuilder.new(questionnaire, key, options)
|
22
|
-
builder.build(&block)
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#plot' do
|
26
|
-
it 'fetches a plottable by key from the questionnaire' do
|
27
|
-
expect(questionnaire).to receive(:find_plottable).with(plottable_key)
|
28
|
-
chart_builder.plot plottable_key
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'creates a plottable with the options merged into the plottable options' do
|
32
|
-
allow(plottable).to receive(:options).and_return({some: 'options', other: 'options'})
|
33
|
-
expect(Quby::Questionnaires::Entities::Charting::Plottable).to receive(:new)
|
34
|
-
.with(plottable.key,
|
35
|
-
some: 'different_options',
|
36
|
-
other: 'options',
|
37
|
-
questionnaire_key: 'questionnaire_key')
|
38
|
-
chart_builder.plot plottable_key, some: 'different_options'
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'sets the label from a question title when no label is present' do
|
42
|
-
plottable = Quby::Questionnaires::Entities::Question.new plottable_key, title: 'some_title'
|
43
|
-
expect(questionnaire).to receive(:find_plottable).with(plottable_key).and_return plottable
|
44
|
-
expect(Quby::Questionnaires::Entities::Charting::Plottable).to receive(:new)
|
45
|
-
.with(plottable_key, questionnaire_key: 'questionnaire_key', label: 'some_title')
|
46
|
-
chart_builder.plot plottable_key
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'does not set the label when it is given in the options' do
|
50
|
-
plottable = Quby::Questionnaires::Entities::Question.new plottable_key, title: 'some_title'
|
51
|
-
expect(questionnaire).to receive(:find_plottable).with(plottable_key).and_return plottable
|
52
|
-
expect(Quby::Questionnaires::Entities::Charting::Plottable).to receive(:new)
|
53
|
-
.with(plottable_key, questionnaire_key: 'questionnaire_key', label: 'some_label')
|
54
|
-
chart_builder.plot plottable_key, label: 'some_label'
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#y_categories' do
|
59
|
-
it 'assigns y_categories' do
|
60
|
-
categories = %w(Bad Great Best)
|
61
|
-
chart_builder.y_categories categories
|
62
|
-
expect(chart_builder.build { }.y_categories).to eq(categories)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#plotband' do
|
67
|
-
it 'can set plotbands' do
|
68
|
-
plotbands =
|
69
|
-
dsl do
|
70
|
-
plotband 2, 5, :yellow
|
71
|
-
plotband 5, 8, :red
|
72
|
-
end.plotbands
|
73
|
-
|
74
|
-
expect(plotbands).to eq [
|
75
|
-
{from: 2, to: 5, color: :yellow},
|
76
|
-
{from: 5, to: 8, color: :red}
|
77
|
-
]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe '#y_range_categories' do
|
82
|
-
it 'sets RangeCategories.new(*parameters).as_range_hash to the chart y_range_categories' do
|
83
|
-
expect(RangeCategories).to receive(:new).with(0, 'Zeer laag', 30).and_return(double(as_range_hash: 'foo'))
|
84
|
-
chart_builder.y_range_categories 0, 'Zeer laag', 30
|
85
|
-
expect(chart_builder.build { }.y_range_categories).to eq('foo')
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'converts the parameters to a range hash' do
|
89
|
-
expected_categories = {(0.0...30.0) => "Zeer laag", (30.0...40.0) => "Laag", (40.0...60.0) => "Gemiddeld",
|
90
|
-
(60.0...70.0) => "Hoog", (70.0..100.0) => "Zeer hoog"}
|
91
|
-
chart_builder.y_range_categories 0, 'Zeer laag',
|
92
|
-
30, 'Laag',
|
93
|
-
40, 'Gemiddeld',
|
94
|
-
60, 'Hoog',
|
95
|
-
70, 'Zeer hoog', 100
|
96
|
-
expect(chart_builder.build { }.y_range_categories).to eq(expected_categories)
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '#range' do
|
101
|
-
it 'assigns y_range' do
|
102
|
-
chart_builder.range 0..5
|
103
|
-
expect(chart_builder.build { }.y_range).to eq(0..5)
|
104
|
-
end
|
105
|
-
end
|
106
|
-
describe '#validate' do
|
107
|
-
describe 'when there is no range defined but y_categories are present' do
|
108
|
-
it 'uses the 0..y_categories.count-1 as a range' do
|
109
|
-
chart_builder.y_categories %w(Bad Great Best)
|
110
|
-
expect(chart_builder.build { }.y_range).to eq(0..2)
|
111
|
-
end
|
112
|
-
end
|
113
|
-
describe 'when range and y_categories are present' do
|
114
|
-
it 'raises if the range does not correspond to the y_categories length' do
|
115
|
-
chart_builder.range 0..3
|
116
|
-
chart_builder.y_categories %w(Bad Great Best)
|
117
|
-
expect { chart_builder.build { } }.to raise_error(ArgumentError)
|
118
|
-
end
|
119
|
-
it 'does not raise if the range matches the y_categories' do
|
120
|
-
chart_builder.range 0..2
|
121
|
-
chart_builder.y_categories %w(Bad Great Best)
|
122
|
-
expect { chart_builder.build { } }.not_to raise_error
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module Quby::Questionnaires::DSL
|
6
|
-
describe LineChartBuilder do
|
7
|
-
it_behaves_like ChartBuilder
|
8
|
-
|
9
|
-
let(:questionnaire) { double(key: 'questionnaire_key') }
|
10
|
-
|
11
|
-
it 'sets y-axis label' do
|
12
|
-
expect(dsl { y_axis_label 'Label' }.y_label).to eq 'Label'
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'sets y-axis range' do
|
16
|
-
expect(dsl { range 0..40 }.y_range).to eq (0..40)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'sets y-axis tick interval' do
|
20
|
-
expect(dsl { tick_interval 1 }.tick_interval).to eq 1
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'raises when y-axis range is not specified' do
|
24
|
-
expect { dsl(:test, {}) { } }.to raise_error(/no range specified/)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'sets tonality' do
|
28
|
-
expect(dsl { tonality :higher_is_better }.tonality).to eq :higher_is_better
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'sets baseline to constant value' do
|
32
|
-
expect(dsl { baseline 5 }.baseline.call(1, :male)).to eq 5.0
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'sets baseline by hash', :aggregate_failures do
|
36
|
-
chart = dsl { baseline({(0..1000) => {female: 5, default: 3}, default: {female: 1, default: 2}}) }
|
37
|
-
expect(chart.baseline.call(1, :female)).to eq(5)
|
38
|
-
expect(chart.baseline.call(1, :two_spirit)).to eq(3)
|
39
|
-
expect(chart.baseline.call(5000, nil)).to eq(2)
|
40
|
-
expect(chart.baseline.call(nil, :female)).to eq(1)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'sets baseline to proc' do
|
44
|
-
expect(dsl { baseline { |age, gender| age } }.baseline.call(5, :male)).to eq(5.0)
|
45
|
-
expect { dsl { baseline { |age| age } } }.to raise_error(ArgumentError, /must take two arguments/)
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'raises error if not giving baseline value or block' do
|
49
|
-
expect { dsl { baseline } }.to raise_error(ArgumentError, /either value or a block/)
|
50
|
-
expect { dsl { baseline(5.0) { |age, gender| age } } }.to raise_error(ArgumentError, /either value or a block/)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'sets clinically relevant change' do
|
54
|
-
expect(dsl { clinically_relevant_change 5 }.clinically_relevant_change).to eq 5.0
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'makes a line chart' do
|
58
|
-
expect(dsl { }).to be_an_instance_of(::Quby::Questionnaires::Entities::Charting::LineChart)
|
59
|
-
end
|
60
|
-
|
61
|
-
def dsl(key = :test, options = {y_range: (0..20)}, &block)
|
62
|
-
builder = LineChartBuilder.new(questionnaire, key, options)
|
63
|
-
builder.build(&block)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|