|
|
|
@ -1,12 +1,12 @@
|
|
|
|
require 'rails_helper'
|
|
|
|
require "rails_helper"
|
|
|
|
require 'fileutils'
|
|
|
|
require "fileutils"
|
|
|
|
require 'csv'
|
|
|
|
require "csv"
|
|
|
|
|
|
|
|
|
|
|
|
RSpec.describe Dese::ThreeBOne do
|
|
|
|
RSpec.describe Dese::ThreeBOne do
|
|
|
|
let(:academic_years) do
|
|
|
|
let(:academic_years) do
|
|
|
|
[
|
|
|
|
[
|
|
|
|
create(:academic_year, range: '2021-22'),
|
|
|
|
create(:academic_year, range: "2021-22"),
|
|
|
|
create(:academic_year, range: '2020-21')
|
|
|
|
create(:academic_year, range: "2020-21")
|
|
|
|
# create(:academic_year, range: '2019-20'),
|
|
|
|
# create(:academic_year, range: '2019-20'),
|
|
|
|
# create(:academic_year, range: '2018-19'),
|
|
|
|
# create(:academic_year, range: '2018-19'),
|
|
|
|
# create(:academic_year, range: '2017-18'),
|
|
|
|
# create(:academic_year, range: '2017-18'),
|
|
|
|
@ -14,95 +14,95 @@ RSpec.describe Dese::ThreeBOne do
|
|
|
|
]
|
|
|
|
]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
let(:i1_filepath) { Rails.root.join('tmp', 'spec', 'dese', '3B_1_masscore.csv') }
|
|
|
|
let(:i1_filepath) { Rails.root.join("tmp", "spec", "dese", "3B_1_masscore.csv") }
|
|
|
|
let(:i2_filepath) { Rails.root.join('tmp', 'spec', 'dese', '3B_1_advcoursecomprate.csv') }
|
|
|
|
let(:i2_filepath) { Rails.root.join("tmp", "spec", "dese", "3B_1_advcoursecomprate.csv") }
|
|
|
|
let(:i3_filepath) { Rails.root.join('tmp', 'spec', 'dese', '3B_1_ap.csv') }
|
|
|
|
let(:i3_filepath) { Rails.root.join("tmp", "spec", "dese", "3B_1_ap.csv") }
|
|
|
|
let(:i4_filepath) { Rails.root.join('tmp', 'spec', 'dese', '3B_1_student_courses_ratio.csv') }
|
|
|
|
let(:i4_filepath) { Rails.root.join("tmp", "spec", "dese", "3B_1_student_courses_ratio.csv") }
|
|
|
|
|
|
|
|
|
|
|
|
let(:filepaths) do
|
|
|
|
let(:filepaths) do
|
|
|
|
[i1_filepath, i2_filepath, i3_filepath, i4_filepath]
|
|
|
|
[i1_filepath, i2_filepath, i3_filepath, i4_filepath]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
before do
|
|
|
|
before do
|
|
|
|
FileUtils.mkdir_p 'tmp/spec/dese'
|
|
|
|
FileUtils.mkdir_p "tmp/spec/dese"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
before :each do
|
|
|
|
before :each do
|
|
|
|
academic_years
|
|
|
|
academic_years
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
context 'a-curv-i5' do
|
|
|
|
xcontext "a-curv-i5" do
|
|
|
|
it 'creates a csv file with the scraped data' do
|
|
|
|
it "creates a csv file with the scraped data" do
|
|
|
|
Dese::ThreeBOne.new(filepaths:).run_all
|
|
|
|
Dese::ThreeBOne.new(filepaths:).run_all
|
|
|
|
expect(i4_filepath).to exist
|
|
|
|
expect(i4_filepath).to exist
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
xcontext 'Creating a new Scraper' do
|
|
|
|
xcontext "Creating a new Scraper" do
|
|
|
|
it 'creates a csv file with the scraped data' do
|
|
|
|
it "creates a csv file with the scraped data" do
|
|
|
|
Dese::ThreeBOne.new(filepaths:).run_all
|
|
|
|
Dese::ThreeBOne.new(filepaths:).run_all
|
|
|
|
expect(i1_filepath).to exist
|
|
|
|
expect(i1_filepath).to exist
|
|
|
|
expect(i2_filepath).to exist
|
|
|
|
expect(i2_filepath).to exist
|
|
|
|
expect(i3_filepath).to exist
|
|
|
|
expect(i3_filepath).to exist
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'has the correct headers for a-curv-i1' do
|
|
|
|
it "has the correct headers for a-curv-i1" do
|
|
|
|
headers = File.open(i1_filepath) do |file|
|
|
|
|
headers = File.open(i1_filepath) do |file|
|
|
|
|
headers = file.first
|
|
|
|
headers = file.first
|
|
|
|
end.split(',')
|
|
|
|
end.split(",")
|
|
|
|
|
|
|
|
|
|
|
|
expect(headers).to eq ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year', 'School Name', 'DESE ID',
|
|
|
|
expect(headers).to eq ["Raw likert calculation", "Likert Score", "Admin Data Item", "Academic Year", "School Name", "DESE ID",
|
|
|
|
'# Graduated', '# Completed MassCore', "% Completed MassCore\n"]
|
|
|
|
"# Graduated", "# Completed MassCore", "% Completed MassCore\n"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
it 'has the correct headers for a-curv-i2' do
|
|
|
|
it "has the correct headers for a-curv-i2" do
|
|
|
|
headers = File.open(i2_filepath) do |file|
|
|
|
|
headers = File.open(i2_filepath) do |file|
|
|
|
|
headers = file.first
|
|
|
|
headers = file.first
|
|
|
|
end.split(',')
|
|
|
|
end.split(",")
|
|
|
|
|
|
|
|
|
|
|
|
expect(headers).to eq ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year', 'School Name', 'DESE ID',
|
|
|
|
expect(headers).to eq ["Raw likert calculation", "Likert Score", "Admin Data Item", "Academic Year", "School Name", "DESE ID",
|
|
|
|
'# Grade 11 and 12 Students', '# Students Completing Advanced', '% Students Completing Advanced',
|
|
|
|
"# Grade 11 and 12 Students", "# Students Completing Advanced", "% Students Completing Advanced",
|
|
|
|
'% ELA', '% Math', '% Science and Technology', '% Computer and Information Science',
|
|
|
|
"% ELA", "% Math", "% Science and Technology", "% Computer and Information Science",
|
|
|
|
'% History and Social Sciences', '% Arts', '% All Other Subjects', "% All Other Subjects\n"]
|
|
|
|
"% History and Social Sciences", "% Arts", "% All Other Subjects", "% All Other Subjects\n"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'has the correct headers for a-curv-i3' do
|
|
|
|
it "has the correct headers for a-curv-i3" do
|
|
|
|
headers = File.open(i3_filepath) do |file|
|
|
|
|
headers = File.open(i3_filepath) do |file|
|
|
|
|
headers = file.first
|
|
|
|
headers = file.first
|
|
|
|
end.split(',')
|
|
|
|
end.split(",")
|
|
|
|
|
|
|
|
|
|
|
|
expect(headers).to eq ['Raw likert calculation', 'Likert Score', 'Admin Data Item', 'Academic Year', 'School Name', 'DESE ID',
|
|
|
|
expect(headers).to eq ["Raw likert calculation", "Likert Score", "Admin Data Item", "Academic Year", "School Name", "DESE ID",
|
|
|
|
'Tests Taken', 'Score=1', 'Score=2', 'Score=3', 'Score=4', 'Score=5', '% Score 1-2', "% Score 3-5\n"]
|
|
|
|
"Tests Taken", "Score=1", "Score=2", "Score=3", "Score=4", "Score=5", "% Score 1-2", "% Score 3-5\n"]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'has the right likert score results for a-curv-i1' do
|
|
|
|
it "has the right likert score results for a-curv-i1" do
|
|
|
|
results = CSV.parse(File.read(i1_filepath), headers: true).map do |row|
|
|
|
|
results = CSV.parse(File.read(i1_filepath), headers: true).map do |row|
|
|
|
|
next unless row['Admin Data Item'] == 'a-curv-i1' && row['Academic Year'] == '2020-21'
|
|
|
|
next unless row["Admin Data Item"] == "a-curv-i1" && row["Academic Year"] == "2020-21"
|
|
|
|
|
|
|
|
|
|
|
|
row['Likert Score'].to_f
|
|
|
|
row["Likert Score"].to_f
|
|
|
|
end.flatten.compact
|
|
|
|
end.flatten.compact
|
|
|
|
|
|
|
|
|
|
|
|
expect(results.take(20)).to eq [4.44, 4.44, 3.33, 3.83, 4.44, 3.6, 4.44, 4.44, 1, 4.44, 4.44, 4.44, 4.44, 3.89,
|
|
|
|
expect(results.take(20)).to eq [4.44, 4.44, 3.33, 3.83, 4.44, 3.6, 4.44, 4.44, 1, 4.44, 4.44, 4.44, 4.44, 3.89,
|
|
|
|
4.44, 4.44, 4.44, 4.44, 4.01, 3.92]
|
|
|
|
4.44, 4.44, 4.44, 4.44, 4.01, 3.92]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
it 'has the right likert score results for a-curv-i2' do
|
|
|
|
it "has the right likert score results for a-curv-i2" do
|
|
|
|
results = CSV.parse(File.read(i2_filepath), headers: true).map do |row|
|
|
|
|
results = CSV.parse(File.read(i2_filepath), headers: true).map do |row|
|
|
|
|
next unless row['Admin Data Item'] == 'a-curv-i2' && row['Academic Year'] == '2020-21'
|
|
|
|
next unless row["Admin Data Item"] == "a-curv-i2" && row["Academic Year"] == "2020-21"
|
|
|
|
|
|
|
|
|
|
|
|
row['Likert Score'].to_f
|
|
|
|
row["Likert Score"].to_f
|
|
|
|
end.flatten.compact
|
|
|
|
end.flatten.compact
|
|
|
|
|
|
|
|
|
|
|
|
expect(results.take(20)).to eq [5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 1.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0,
|
|
|
|
expect(results.take(20)).to eq [5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 1.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0,
|
|
|
|
5.0, 2.53, 5.0, 5.0]
|
|
|
|
5.0, 2.53, 5.0, 5.0]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
it 'has the right likert score results for a-curv-i3' do
|
|
|
|
it "has the right likert score results for a-curv-i3" do
|
|
|
|
results = CSV.parse(File.read(i3_filepath), headers: true).map do |row|
|
|
|
|
results = CSV.parse(File.read(i3_filepath), headers: true).map do |row|
|
|
|
|
next unless row['Admin Data Item'] == 'a-curv-i3' && row['Academic Year'] == '2020-21'
|
|
|
|
next unless row["Admin Data Item"] == "a-curv-i3" && row["Academic Year"] == "2020-21"
|
|
|
|
|
|
|
|
|
|
|
|
row['Likert Score'].to_f
|
|
|
|
row["Likert Score"].to_f
|
|
|
|
end.flatten.compact
|
|
|
|
end.flatten.compact
|
|
|
|
|
|
|
|
|
|
|
|
expect(results.take(20)).to eq [5.0, 1.46, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 2.06, 3.54, 5.0,
|
|
|
|
expect(results.take(20)).to eq [5.0, 1.46, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 5.0, 2.06, 3.54, 5.0,
|
|
|
|
5.0, 5.0, 5.0, 5.0, 1.0]
|
|
|
|
5.0, 5.0, 5.0, 5.0, 1.0]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|