quby 4.0.4 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. checksums.yaml +4 -4
  2. data/README.markdown +0 -1
  3. data/lib/quby.rb +2 -10
  4. data/lib/quby/answers/entities/answer.rb +4 -2
  5. data/lib/quby/answers/services/score_calculator.rb +1 -3
  6. data/lib/quby/engine.rb +0 -1
  7. data/lib/quby/questionnaires.rb +1 -0
  8. data/lib/quby/questionnaires/api.rb +5 -1
  9. data/lib/quby/questionnaires/deserializer.rb +441 -0
  10. data/lib/quby/questionnaires/dsl.rb +12 -15
  11. data/lib/quby/questionnaires/entities.rb +1 -0
  12. data/lib/quby/questionnaires/entities/charting/line_chart.rb +23 -0
  13. data/lib/quby/questionnaires/entities/charting/overview_chart.rb +3 -1
  14. data/lib/quby/questionnaires/entities/definition.rb +3 -5
  15. data/lib/quby/questionnaires/entities/fields.rb +0 -15
  16. data/lib/quby/questionnaires/entities/question.rb +9 -32
  17. data/lib/quby/questionnaires/entities/questionnaire.rb +4 -15
  18. data/lib/quby/questionnaires/entities/questions/checkbox_question.rb +0 -24
  19. data/lib/quby/questionnaires/entities/questions/date_question.rb +0 -8
  20. data/lib/quby/questionnaires/entities/score_calculation.rb +40 -3
  21. data/lib/quby/questionnaires/repos.rb +1 -0
  22. data/lib/quby/questionnaires/repos/bundle_disk_repo.rb +51 -0
  23. data/lib/quby/table_backend/range_tree.rb +0 -51
  24. data/lib/quby/version.rb +1 -1
  25. data/spec/features/tables_spec.rb +40 -0
  26. data/spec/fixtures/score_test.rb +4 -0
  27. data/spec/internal/log/test-events.log +183 -0
  28. data/spec/internal/log/test.log +5522 -0
  29. data/spec/internal/tmp/cache/assets/sprockets/v3.0/00/00nglkSepN01iGiDa7URmJtWQP-xSWffZb9wJgBqUr4.cache +2 -0
  30. data/spec/internal/tmp/cache/assets/sprockets/v3.0/1V/1VQnRlqKBL0MybpMmC3EVtA2s6-ZX-GSGs2Cza3g3kI.cache +1 -0
  31. data/spec/internal/tmp/cache/assets/sprockets/v3.0/1_/1_J_3havMjJDCz3iAQXAXXBh6tBQRJ3OpdWm3W46ss8.cache +1 -0
  32. data/spec/internal/tmp/cache/assets/sprockets/v3.0/4G/4gcYvPHmPX3fZw9xr6plMl5Hfbo2xTWwcD7T7lIlD4Y.cache +2 -0
  33. data/spec/internal/tmp/cache/assets/sprockets/v3.0/4_/4_FK6PMcF1eyIQx7RtVQ5t8c6X7smPQmJWNN5YTImVc.cache +1 -0
  34. data/spec/internal/tmp/cache/assets/sprockets/v3.0/4d/4Dd15Upcg8_kiEsx_5wpQNrjM1sCk0tGTtWGhtmCKpg.cache +1 -0
  35. data/spec/internal/tmp/cache/assets/sprockets/v3.0/4h/4hd8RzwlWb2IEeLLZN0s-3_sdJXtw6nu2k5baLb9vNs.cache +0 -0
  36. data/spec/internal/tmp/cache/assets/sprockets/v3.0/5X/5xFJleOz2sGyE9gbs8KPkToDiv3s9bwFzroBRcjPELY.cache +0 -0
  37. data/spec/internal/tmp/cache/assets/sprockets/v3.0/6Y/6y1tV_fKJP9YIQn-dF847aZ9kza1O7iyTEUht42D7nc.cache +0 -0
  38. data/spec/internal/tmp/cache/assets/sprockets/v3.0/6d/6dfYZY_DkQe892FZVDUbBbrINslzVUkLZePdnVxO3Ps.cache +1 -0
  39. data/spec/internal/tmp/cache/assets/sprockets/v3.0/6w/6WcYsWQCgw0z_URAWGhOsbiKXcqVxZ--ImazY5S-2Gk.cache +2 -0
  40. data/spec/internal/tmp/cache/assets/sprockets/v3.0/77/77EJjFGVCRzLbhJy6KZZUYe5w0LxsqZQcmFcHAbxKeQ.cache +1 -0
  41. data/spec/internal/tmp/cache/assets/sprockets/v3.0/7f/7fvhJnfiJknq6sA-MPtumXlL5qB-rfH__Heye13NyHc.cache +1 -0
  42. data/spec/internal/tmp/cache/assets/sprockets/v3.0/8W/8W6AwDwFqo6egmWyt6Cs0vf_XJbT2YxPs2sqbo0Q9kk.cache +2 -0
  43. data/spec/internal/tmp/cache/assets/sprockets/v3.0/8c/8cQ8uBhUhrouKwor0Z87dDCxyPbqbLvK8KEFEgjHxqM.cache +0 -0
  44. data/spec/internal/tmp/cache/assets/sprockets/v3.0/9L/9LJo1U9wQdfWrrn3HkNZTgIZc6jeHvWbGk8tJ4m_Qec.cache +1 -0
  45. data/spec/internal/tmp/cache/assets/sprockets/v3.0/9o/9oXJXZnA6F49i4EflydD0Ivx6dhSxGGDD69G-N5NSCg.cache +0 -0
  46. data/spec/internal/tmp/cache/assets/sprockets/v3.0/A1/a1jgtYtDHIb04Og07H6_XNmhXppaAnFiO88kgq80edQ.cache +1 -0
  47. data/spec/internal/tmp/cache/assets/sprockets/v3.0/AC/ACV6t4unw39Kpn2DnbBtHeJYLoAHyyBN1DTRXs6a2ik.cache +1 -0
  48. data/spec/internal/tmp/cache/assets/sprockets/v3.0/BO/BoVO8e1GTTGHfnJTOByDxMlvVi9fNGyOdSubqCbBITI.cache +2 -0
  49. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ba/babjk3aW-jBoEw_ERhmT5ZQprEqilJCWmImrvVskWk8.cache +0 -0
  50. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Cg/cgb1vvOogMD0V1lqQ5k_mny7Z38rbqBdIumlGh5sZ_E.cache +0 -0
  51. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Cw/CwjNk_RYiC93RW8vRs7fWsHcwKTg7uE9OLifRm3Y6WA.cache +2 -0
  52. data/spec/internal/tmp/cache/assets/sprockets/v3.0/DY/Dy1qsY0W-eyFR6RVKSCCli-XsitpaXD4DwTjXL86t2M.cache +1 -0
  53. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Dk/DkGOwkJNeDdljv4b8QbwtPVrsghwYuA6EOxx1goEQg0.cache +1 -0
  54. data/spec/internal/tmp/cache/assets/sprockets/v3.0/FG/fGmVSU-v7aZV9-CLG5U2OmteGgWTuAotlFcwFyx4Eqs.cache +1 -0
  55. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Fd/fDidWZjSZsPN4uAEyVYABV2WFCSR7AZE0l8U-9XOw7U.cache +0 -0
  56. data/spec/internal/tmp/cache/assets/sprockets/v3.0/G1/G1RRwpldS5MGQ5x-WHyPWzXJWDOd2qyWMMFumuU4-Ms.cache +1 -0
  57. data/spec/internal/tmp/cache/assets/sprockets/v3.0/GG/ggGfy_gZryUPmYwgenN3A4jv0q-buxyjCGdLB6wfHxQ.cache +1 -0
  58. data/spec/internal/tmp/cache/assets/sprockets/v3.0/GY/gYwYoJrifknCG-a0FXlM1NU6tUj1JXxm27s-a0uP_IE.cache +1 -0
  59. data/spec/internal/tmp/cache/assets/sprockets/v3.0/I6/i64Ysik0cyoTrYF0-O63B7sN3AdIgeoJ7zLh9pMC2u4.cache +0 -0
  60. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ic/ICKeOd4yOff3JGsfU1XliLgXfJtTPKSbXsqNVZAb1-Y.cache +1 -0
  61. data/spec/internal/tmp/cache/assets/sprockets/v3.0/J7/J75M1l--IMcCn-Wy7uWv17SWaj0DFaGiiwac63pENPQ.cache +1 -0
  62. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Jh/JHPqsKZsrkvQg23ukphinYoViiIw3askwCMP8VrHTMk.cache +1 -0
  63. data/spec/internal/tmp/cache/assets/sprockets/v3.0/K9/k9tOCRdX5tsxa5LImq7MZk0WzC692t8tx5LzLln0l4Q.cache +0 -0
  64. data/spec/internal/tmp/cache/assets/sprockets/v3.0/LY/ly4TNAIbW9ghgXz8mxfmskR_6AkuiMiG-RIFGhewgQ0.cache +1 -0
  65. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Lq/LQ9fP0wIqVc5s-AtP3ESWJr0qpkDe-VpTxpgYl-9FfU.cache +1 -0
  66. data/spec/internal/tmp/cache/assets/sprockets/v3.0/MO/MOmnpcaRW98Ke-zTOOCSZ0ODnnQntKhQr0vFc_un1_A.cache +1 -0
  67. data/spec/internal/tmp/cache/assets/sprockets/v3.0/OX/OxOBsUA5EpScoZgEt_UhsHzhu-GGmxKnHpCwnhbTwiM.cache +1 -0
  68. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ot/oTVAc3-iuSlg7XAM-YIAhw3cdc5yhgL2-tK3N7sfOfU.cache +0 -0
  69. data/spec/internal/tmp/cache/assets/sprockets/v3.0/PK/pKNcBOgAbCyIwsWIvnlmiPiFxrw6nUo_nTz7wWFDr80.cache +1 -0
  70. data/spec/internal/tmp/cache/assets/sprockets/v3.0/QB/QBMvSW7SYbYcm5lSjybgO7fhHDFIQjJWOvefH0MQC-A.cache +0 -0
  71. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Qs/QSbtm1y8JKPV0MQkpiC0hEisaSjKZ3tp2AWHSrhO30Y.cache +1 -0
  72. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Sp/SpyGDguFy3tp0sim1miZOehEDpE97oueO7wl3oUFYcE.cache +1 -0
  73. data/spec/internal/tmp/cache/assets/sprockets/v3.0/TW/TwtJPRSE9lmwTuSP0lezWSRSBp2u43zuF196FQcHY-c.cache +1 -0
  74. data/spec/internal/tmp/cache/assets/sprockets/v3.0/VX/Vxn9zv60MCKUBfRhrjefo-MEzFej81PPEutxTPQ4VLQ.cache +0 -0
  75. data/spec/internal/tmp/cache/assets/sprockets/v3.0/Vr/vrqPEzlsuORocHY0EbtGdFomRmrcoAa6wWSDMx642-Q.cache +2 -0
  76. data/spec/internal/tmp/cache/assets/sprockets/v3.0/WH/WHVQ0GBe51hbYqv2g7YYo7EIw9PSzt9-RqU7hKP2dc4.cache +1 -0
  77. data/spec/internal/tmp/cache/assets/sprockets/v3.0/_B/_B796ezRHfk7H8YKj7zr3-gRy6Mw2IVn2NbHu-k20ug.cache +1 -0
  78. data/spec/internal/tmp/cache/assets/sprockets/v3.0/_W/_Wh-7b1t-Xm19wg3KPtkXq7DOpohaL5OhnLggzJLpj4.cache +0 -0
  79. data/spec/internal/tmp/cache/assets/sprockets/v3.0/b2/B2y-2qTbQYKRm6_sCQ6qfUeVfl9rKXUvotTDm56w4bs.cache +1 -0
  80. data/spec/internal/tmp/cache/assets/sprockets/v3.0/bw/bwFR2MLpvJvPSAPJzSLWk6TUDCw5TlBFUUuq7z_Y9vg.cache +1 -0
  81. data/spec/internal/tmp/cache/assets/sprockets/v3.0/c7/c7ubvrHhbhAYh-K4srvM9EqwWdbWTLrsLMgjG5XQDbY.cache +1 -0
  82. data/spec/internal/tmp/cache/assets/sprockets/v3.0/cX/CXpMzZYfJy6HIOVXN0IyYilvy6J4CDgFZIwqKm8OQEU.cache +1 -0
  83. data/spec/internal/tmp/cache/assets/sprockets/v3.0/eN/EN0enu5dkKEnIz-DVCpbhkfeph7wImeXnlqb7SXMrjE.cache +1 -0
  84. data/spec/internal/tmp/cache/assets/sprockets/v3.0/fu/fuP9zP6C6rj650HLkypoTfYN2KD1ecB9HdtlbhbA2cg.cache +1 -0
  85. data/spec/internal/tmp/cache/assets/sprockets/v3.0/gr/gRPXI3EsVPwysy9YKW_6yDxaqRRr4Idxtexf7zCHECw.cache +1 -0
  86. data/spec/internal/tmp/cache/assets/sprockets/v3.0/h0/h0P63ZZdlSbtztDOe0V9r7jtCoy0L2bAf_iDNKLJ0nk.cache +1 -0
  87. data/spec/internal/tmp/cache/assets/sprockets/v3.0/i-/i-Or0Xuxbbm3-HdE_xGIf6sAx2vhUa3eVMpbT37lyEo.cache +1 -0
  88. data/spec/internal/tmp/cache/assets/sprockets/v3.0/iF/iFP67If98izMEAAMKnAFi2dWAb8TNlHNayZKNjXdAMs.cache +1 -0
  89. data/spec/internal/tmp/cache/assets/sprockets/v3.0/iH/Ih2svq5ul-xibfRUfd1fxigouli6U19Rf80FrTSoMak.cache +1 -0
  90. data/spec/internal/tmp/cache/assets/sprockets/v3.0/ka/Ka_YEbZNQxpS8XAA7xZturgPr2vLYQq60KK1uwou4Lo.cache +1 -0
  91. data/spec/internal/tmp/cache/assets/sprockets/v3.0/kq/KqkIGfAdJjTcr53lFl1aDAMUeqhhKdXGyTlHVlCz0R4.cache +1 -0
  92. data/spec/internal/tmp/cache/assets/sprockets/v3.0/mR/mRDPkwomGSfjpIWEKtPPBSx5cBHssvH8v0gCSI33P3Y.cache +1 -0
  93. data/spec/internal/tmp/cache/assets/sprockets/v3.0/n4/n4qaNjjNvKB0VAbVJlP_BjFlcLf70TsBzcIMc7VO9dw.cache +2 -0
  94. data/spec/internal/tmp/cache/assets/sprockets/v3.0/nY/nykt5oy2ExUYa8g1phLCDRqwb55BuUot5ZBbRdNuCCw.cache +2 -0
  95. data/spec/internal/tmp/cache/assets/sprockets/v3.0/nv/nvmgm4bOtxCbD6EA14ZIwDcYO8fxXOoEk_s7V-uRMMM.cache +1 -0
  96. data/spec/internal/tmp/cache/assets/sprockets/v3.0/oG/og5ypFjbFAX_nH7oxK6Bn5Ejh81BMDBSMxbGcL5ZbQs.cache +1 -0
  97. data/spec/internal/tmp/cache/assets/sprockets/v3.0/oO/oO4iBwOm5E7uLH39zeR8zun4eBM-WxZKvEMpIYKx6SU.cache +1 -0
  98. data/spec/internal/tmp/cache/assets/sprockets/v3.0/pN/PnQ-dEclV6jTDE4kkqw4G9dBpHArAgUnATOpRrQAsGc.cache +1 -0
  99. data/spec/internal/tmp/cache/assets/sprockets/v3.0/pe/pet4fFbc2Cm2SD_ZBO_s83Gey29EXE26u-7lwn2O8gM.cache +1 -0
  100. data/spec/internal/tmp/cache/assets/sprockets/v3.0/qo/Qoqb-JjTe1BiY4rICKHm5e6bsPt-DHXZc4ADXESjw2I.cache +1 -0
  101. data/spec/internal/tmp/cache/assets/sprockets/v3.0/qx/QXICLj9xx1EI9rBeXLXpKOeHGll_LBWHRWlpb1DK424.cache +1 -0
  102. data/spec/internal/tmp/cache/assets/sprockets/v3.0/rM/rMF4Y2UGkmBABLlC1eSSqb6y6g_Z3uUCLBtFvz_LoyI.cache +1 -0
  103. data/spec/internal/tmp/cache/assets/sprockets/v3.0/ty/ty1qAnpL07anYdhIJoiPYLcsWKejuzy6JaxU9mI7egw.cache +1 -0
  104. data/spec/internal/tmp/cache/assets/sprockets/v3.0/uH/UHs9nE45XS7v4QlMjSjhwHbqYIKC06FsEjMSMIfKanU.cache +1 -0
  105. data/spec/internal/tmp/cache/assets/sprockets/v3.0/v8/v8VXJ3AQom-JqxBYAB7tOjV-tt4IdDb6YyFEzlsWV8c.cache +1 -0
  106. data/spec/internal/tmp/cache/assets/sprockets/v3.0/vD/VDI2CxkTg7-DuMcLmofLvch0yukSl88oI_AjGgN-hQ8.cache +1 -0
  107. data/spec/internal/tmp/cache/assets/sprockets/v3.0/wq/wqhk46aZc1Bbb8gTCOZKxTvwTV0ANLSz8VdQYACo03E.cache +1 -0
  108. data/spec/internal/tmp/cache/assets/sprockets/v3.0/xy/Xy8Yk--iYZNupHMjUtYX1AQ0BppsvThCh_ZAizblCb0.cache +1 -0
  109. data/spec/internal/tmp/cache/assets/sprockets/v3.0/zu/zUCfHRTHprn06F5WxH6wp_BLs9-yhs-foc0j0Y7BYbg.cache +1 -0
  110. data/spec/internal/tmp/cache/assets/sprockets/v3.0/zx/ZX2IY3eKQjBy93tlH7_Xg7zGZKYuaQ-E8YPvtPT_4vM.cache +1 -0
  111. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-35.705.html +1 -0
  112. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-35.705.png +0 -0
  113. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.005.html +1 -0
  114. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.005.png +0 -0
  115. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.276.html +1 -0
  116. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.276.png +0 -0
  117. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.556.html +1 -0
  118. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.556.png +0 -0
  119. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.818.html +1 -0
  120. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.818.png +0 -0
  121. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.083.html +1 -0
  122. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.083.png +0 -0
  123. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.350.html +1 -0
  124. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.350.png +0 -0
  125. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.620.html +1 -0
  126. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.620.png +0 -0
  127. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.885.html +1 -0
  128. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.885.png +0 -0
  129. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-38.152.html +1 -0
  130. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-38.152.png +0 -0
  131. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-28-14.063.html +207 -0
  132. data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-28-14.063.png +0 -0
  133. data/spec/quby/answers/entities/score_spec.rb +4 -0
  134. data/spec/quby/answers/services/answer_validations_spec.rb +8 -8
  135. data/spec/quby/answers/services/score_calculator_spec.rb +4 -14
  136. data/spec/quby/questionnaires/deserializer/questionnaire_spec.rb +237 -0
  137. data/spec/quby/questionnaires/dsl_spec.rb +0 -9
  138. data/spec/quby/questionnaires/entities/fields_spec.rb +3 -3
  139. data/spec/quby/questionnaires/entities/question_spec.rb +0 -8
  140. data/spec/quby/questionnaires/entities/questionnaire_spec.rb +2 -26
  141. data/spec/quby/table_backend/range_tree_spec.rb +46 -13
  142. data/spec/spec_helper.rb +1 -1
  143. metadata +230 -53
  144. data/lib/quby/lookup_table.rb +0 -29
  145. data/lib/quby/lookup_table_repo.rb +0 -24
  146. data/lib/quby/questionnaires/dsl/base.rb +0 -20
  147. data/lib/quby/questionnaires/dsl/calls_custom_methods.rb +0 -29
  148. data/lib/quby/questionnaires/dsl/charting/bar_chart_builder.rb +0 -18
  149. data/lib/quby/questionnaires/dsl/charting/chart_builder.rb +0 -91
  150. data/lib/quby/questionnaires/dsl/charting/line_chart_builder.rb +0 -57
  151. data/lib/quby/questionnaires/dsl/charting/overview_chart_builder.rb +0 -31
  152. data/lib/quby/questionnaires/dsl/charting/radar_chart_builder.rb +0 -18
  153. data/lib/quby/questionnaires/dsl/helpers.rb +0 -51
  154. data/lib/quby/questionnaires/dsl/panel_builder.rb +0 -80
  155. data/lib/quby/questionnaires/dsl/question_builder.rb +0 -40
  156. data/lib/quby/questionnaires/dsl/questionnaire_builder.rb +0 -260
  157. data/lib/quby/questionnaires/dsl/questions/base.rb +0 -179
  158. data/lib/quby/questionnaires/dsl/questions/checkbox_question_builder.rb +0 -20
  159. data/lib/quby/questionnaires/dsl/questions/date_question_builder.rb +0 -18
  160. data/lib/quby/questionnaires/dsl/questions/deprecated_question_builder.rb +0 -18
  161. data/lib/quby/questionnaires/dsl/questions/float_question_builder.rb +0 -21
  162. data/lib/quby/questionnaires/dsl/questions/integer_question_builder.rb +0 -21
  163. data/lib/quby/questionnaires/dsl/questions/radio_question_builder.rb +0 -20
  164. data/lib/quby/questionnaires/dsl/questions/select_question_builder.rb +0 -18
  165. data/lib/quby/questionnaires/dsl/questions/string_question_builder.rb +0 -20
  166. data/lib/quby/questionnaires/dsl/questions/text_question_builder.rb +0 -22
  167. data/lib/quby/questionnaires/dsl/score_builder.rb +0 -22
  168. data/lib/quby/questionnaires/dsl/standardized_panel_generators.rb +0 -33
  169. data/lib/quby/questionnaires/dsl/table_builder.rb +0 -48
  170. data/lib/quby/questionnaires/services/definition_validator.rb +0 -298
  171. data/spec/benchmarks/load_normscore_csv.rb +0 -18
  172. data/spec/quby/lookup_table_repo_spec.rb +0 -20
  173. data/spec/quby/lookup_table_spec.rb +0 -38
  174. data/spec/quby/questionnaires/dsl/calls_custom_methods_spec.rb +0 -38
  175. data/spec/quby/questionnaires/dsl/charting/bar_chart_builder_spec.rb +0 -41
  176. data/spec/quby/questionnaires/dsl/charting/chart_builder_spec.rb +0 -127
  177. data/spec/quby/questionnaires/dsl/charting/line_chart_builder_spec.rb +0 -66
  178. data/spec/quby/questionnaires/dsl/charting/radar_chart_builder_spec.rb +0 -41
  179. data/spec/quby/questionnaires/dsl/helpers_spec.rb +0 -80
  180. data/spec/quby/questionnaires/dsl/questionnaire_builder_spec.rb +0 -480
  181. data/spec/quby/questionnaires/services/definition_validator_spec.rb +0 -793
  182. data/spec/support/examples_for_chart_builders.rb +0 -59
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- feature 'Load normscore csv file', benchmark: true do
6
- it 'loads a csv file' do
7
- 10.times do
8
- Quby.lookup_table_repo.retrieve('test')
9
- end
10
- end
11
-
12
- it 'builds a tree' do
13
- data = Quby.lookup_table_repo.retrieve('test')
14
- 10.times do
15
- Quby::TableBackend::RangeTree.new(data).send :tree
16
- end
17
- end
18
- end
@@ -1,20 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Quby::LookupTableRepo::Disk do
4
- subject { Quby.lookup_table_repo }
5
-
6
- it 'Quby.lookup_table_repo is a disk repo by default' do
7
- expect(subject).to be_an_instance_of(described_class)
8
- end
9
-
10
- describe '#retrieve' do
11
- it 'reads the csv file' do
12
- expect(CSV).to receive(:read).and_call_original
13
- subject.retrieve 'test'
14
- end
15
-
16
- it 'fails when csv file is not found' do
17
- expect { subject.retrieve 'not_there' }.to raise_error(Errno::ENOENT)
18
- end
19
- end
20
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Quby
6
- describe LookupTable do
7
- let(:table) { described_class.new('test') }
8
- let(:fake_backing) { double(:"present?" => true).as_null_object }
9
-
10
- describe '#lookup' do
11
- it 'passes lookup calls on to the backing' do
12
- expect(Quby::TableBackend::RangeTree).to receive(:from_csv).and_return(fake_backing)
13
- parameters = {a: 1}
14
- expect(table.backing).to receive(:lookup).with(parameters)
15
- table.lookup(parameters)
16
- end
17
-
18
- it 'initializes the disktree lazily' do
19
- headers = double
20
- compare = double
21
- data = double
22
- data_double = [headers, compare, data]
23
- table
24
- expect_any_instance_of(described_class).to receive(:data).and_return(data_double)
25
- expect(Quby::TableBackend::RangeTree).to receive(:from_csv).with(levels: headers, compare: compare, data:[data]).and_return(fake_backing)
26
- table.lookup(some: :thing)
27
- end
28
- end
29
-
30
- describe '#data' do
31
- it 'calls Quby.lookup_table_repo.retrieve(table.key)' do
32
- table
33
- expect(Quby.lookup_table_repo).to receive(:retrieve).with(table.key)
34
- table.data
35
- end
36
- end
37
- end
38
- end
@@ -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
@@ -1,41 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Quby::Questionnaires::DSL
6
- describe RadarChartBuilder do
7
- it_behaves_like ChartBuilder
8
-
9
- let(:questionnaire) { double(key: 'questionnaire_key') }
10
-
11
- it 'makes a radar chart' do
12
- expect(dsl { }).to be_an_instance_of(::Quby::Questionnaires::Entities::Charting::RadarChart)
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 'sets plotlines' do
24
- plotlines =
25
- dsl {
26
- plotline 40, :orange
27
- plotline 60, :red
28
- }.plotlines
29
-
30
- expect(plotlines).to eq [
31
- {value: 40, color: :orange, width: 1, zIndex: 3},
32
- {value: 60, color: :red, width: 1, zIndex: 3}
33
- ]
34
- end
35
-
36
- def dsl(key = :test, options = {}, &block)
37
- builder = RadarChartBuilder.new(questionnaire, key, options)
38
- builder.build(&block)
39
- end
40
- end
41
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- module Quby::Questionnaires::DSL
6
- describe Helpers do
7
- let(:questionnaire) { Quby::Questionnaires::Entities::Questionnaire.new("example") }
8
- let(:builder) { QuestionnaireBuilder.new(questionnaire) }
9
-
10
- # this helper has some extra tests to check that helpers are included everywhere
11
- describe '.image_tag' do
12
- let(:expected_html) { %r{<p><img alt=\"Happy face\" src=\"/assets/quby/happy-face.*.png\" /></p>} }
13
-
14
- it 'builds image tags outside of panels' do
15
- dsl { text image_tag('quby/happy-face.png') }
16
- expect(questionnaire.panels.first.items.first.text).to match(expected_html)
17
- end
18
-
19
- it 'builds image tags inside of panels' do
20
- dsl do
21
- panel do
22
- text image_tag('quby/happy-face.png')
23
- end
24
- end
25
-
26
- expect(questionnaire.panels.first.items.first.text).to match(expected_html)
27
- end
28
-
29
- it 'builds image tags inside of questions' do
30
- # this one is different because markdown/maruku transforms double quotes into single quotes
31
- # and question descriptions are not passed through markdown/maruku
32
- expected_html = %r{<img .*?src="/assets/quby/happy-face.*.png"}
33
- dsl do
34
- panel do
35
- question :v_1, type: :radio do
36
- option :a1, description: image_tag('quby/happy-face.png')
37
- end
38
- end
39
- end
40
- expect(questionnaire.panels.first.items.first.options.first.description).to match(expected_html)
41
- end
42
- end
43
-
44
- describe 'video_tag' do
45
- it 'makes a text item with a html 5 video player for the given video source urls' do
46
- html = builder.video_tag 'https://www.example.com/video.mp4', 'https://www.example.com/video.webm'
47
-
48
- expect(html).to \
49
- eq("<video width=\"100%\" preload=\"none\" controls=\"controls\"><source src=\"https://www.example.com/video.mp4\" type=\"video/mp4\">\
50
- <source src=\"https://www.example.com/video.webm\" type=\"video/webm\">\
51
- Helaas kan je browser dit filmpje niet afspelen. Probeer een andere browser te gebruiken.</video>")
52
- end
53
-
54
- it 'can add a autoplay attribute (with muted added to allow chrome autoplay)' do
55
- html = builder.video_tag 'https://www.example.com/video.mp4', autoplay: true
56
-
57
- expect(html).to \
58
- include('<video width="100%" preload="none" autoplay="autoplay" muted="muted" controls="controls">')
59
- end
60
-
61
- it 'can add a loop attribute' do
62
- html = builder.video_tag 'https://www.example.com/video.mp4', loop: true
63
-
64
- expect(html).to \
65
- include('<video width="100%" preload="none" loop="loop" controls="controls">')
66
- end
67
-
68
- it 'can add a poster url' do
69
- html = builder.video_tag 'https://www.example.com/video.mp4', poster: 'https://www.example.com/poster.jpg'
70
-
71
- expect(html).to \
72
- include('<video width="100%" preload="none" poster="https://www.example.com/poster.jpg" controls="controls">')
73
- end
74
- end
75
-
76
- def dsl(&block)
77
- builder.instance_eval(&block)
78
- end
79
- end
80
- end