Ensure that construct returns the correct zone when the score is right on a benchmark

pull/1/head
Alex Basson 4 years ago
parent 8915cb9d45
commit 9007cd3078

@ -1,10 +1,3 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor.create(name: 'Emanuel', city: cities.first)
require 'csv'
Item.destroy_all
@ -27,8 +20,6 @@ CSV.parse(csv_file, headers: true).each do |row|
item_prompt = row['Survey Item']
Item.create construct: Construct.find_by_construct_id(construct_id), prompt: item_prompt
end
end
# questions = Category.find_by_name('Family Subcategory').child_categories.map(&:questions).flatten

@ -15,4 +15,31 @@ describe Construct, type: :model do
expect(construct.approval_zone).to eq Construct::Zone.new(3.5, 4.71, :approval)
expect(construct.ideal_zone).to eq Construct::Zone.new(4.71, 5.0, :ideal)
end
describe '#zone_for_score' do
let(:construct) {
Construct.new watch_low_benchmark: 1.5, growth_low_benchmark: 2.5, approval_low_benchmark: 3.5, ideal_low_benchmark: 4.5
}
context 'when the score is 1.0' do
it 'returns the warning zone' do
expect(construct.zone_for_score(1.0)).to eq construct.warning_zone
end
end
context 'when the score is 5.0' do
it 'returns the ideal zone' do
expect(construct.zone_for_score(5.0)).to eq construct.ideal_zone
end
end
context 'when the score is right on the benchmark' do
it 'returns the higher zone' do
expect(construct.zone_for_score(1.5)).to eq construct.watch_zone
expect(construct.zone_for_score(2.5)).to eq construct.growth_zone
expect(construct.zone_for_score(3.5)).to eq construct.approval_zone
expect(construct.zone_for_score(4.5)).to eq construct.ideal_zone
end
end
end
end

Loading…
Cancel
Save