Commit 267fdfecb5cf592b52e72d938dbfa6a8ddc05a75

Authored by Luke Baker
1 parent aac098d1

use @question_tasks to call all question tests

Showing 1 changed file with 10 additions and 40 deletions   Show diff stats
lib/tasks/test_api.rake
@@ -93,43 +93,13 @@ namespace :test_api do @@ -93,43 +93,13 @@ namespace :test_api do
93 successes << message 93 successes << message
94 end 94 end
95 95
96 - message, error_occurred = answered_appearances_equals_votes_and_skips(question)  
97 - if error_occurred  
98 - errors << message  
99 - else  
100 - successes << message  
101 - end  
102 -  
103 -  
104 - message, error_occurred = check_each_choice_appears_within_n_stddevs(question)  
105 - if error_occurred  
106 - errors << message  
107 - else  
108 - successes << message  
109 - end  
110 -  
111 - message, error_occurred = check_each_choice_equally_likely_to_appear_left_or_right(question)  
112 - if error_occurred  
113 - errors << message  
114 - else  
115 - successes << message  
116 - end  
117 -  
118 -  
119 -  
120 - message, error_occurred = check_object_counter_cache_values_match_actual_values(question)  
121 - if error_occurred  
122 - errors << message  
123 - else  
124 - successes << message  
125 - end  
126 -  
127 -  
128 - message, error_occurred = check_prompt_cache_hit_rate(question)  
129 - if error_occurred  
130 - errors << message  
131 - else  
132 - successes << message 96 + @question_tasks.each do |taskname, description|
  97 + message, error_occurred = send(taskname, question)
  98 + if error_occurred
  99 + errors << message
  100 + else
  101 + successes << message
  102 + end
133 end 103 end
134 104
135 end 105 end
@@ -301,10 +271,10 @@ namespace :test_api do @@ -301,10 +271,10 @@ namespace :test_api do
301 end 271 end
302 272
303 273
304 - namespace :question do  
305 274
  275 + namespace :question do
306 # use this to dynamically create rake task for each question test 276 # use this to dynamically create rake task for each question test
307 - question_tasks = { 277 + @question_tasks = {
308 :answered_appearances_equals_votes_and_skips => "Ensure that a question has: answered_appearances == votes + skips", 278 :answered_appearances_equals_votes_and_skips => "Ensure that a question has: answered_appearances == votes + skips",
309 :check_each_choice_appears_within_n_stddevs => "Ensure each choice appears within 6 standard deviations", 279 :check_each_choice_appears_within_n_stddevs => "Ensure each choice appears within 6 standard deviations",
310 :check_each_choice_equally_likely_to_appear_left_or_right => "Ensure each choice is equally likely to appear on left or right", 280 :check_each_choice_equally_likely_to_appear_left_or_right => "Ensure each choice is equally likely to appear on left or right",
@@ -313,7 +283,7 @@ namespace :test_api do @@ -313,7 +283,7 @@ namespace :test_api do
313 } 283 }
314 284
315 # dynamically create tasks for each question task 285 # dynamically create tasks for each question task
316 - question_tasks.each do |taskname, description| 286 + @question_tasks.each do |taskname, description|
317 desc description 287 desc description
318 task taskname, [:question_id] => :environment do |t, args| 288 task taskname, [:question_id] => :environment do |t, args|
319 a = cleanup_args(args) 289 a = cleanup_args(args)