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

This commit is contained in:
Alex Basson 2021-09-15 15:28:04 -04:00
parent 8915cb9d45
commit 9007cd3078
2 changed files with 27 additions and 9 deletions

View file

@ -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