@ -45,8 +45,8 @@ describe ResponseRatePresenter do
end
end
it 'ignores all teacher items and only gets the modified date of the last student item' do
it 'ignores all teacher items and only gets the modified date of the last student item' do
rdat e = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . date
percentag e = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . date
expect ( rdat e) . to eq ( newest_student_survey_response . updated_at )
expect ( percentag e) . to eq ( newest_student_survey_response . updated_at )
end
end
end
end
context 'when focus is teacher' do
context 'when focus is teacher' do
@ -58,8 +58,8 @@ describe ResponseRatePresenter do
end
end
it 'ignores all student responses and only gets the modified date of the last teacher item' do
it 'ignores all student responses and only gets the modified date of the last teacher item' do
rdat e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . date
percentag e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . date
expect ( rdat e) . to eq ( newest_teacher_survey_response . updated_at )
expect ( percentag e) . to eq ( newest_teacher_survey_response . updated_at )
end
end
end
end
end
end
@ -71,8 +71,8 @@ describe ResponseRatePresenter do
end
end
context 'when no survey responses are found for a school' do
context 'when no survey responses are found for a school' do
it 'returns a response rate of 0' do
it 'returns a response rate of 0' do
rdat e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
percentag e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
expect ( rdat e) . to eq ( 0 )
expect ( percentag e) . to eq ( 0 )
end
end
end
end
@ -83,8 +83,8 @@ describe ResponseRatePresenter do
end
end
it 'returns a response rate of 100' do
it 'returns a response rate of 100' do
rdat e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
percentag e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
expect ( rdat e) . to eq ( 100 )
expect ( percentag e) . to eq ( 100 )
end
end
end
end
@ -95,8 +95,8 @@ describe ResponseRatePresenter do
end
end
it 'returns a response rate of 100' do
it 'returns a response rate of 100' do
rdat e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
percentag e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
expect ( rdat e) . to eq ( 100 )
expect ( percentag e) . to eq ( 100 )
end
end
end
end
@ -107,8 +107,8 @@ describe ResponseRatePresenter do
end
end
it 'returns a response rate of 75' do
it 'returns a response rate of 75' do
rdat e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
percentag e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
expect ( rdat e) . to eq ( 75 )
expect ( percentag e) . to eq ( 75 )
end
end
end
end
context 'when one quarter of the teachers responded to the survey' do
context 'when one quarter of the teachers responded to the survey' do
@ -118,8 +118,8 @@ describe ResponseRatePresenter do
end
end
it 'returns a response rate of 25' do
it 'returns a response rate of 25' do
rdat e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
percentag e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
expect ( rdat e) . to eq ( 25 )
expect ( percentag e) . to eq ( 25 )
end
end
end
end
context 'When the percentage is not a round number' do
context 'When the percentage is not a round number' do
@ -129,8 +129,8 @@ describe ResponseRatePresenter do
end
end
it 'its rounded to the nearest integer' do
it 'its rounded to the nearest integer' do
rdat e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
percentag e = ResponseRatePresenter . new ( focus : :teacher , academic_year : , school : ) . percentage
expect ( rdat e) . to eq ( 23 )
expect ( percentag e) . to eq ( 23 )
end
end
end
end
@ -141,8 +141,8 @@ describe ResponseRatePresenter do
end
end
it 'returns a response rate of 100' do
it 'returns a response rate of 100' do
rdat e = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
percentag e = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
expect ( rdat e) . to eq ( 100 )
expect ( percentag e) . to eq ( 100 )
end
end
end
end
context 'when half of all students responded' do
context 'when half of all students responded' do
@ -152,8 +152,98 @@ describe ResponseRatePresenter do
end
end
it 'returns a response rate of 50' do
it 'returns a response rate of 50' do
rdate = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
percentage = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
expect ( rdate ) . to eq ( 50 )
expect ( percentage ) . to eq ( 50 )
end
end
context 'when only a subset of grades was given the survey' do
before :each do
respondents . one = 20
respondents . two = 20
respondents . three = 20
respondents . four = 20
respondents . five = 20
respondents . save
end
context 'and only first grade was given the survey' do
context 'and all the first grade responded' do
before :each do
create_list ( :survey_item_response , 20 , school : , academic_year : ,
survey_item : student_survey_item , grade : 1 )
end
it 'returns a response rate of 100' do
percentage = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
expect ( percentage ) . to eq ( 100 )
end
end
context 'and half of first grade responded' do
before :each do
create_list ( :survey_item_response , 10 , school : , academic_year : ,
survey_item : student_survey_item , grade : 1 )
end
it 'returns a response rate of 50' do
percentage = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
expect ( percentage ) . to eq ( 50 )
end
end
end
context 'and two grades responded' do
context 'and both grades responded fully' do
before :each do
create_list ( :survey_item_response , 20 , school : , academic_year : ,
survey_item : student_survey_item , grade : 1 )
create_list ( :survey_item_response , 20 , school : , academic_year : ,
survey_item : student_survey_item , grade : 2 )
end
it 'returns a response rate of 100' do
percentage = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
expect ( percentage ) . to eq ( 100 )
end
end
context 'and half of first grade responded' do
before :each do
create_list ( :survey_item_response , 10 , school : , academic_year : ,
survey_item : student_survey_item , grade : 1 )
create_list ( :survey_item_response , 20 , school : , academic_year : ,
survey_item : student_survey_item , grade : 2 )
end
it 'returns a response rate of 75' do
percentage = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
expect ( percentage ) . to eq ( 75 )
end
end
context 'and a quarter of first grade responded' do
before :each do
create_list ( :survey_item_response , 5 , school : , academic_year : ,
survey_item : student_survey_item , grade : 1 )
create_list ( :survey_item_response , 20 , school : , academic_year : ,
survey_item : student_survey_item , grade : 2 )
end
it 'returns a response rate of 63 (rounded up from 62.5)' do
percentage = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
expect ( percentage ) . to eq ( 63 )
end
end
end
context 'and three grades responded' do
context 'and all three grades responded fully' do
before :each do
create_list ( :survey_item_response , 20 , school : , academic_year : ,
survey_item : student_survey_item , grade : 1 )
create_list ( :survey_item_response , 20 , school : , academic_year : ,
survey_item : student_survey_item , grade : 2 )
create_list ( :survey_item_response , 20 , school : , academic_year : ,
survey_item : student_survey_item , grade : 3 )
end
it 'returns a response rate of 100' do
percentage = ResponseRatePresenter . new ( focus : :student , academic_year : , school : ) . percentage
expect ( percentage ) . to eq ( 100 )
end
end
end
end
end
end
end
end