quby 4.0.4 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +0 -1
- data/lib/quby.rb +2 -10
- data/lib/quby/answers/entities/answer.rb +4 -2
- data/lib/quby/answers/services/score_calculator.rb +1 -3
- data/lib/quby/engine.rb +0 -1
- data/lib/quby/questionnaires.rb +1 -0
- data/lib/quby/questionnaires/api.rb +5 -1
- data/lib/quby/questionnaires/deserializer.rb +441 -0
- data/lib/quby/questionnaires/dsl.rb +12 -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 +40 -3
- data/lib/quby/questionnaires/repos.rb +1 -0
- data/lib/quby/questionnaires/repos/bundle_disk_repo.rb +51 -0
- data/lib/quby/table_backend/range_tree.rb +0 -51
- data/lib/quby/version.rb +1 -1
- data/spec/features/tables_spec.rb +40 -0
- data/spec/fixtures/score_test.rb +4 -0
- data/spec/internal/log/test-events.log +183 -0
- data/spec/internal/log/test.log +5522 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/00/00nglkSepN01iGiDa7URmJtWQP-xSWffZb9wJgBqUr4.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/1V/1VQnRlqKBL0MybpMmC3EVtA2s6-ZX-GSGs2Cza3g3kI.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/1_/1_J_3havMjJDCz3iAQXAXXBh6tBQRJ3OpdWm3W46ss8.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/4G/4gcYvPHmPX3fZw9xr6plMl5Hfbo2xTWwcD7T7lIlD4Y.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/4_/4_FK6PMcF1eyIQx7RtVQ5t8c6X7smPQmJWNN5YTImVc.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/4d/4Dd15Upcg8_kiEsx_5wpQNrjM1sCk0tGTtWGhtmCKpg.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/4h/4hd8RzwlWb2IEeLLZN0s-3_sdJXtw6nu2k5baLb9vNs.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/5X/5xFJleOz2sGyE9gbs8KPkToDiv3s9bwFzroBRcjPELY.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/6Y/6y1tV_fKJP9YIQn-dF847aZ9kza1O7iyTEUht42D7nc.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/6d/6dfYZY_DkQe892FZVDUbBbrINslzVUkLZePdnVxO3Ps.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/6w/6WcYsWQCgw0z_URAWGhOsbiKXcqVxZ--ImazY5S-2Gk.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/77/77EJjFGVCRzLbhJy6KZZUYe5w0LxsqZQcmFcHAbxKeQ.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/7f/7fvhJnfiJknq6sA-MPtumXlL5qB-rfH__Heye13NyHc.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/8W/8W6AwDwFqo6egmWyt6Cs0vf_XJbT2YxPs2sqbo0Q9kk.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/8c/8cQ8uBhUhrouKwor0Z87dDCxyPbqbLvK8KEFEgjHxqM.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/9L/9LJo1U9wQdfWrrn3HkNZTgIZc6jeHvWbGk8tJ4m_Qec.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/9o/9oXJXZnA6F49i4EflydD0Ivx6dhSxGGDD69G-N5NSCg.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/A1/a1jgtYtDHIb04Og07H6_XNmhXppaAnFiO88kgq80edQ.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/AC/ACV6t4unw39Kpn2DnbBtHeJYLoAHyyBN1DTRXs6a2ik.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/BO/BoVO8e1GTTGHfnJTOByDxMlvVi9fNGyOdSubqCbBITI.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ba/babjk3aW-jBoEw_ERhmT5ZQprEqilJCWmImrvVskWk8.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Cg/cgb1vvOogMD0V1lqQ5k_mny7Z38rbqBdIumlGh5sZ_E.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Cw/CwjNk_RYiC93RW8vRs7fWsHcwKTg7uE9OLifRm3Y6WA.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/DY/Dy1qsY0W-eyFR6RVKSCCli-XsitpaXD4DwTjXL86t2M.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Dk/DkGOwkJNeDdljv4b8QbwtPVrsghwYuA6EOxx1goEQg0.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/FG/fGmVSU-v7aZV9-CLG5U2OmteGgWTuAotlFcwFyx4Eqs.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Fd/fDidWZjSZsPN4uAEyVYABV2WFCSR7AZE0l8U-9XOw7U.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/G1/G1RRwpldS5MGQ5x-WHyPWzXJWDOd2qyWMMFumuU4-Ms.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/GG/ggGfy_gZryUPmYwgenN3A4jv0q-buxyjCGdLB6wfHxQ.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/GY/gYwYoJrifknCG-a0FXlM1NU6tUj1JXxm27s-a0uP_IE.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/I6/i64Ysik0cyoTrYF0-O63B7sN3AdIgeoJ7zLh9pMC2u4.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ic/ICKeOd4yOff3JGsfU1XliLgXfJtTPKSbXsqNVZAb1-Y.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/J7/J75M1l--IMcCn-Wy7uWv17SWaj0DFaGiiwac63pENPQ.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Jh/JHPqsKZsrkvQg23ukphinYoViiIw3askwCMP8VrHTMk.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/K9/k9tOCRdX5tsxa5LImq7MZk0WzC692t8tx5LzLln0l4Q.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/LY/ly4TNAIbW9ghgXz8mxfmskR_6AkuiMiG-RIFGhewgQ0.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Lq/LQ9fP0wIqVc5s-AtP3ESWJr0qpkDe-VpTxpgYl-9FfU.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/MO/MOmnpcaRW98Ke-zTOOCSZ0ODnnQntKhQr0vFc_un1_A.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/OX/OxOBsUA5EpScoZgEt_UhsHzhu-GGmxKnHpCwnhbTwiM.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Ot/oTVAc3-iuSlg7XAM-YIAhw3cdc5yhgL2-tK3N7sfOfU.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/PK/pKNcBOgAbCyIwsWIvnlmiPiFxrw6nUo_nTz7wWFDr80.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/QB/QBMvSW7SYbYcm5lSjybgO7fhHDFIQjJWOvefH0MQC-A.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Qs/QSbtm1y8JKPV0MQkpiC0hEisaSjKZ3tp2AWHSrhO30Y.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Sp/SpyGDguFy3tp0sim1miZOehEDpE97oueO7wl3oUFYcE.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/TW/TwtJPRSE9lmwTuSP0lezWSRSBp2u43zuF196FQcHY-c.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/VX/Vxn9zv60MCKUBfRhrjefo-MEzFej81PPEutxTPQ4VLQ.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/Vr/vrqPEzlsuORocHY0EbtGdFomRmrcoAa6wWSDMx642-Q.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/WH/WHVQ0GBe51hbYqv2g7YYo7EIw9PSzt9-RqU7hKP2dc4.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/_B/_B796ezRHfk7H8YKj7zr3-gRy6Mw2IVn2NbHu-k20ug.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/_W/_Wh-7b1t-Xm19wg3KPtkXq7DOpohaL5OhnLggzJLpj4.cache +0 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/b2/B2y-2qTbQYKRm6_sCQ6qfUeVfl9rKXUvotTDm56w4bs.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/bw/bwFR2MLpvJvPSAPJzSLWk6TUDCw5TlBFUUuq7z_Y9vg.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/c7/c7ubvrHhbhAYh-K4srvM9EqwWdbWTLrsLMgjG5XQDbY.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/cX/CXpMzZYfJy6HIOVXN0IyYilvy6J4CDgFZIwqKm8OQEU.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/eN/EN0enu5dkKEnIz-DVCpbhkfeph7wImeXnlqb7SXMrjE.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/fu/fuP9zP6C6rj650HLkypoTfYN2KD1ecB9HdtlbhbA2cg.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/gr/gRPXI3EsVPwysy9YKW_6yDxaqRRr4Idxtexf7zCHECw.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/h0/h0P63ZZdlSbtztDOe0V9r7jtCoy0L2bAf_iDNKLJ0nk.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/i-/i-Or0Xuxbbm3-HdE_xGIf6sAx2vhUa3eVMpbT37lyEo.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/iF/iFP67If98izMEAAMKnAFi2dWAb8TNlHNayZKNjXdAMs.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/iH/Ih2svq5ul-xibfRUfd1fxigouli6U19Rf80FrTSoMak.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/ka/Ka_YEbZNQxpS8XAA7xZturgPr2vLYQq60KK1uwou4Lo.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/kq/KqkIGfAdJjTcr53lFl1aDAMUeqhhKdXGyTlHVlCz0R4.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/mR/mRDPkwomGSfjpIWEKtPPBSx5cBHssvH8v0gCSI33P3Y.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/n4/n4qaNjjNvKB0VAbVJlP_BjFlcLf70TsBzcIMc7VO9dw.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/nY/nykt5oy2ExUYa8g1phLCDRqwb55BuUot5ZBbRdNuCCw.cache +2 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/nv/nvmgm4bOtxCbD6EA14ZIwDcYO8fxXOoEk_s7V-uRMMM.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/oG/og5ypFjbFAX_nH7oxK6Bn5Ejh81BMDBSMxbGcL5ZbQs.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/oO/oO4iBwOm5E7uLH39zeR8zun4eBM-WxZKvEMpIYKx6SU.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/pN/PnQ-dEclV6jTDE4kkqw4G9dBpHArAgUnATOpRrQAsGc.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/pe/pet4fFbc2Cm2SD_ZBO_s83Gey29EXE26u-7lwn2O8gM.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/qo/Qoqb-JjTe1BiY4rICKHm5e6bsPt-DHXZc4ADXESjw2I.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/qx/QXICLj9xx1EI9rBeXLXpKOeHGll_LBWHRWlpb1DK424.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/rM/rMF4Y2UGkmBABLlC1eSSqb6y6g_Z3uUCLBtFvz_LoyI.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/ty/ty1qAnpL07anYdhIJoiPYLcsWKejuzy6JaxU9mI7egw.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/uH/UHs9nE45XS7v4QlMjSjhwHbqYIKC06FsEjMSMIfKanU.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/v8/v8VXJ3AQom-JqxBYAB7tOjV-tt4IdDb6YyFEzlsWV8c.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/vD/VDI2CxkTg7-DuMcLmofLvch0yukSl88oI_AjGgN-hQ8.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/wq/wqhk46aZc1Bbb8gTCOZKxTvwTV0ANLSz8VdQYACo03E.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/xy/Xy8Yk--iYZNupHMjUtYX1AQ0BppsvThCh_ZAizblCb0.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/zu/zUCfHRTHprn06F5WxH6wp_BLs9-yhs-foc0j0Y7BYbg.cache +1 -0
- data/spec/internal/tmp/cache/assets/sprockets/v3.0/zx/ZX2IY3eKQjBy93tlH7_Xg7zGZKYuaQ-E8YPvtPT_4vM.cache +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-35.705.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-35.705.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.005.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.005.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.276.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.276.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.556.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.556.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.818.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-36.818.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.083.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.083.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.350.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.350.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.620.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.620.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.885.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-37.885.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-38.152.html +1 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-27-38.152.png +0 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-28-14.063.html +207 -0
- data/spec/internal/tmp/capybara/screenshot_2020-11-17-14-28-14.063.png +0 -0
- data/spec/quby/answers/entities/score_spec.rb +4 -0
- data/spec/quby/answers/services/answer_validations_spec.rb +8 -8
- data/spec/quby/answers/services/score_calculator_spec.rb +4 -14
- 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 +46 -13
- data/spec/spec_helper.rb +1 -1
- metadata +230 -53
- data/lib/quby/lookup_table.rb +0 -29
- data/lib/quby/lookup_table_repo.rb +0 -24
- 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/benchmarks/load_normscore_csv.rb +0 -18
- data/spec/quby/lookup_table_repo_spec.rb +0 -20
- data/spec/quby/lookup_table_spec.rb +0 -38
- 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
@@ -1,480 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
|
5
|
-
module Quby::Questionnaires::DSL
|
6
|
-
describe QuestionnaireBuilder do
|
7
|
-
let(:questionnaire) { Quby::Questionnaires::Entities::Questionnaire.new("example") }
|
8
|
-
let(:builder) { QuestionnaireBuilder.new(questionnaire) }
|
9
|
-
|
10
|
-
it 'sets title' do
|
11
|
-
dsl { title 'Foo' }
|
12
|
-
expect(questionnaire.title).to eq('Foo')
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'sets description' do
|
16
|
-
dsl { description 'This is a questionnaire description' }
|
17
|
-
expect(questionnaire.description).to eq('This is a questionnaire description')
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'sets outcome_description' do
|
21
|
-
dsl { outcome_description 'Outcome description' }
|
22
|
-
expect(questionnaire.outcome_description).to eq('Outcome description')
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'can disable checking key clashes' do
|
26
|
-
expect(questionnaire.check_key_clashes).to eq(true)
|
27
|
-
dsl { do_not_check_key_clashes }
|
28
|
-
expect(questionnaire.check_key_clashes).to eq(false)
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'set sbg_key' do
|
32
|
-
dsl { sbg_key 'foo' }
|
33
|
-
expect(questionnaire.sbg_key).to eq('foo')
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'can request outcome regeneration' do
|
37
|
-
timestamp = Time.local(2020, 5, 12, 4, 28, 19)
|
38
|
-
dsl { outcome_regeneration_requested_at timestamp }
|
39
|
-
expect(questionnaire.outcome_regeneration_requested_at).to eq(timestamp)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'can request answers to be deactivated' do
|
43
|
-
timestamp = Time.local(2020, 5, 12, 4, 28, 19)
|
44
|
-
dsl { deactivate_answers_requested_at timestamp }
|
45
|
-
expect(questionnaire.deactivate_answers_requested_at).to eq(timestamp)
|
46
|
-
end
|
47
|
-
|
48
|
-
describe 'roqua keys' do
|
49
|
-
it 'defaults to key' do
|
50
|
-
dsl {}
|
51
|
-
expect(questionnaire.roqua_keys).to eq(["example"])
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'sets roqua keys' do
|
55
|
-
dsl { roqua_keys :alg_o, :alg_o2 }
|
56
|
-
expect(questionnaire.roqua_keys).to eq([:alg_o, :alg_o2])
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe 'sbg_domain' do
|
61
|
-
it 'sets sbg_domain' do
|
62
|
-
dsl do
|
63
|
-
sbg_domain '02', from: '2000-01-01', till: '2099-12-31', outcome: '01', sbg_key: 'OQ45-sd', primary: true
|
64
|
-
end
|
65
|
-
expect(questionnaire.sbg_domains).to eq(
|
66
|
-
[
|
67
|
-
{sbg_code: '02', from: '2000-01-01', till: '2099-12-31', outcome: '01', sbg_key: 'OQ45-sd', primary: true}
|
68
|
-
]
|
69
|
-
)
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'sets multiple sbg_domains with optional attributes' do
|
73
|
-
dsl do
|
74
|
-
sbg_domain '02', outcome: '01', sbg_key: 'OQ45-sd', primary: false
|
75
|
-
sbg_domain '03', outcome: '02', from: '2000-01-01', till: '2099-12-31'
|
76
|
-
end
|
77
|
-
expect(questionnaire.sbg_domains).to eq(
|
78
|
-
[
|
79
|
-
{sbg_code: '02', from: nil, till: nil, outcome: '01', sbg_key: 'OQ45-sd', primary: false},
|
80
|
-
{sbg_code: '03', from: '2000-01-01', till: '2099-12-31', outcome: '02', sbg_key: nil, primary: false}
|
81
|
-
]
|
82
|
-
)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'defaults the sbg_key to the sbg_key of the questionnaire' do
|
86
|
-
dsl do
|
87
|
-
sbg_key 'example'
|
88
|
-
sbg_domain '03', from: '2000-01-01', till: '2099-12-31', outcome: '01'
|
89
|
-
end
|
90
|
-
expect(questionnaire.sbg_domains).to eq(
|
91
|
-
[
|
92
|
-
{sbg_code: '03', from: '2000-01-01', till: '2099-12-31', outcome: '01', sbg_key: 'example', primary: false}
|
93
|
-
]
|
94
|
-
)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'does not accept invalid sbg_domains options' do
|
99
|
-
expect { dsl { sbg_domain '02', foo: 'bar' } }.to raise_exception(ArgumentError, "missing keyword: outcome")
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'can be abortable' do
|
103
|
-
expect(questionnaire.abortable).to be_falsey
|
104
|
-
dsl { abortable }
|
105
|
-
expect(questionnaire.abortable).to be_truthy
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'can allow hotkeys' do
|
109
|
-
dsl { allow_hotkeys }
|
110
|
-
expect(questionnaire.allow_hotkeys).to eq("all")
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'can set license' do
|
114
|
-
dsl { license :free }
|
115
|
-
expect(questionnaire.license).to eq(:free)
|
116
|
-
expect(questionnaire.licensor).to be_nil
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'can set licensor' do
|
120
|
-
dsl { license :free, licensor: 'FOO' }
|
121
|
-
expect(questionnaire.licensor).to eq('FOO')
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'can set language' do
|
125
|
-
dsl { language :en }
|
126
|
-
expect(questionnaire.language).to eq(:en)
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'defaults to Dutch language' do
|
130
|
-
dsl { }
|
131
|
-
expect(questionnaire.language).to eq(:nl)
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'can set respondent_types' do
|
135
|
-
dsl { respondent_types :patient, :parent }
|
136
|
-
expect(questionnaire.respondent_types).to eq([:patient, :parent])
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'can set tags' do
|
140
|
-
dsl { tags :diary }
|
141
|
-
expect(questionnaire.tags.diary).to be_truthy
|
142
|
-
expect(questionnaire.tags.another_tag).to be_falsey
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'builds panels' do
|
146
|
-
dsl { panel { title 'My Title' } }
|
147
|
-
expect(questionnaire.panels.first.title).to eq('My Title')
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'builds line charts' do
|
151
|
-
dsl { line_chart(:tot) { title 'My Title'; range 0..40 } }
|
152
|
-
expect(questionnaire.charts.find(:tot).title).to eq('My Title')
|
153
|
-
end
|
154
|
-
|
155
|
-
it 'builds bar charts' do
|
156
|
-
dsl { bar_chart(:tot) { title 'My Title' } }
|
157
|
-
expect(questionnaire.charts.find(:tot).title).to eq('My Title')
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'builds radar charts' do
|
161
|
-
dsl { radar_chart(:tot) { title 'My Title' } }
|
162
|
-
expect(questionnaire.charts.find(:tot).title).to eq('My Title')
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'checks for duplicate question keys' do
|
166
|
-
expect do
|
167
|
-
dsl do
|
168
|
-
question :v_1, type: :string
|
169
|
-
question :v_1, type: :string
|
170
|
-
end
|
171
|
-
end.to raise_exception(RuntimeError, "example:v_1: A question or option with input key v_1 is already defined.")
|
172
|
-
end
|
173
|
-
|
174
|
-
it 'checks for subquestion clashing with parent question' do
|
175
|
-
skip
|
176
|
-
expect do
|
177
|
-
dsl do
|
178
|
-
question :v_1, type: :radio do
|
179
|
-
option :a1 do
|
180
|
-
question :v_1, type: :string
|
181
|
-
end
|
182
|
-
end
|
183
|
-
end
|
184
|
-
end.to raise_exception
|
185
|
-
end
|
186
|
-
|
187
|
-
it 'checks for duplicate option keys' do
|
188
|
-
expect do
|
189
|
-
dsl do
|
190
|
-
question :v_1, type: :radio do
|
191
|
-
option :a1
|
192
|
-
option :a1
|
193
|
-
end
|
194
|
-
end
|
195
|
-
end.to raise_exception(RuntimeError, "example:v_1:a1: A question or option with input key v_1_a1 is already defined.")
|
196
|
-
end
|
197
|
-
|
198
|
-
it 'checks for duplicate option input keys' do
|
199
|
-
expect do
|
200
|
-
dsl do
|
201
|
-
question :v_1_a, type: :radio do
|
202
|
-
option :a1
|
203
|
-
end
|
204
|
-
|
205
|
-
question :v_1, type: :radio do
|
206
|
-
option :a_a1
|
207
|
-
end
|
208
|
-
end
|
209
|
-
end.to raise_exception(RuntimeError, "example:v_1:a_a1: A question or option with input key v_1_a_a1 is already defined.")
|
210
|
-
end
|
211
|
-
|
212
|
-
it 'checks for duplicates in past date input keys' do
|
213
|
-
expect do
|
214
|
-
dsl do
|
215
|
-
question :v_1_a, type: :date do
|
216
|
-
option :a1
|
217
|
-
end
|
218
|
-
|
219
|
-
question :v_1_yyyy, type: :text
|
220
|
-
end
|
221
|
-
end.to raise_exception(NoMethodError, /undefined method `option'/)
|
222
|
-
end
|
223
|
-
|
224
|
-
it 'checks for duplicates when creating date input keys' do
|
225
|
-
expect do
|
226
|
-
dsl do
|
227
|
-
question :v_1_yyyy, type: :text
|
228
|
-
|
229
|
-
question :v_1_a, type: :date do
|
230
|
-
option :a1
|
231
|
-
end
|
232
|
-
end
|
233
|
-
end.to raise_exception(KeyError, "key not found: \"text\"")
|
234
|
-
end
|
235
|
-
|
236
|
-
it 'checks for checkbox option keys clashing with question keys' do
|
237
|
-
expect do
|
238
|
-
dsl do
|
239
|
-
question :v_1, type: :string
|
240
|
-
question :v_2, type: :check_box do
|
241
|
-
option :v_1
|
242
|
-
end
|
243
|
-
end
|
244
|
-
end.to raise_exception(RuntimeError, "example:v_2:v_1: A question or option with input key v_1 is already defined.")
|
245
|
-
end
|
246
|
-
|
247
|
-
it 'checks for checkbox option keys clashing with their own question key' do
|
248
|
-
expect do
|
249
|
-
dsl do
|
250
|
-
question :v_1, type: :check_box do
|
251
|
-
option :v_2
|
252
|
-
option :v_1
|
253
|
-
end
|
254
|
-
end
|
255
|
-
end.to raise_exception(RuntimeError, "example:v_1:v_1: A question or option with input key v_1 is already defined.")
|
256
|
-
end
|
257
|
-
|
258
|
-
it 'checks for checkbox option keys clashing with input keys' do
|
259
|
-
expect do
|
260
|
-
dsl do
|
261
|
-
question :v_1, type: :radio do
|
262
|
-
option :a1
|
263
|
-
end
|
264
|
-
question :v_2, type: :check_box do
|
265
|
-
option :v_1_a1
|
266
|
-
end
|
267
|
-
end
|
268
|
-
end.to raise_exception(RuntimeError, "example:v_2:v_1_a1: A question or option with input key v_1_a1 is already defined.")
|
269
|
-
end
|
270
|
-
|
271
|
-
it 'sets a depends_on key correctly' do
|
272
|
-
dsl do
|
273
|
-
question :v_1, type: :check_box do
|
274
|
-
option :v_1_a
|
275
|
-
end
|
276
|
-
question :v_2, type: :string, depends_on: [:v_1]
|
277
|
-
end
|
278
|
-
questionnaire.callback_after_dsl_enhance_on_questions
|
279
|
-
expect(questionnaire.question_hash[:v_2].depends_on).to eq [:v_1_a]
|
280
|
-
end
|
281
|
-
|
282
|
-
it 'raises when a depends_on key does not exist in the questionnaire' do
|
283
|
-
expect do
|
284
|
-
dsl do
|
285
|
-
question :v_1, type: :string, depends_on: [:unknown]
|
286
|
-
end
|
287
|
-
questionnaire.callback_after_dsl_enhance_on_questions
|
288
|
-
end.to raise_exception(Quby::Questionnaires::Entities::Questionnaire::UnknownInputKey, "Question v_1 depends_on contains an error: Unknown input key unknown")
|
289
|
-
end
|
290
|
-
|
291
|
-
it 'sets the parent option key on subquestions correctly' do
|
292
|
-
dsl do
|
293
|
-
question :v_1, type: :check_box do
|
294
|
-
option :v_1a do
|
295
|
-
question :v_2, type: :string
|
296
|
-
end
|
297
|
-
option :v_1b
|
298
|
-
end
|
299
|
-
end
|
300
|
-
expect(questionnaire.question_hash[:v_2].parent_option_key).to eq(:v_1a)
|
301
|
-
end
|
302
|
-
|
303
|
-
describe 'flag' do
|
304
|
-
before do
|
305
|
-
allow_any_instance_of(Quby::Questionnaires::Entities::Questionnaire).to receive(:add_flag)
|
306
|
-
end
|
307
|
-
|
308
|
-
it 'defines flags' do
|
309
|
-
dsl do
|
310
|
-
flag key: :test, description: 'test flag'
|
311
|
-
end
|
312
|
-
expect(questionnaire).to have_received(:add_flag).with(key: :test, description: 'test flag')
|
313
|
-
end
|
314
|
-
end
|
315
|
-
|
316
|
-
describe '#question' do
|
317
|
-
it 'does not overwrite the @default_question_options' do
|
318
|
-
dsl do
|
319
|
-
default_question_options required: false, type: :checkbox
|
320
|
-
question :v_1, type: :string, required: true
|
321
|
-
end
|
322
|
-
expect(builder.default_question_options[:required]).to eq false
|
323
|
-
end
|
324
|
-
end
|
325
|
-
|
326
|
-
describe '#do_not_check_score_keys_consistency' do
|
327
|
-
it 'sets check_score_keys_consistency flag to false' do
|
328
|
-
dsl do
|
329
|
-
do_not_check_score_keys_consistency
|
330
|
-
end
|
331
|
-
expect(questionnaire.check_score_keys_consistency).to eq false
|
332
|
-
end
|
333
|
-
it 'flag is true on the questionnaire if not altered' do
|
334
|
-
expect(questionnaire.check_score_keys_consistency).to eq true
|
335
|
-
end
|
336
|
-
end
|
337
|
-
|
338
|
-
describe '#custom_method' do
|
339
|
-
context 'valid definition' do
|
340
|
-
before do
|
341
|
-
dsl do
|
342
|
-
custom_method :zzl_question do |question_key, question_title|
|
343
|
-
question question_key, type: :scale do
|
344
|
-
title question_title
|
345
|
-
option :a1, value: 1
|
346
|
-
option :a2, value: 2
|
347
|
-
end
|
348
|
-
end
|
349
|
-
end
|
350
|
-
end
|
351
|
-
|
352
|
-
it 'can build a question with options' do
|
353
|
-
dsl do
|
354
|
-
panel do
|
355
|
-
zzl_question :v_1, 'zzl title'
|
356
|
-
end
|
357
|
-
end
|
358
|
-
expect(questionnaire.question_hash[:v_1].title).to eq 'zzl title'
|
359
|
-
expect(questionnaire.question_hash[:v_1].type).to eq :scale
|
360
|
-
expect(questionnaire.question_hash[:v_1].options[0].key).to eq :a1
|
361
|
-
end
|
362
|
-
|
363
|
-
it 'can be used within a table' do
|
364
|
-
dsl do
|
365
|
-
panel do
|
366
|
-
table columns: 4 do
|
367
|
-
zzl_question :v_1, 'zzl title'
|
368
|
-
end
|
369
|
-
end
|
370
|
-
end
|
371
|
-
expect(questionnaire.question_hash[:v_1].title).to eq 'zzl title'
|
372
|
-
expect(questionnaire.question_hash[:v_1].type).to eq :scale
|
373
|
-
expect(questionnaire.question_hash[:v_1].options[0].key).to eq :a1
|
374
|
-
end
|
375
|
-
end
|
376
|
-
|
377
|
-
it 'fails when specifying an existing method' do
|
378
|
-
expect do
|
379
|
-
dsl do
|
380
|
-
custom_method :question do |question_key, question_title|
|
381
|
-
question question_key, type: :string, title: question_title
|
382
|
-
end
|
383
|
-
panel do
|
384
|
-
zzl_question :v_1, 'zzl title'
|
385
|
-
end
|
386
|
-
end
|
387
|
-
end.to raise_exception(RuntimeError, "Custom method trying to override existing method")
|
388
|
-
end
|
389
|
-
|
390
|
-
it 'fails when specifying a a method twice' do
|
391
|
-
expect do
|
392
|
-
dsl do
|
393
|
-
custom_method :zzl_question do |question_key, question_title|
|
394
|
-
question question_key, type: :string, title: question_title
|
395
|
-
end
|
396
|
-
custom_method :zzl_question do |question_key, question_title|
|
397
|
-
question question_key, type: :string, title: question_title
|
398
|
-
end
|
399
|
-
panel do
|
400
|
-
zzl_question :v_1, 'zzl title'
|
401
|
-
end
|
402
|
-
end
|
403
|
-
end.to raise_exception(RuntimeError, "Custom method trying to override existing method")
|
404
|
-
end
|
405
|
-
end
|
406
|
-
|
407
|
-
describe '#add_lookup_tree' do
|
408
|
-
it 'can add a lookup tree' do
|
409
|
-
dsl do
|
410
|
-
add_lookup_tree :interpretations,
|
411
|
-
levels: ['score', 'interpretation'],
|
412
|
-
tree: {
|
413
|
-
0..24 => 'low',
|
414
|
-
25..50 => 'high'
|
415
|
-
}
|
416
|
-
end
|
417
|
-
|
418
|
-
expect(questionnaire.lookup_tables[:interpretations].lookup(score: 26)).to eq 'high'
|
419
|
-
end
|
420
|
-
end
|
421
|
-
|
422
|
-
describe '#score' do
|
423
|
-
it 'requires scores to have a label' do
|
424
|
-
dsl do
|
425
|
-
score :totaal do
|
426
|
-
{value: 100}
|
427
|
-
end
|
428
|
-
end
|
429
|
-
|
430
|
-
expect(questionnaire.errors.full_messages).to eq(["Score totaal misses label in score call"])
|
431
|
-
end
|
432
|
-
end
|
433
|
-
|
434
|
-
describe '#score_schema' do
|
435
|
-
let(:subschema_options) { [{key: :value, export_key: :tot, label: 'Score'}] }
|
436
|
-
let(:set_dsl) do
|
437
|
-
options = subschema_options
|
438
|
-
dsl do
|
439
|
-
score :totaal, label: 'totaal' do
|
440
|
-
{value: 100}
|
441
|
-
end
|
442
|
-
|
443
|
-
score_schema :totaal, 'Totaal', options
|
444
|
-
end
|
445
|
-
end
|
446
|
-
|
447
|
-
it 'calls #add_score_schema with the given arguments' do
|
448
|
-
expect(questionnaire).to receive(:add_score_schema).with :totaal, 'Totaal', subschema_options
|
449
|
-
set_dsl
|
450
|
-
end
|
451
|
-
end
|
452
|
-
|
453
|
-
describe '#outcome_table' do
|
454
|
-
it 'calls questionnaire.add_outcome_table with the given arguments' do
|
455
|
-
expect(questionnaire).to receive(:add_outcome_table).with(score_keys: [:a], subscore_keys: [:b])
|
456
|
-
dsl do
|
457
|
-
outcome_table score_keys: [:a], subscore_keys: [:b]
|
458
|
-
end
|
459
|
-
end
|
460
|
-
end
|
461
|
-
|
462
|
-
describe '#video' do
|
463
|
-
it 'passes arguments to a video tag call, and puts the result in a text item' do
|
464
|
-
expect_any_instance_of(PanelBuilder).to receive(:video_tag).with('https://example.com/video.mp4', looping: true).and_return 'foo'
|
465
|
-
|
466
|
-
dsl do
|
467
|
-
panel do
|
468
|
-
video 'https://example.com/video.mp4', looping: true
|
469
|
-
end
|
470
|
-
end
|
471
|
-
expect(questionnaire.panels.first.items.first.raw_content).to eq('foo')
|
472
|
-
end
|
473
|
-
|
474
|
-
end
|
475
|
-
|
476
|
-
def dsl(&block)
|
477
|
-
builder.instance_eval(&block)
|
478
|
-
end
|
479
|
-
end
|
480
|
-
end
|