@ -23,6 +23,7 @@ RSpec.describe SurveyItemValues, type: :model do
create ( :race , qualtrics_code : 7 )
create ( :race , qualtrics_code : 8 )
create ( :race , qualtrics_code : 99 )
create ( :race , qualtrics_code : 100 )
Race . by_qualtrics_code
end
@ -378,6 +379,48 @@ RSpec.describe SurveyItemValues, type: :model do
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 99 ]
end
end
context " when there are multiple races " do
it " returns the gender that maps to the gender provided " do
row = { " Race " = > " 1,2,3 " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " Alaskan Native, Pacific Islander, Black " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " American Indian or Alaskan Native, Asian, African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " n/a " }
row = { " Race " = > " American Indian or Alaskan Native, Asian and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " American Indian or Alaskan Native and Asian and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " American Indian or Alaskan Native and Asian, and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 1 , 2 , 3 , 100 ]
row = { " Race " = > " Asian, Caucasian and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 2 , 5 , 3 , 100 ]
row = { " Race " = > " Caucasian and Asian and African American " }
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 , 2 , 3 , 100 ]
row = { " Race " = > " Caucasian and Asian and African American " , " HispanicLatino " = > " true " }
headers . push ( " HispanicLatino " )
values = SurveyItemValues . new ( row : , headers : , genders : , survey_items : , schools : )
expect ( values . races . map { | race | race & . qualtrics_code } ) . to eq [ 5 , 2 , 3 , 4 , 100 ]
end
end
end
context " .respondent_type " do