Last active
December 21, 2019 12:12
-
-
Save wshihadeh/6bf5da67356be649261cfc5a6f5ff92e to your computer and use it in GitHub Desktop.
PriorityList Unit Tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# frozen_string_literal: true | |
describe PriorityList do | |
let(:list) { [1, 4, 6, 3, 7, 3, 0, 20, 3] } | |
describe '#priority_list' do | |
context 'ascending mode' do | |
before do | |
ENV['APPLICATION_MODE'] = 'ascending' | |
end | |
it ' sorts ascending' do | |
subject = described_class.new(list) | |
expect(subject.priority_list).to eq list.sort | |
end | |
end | |
context 'descending mode' do | |
before do | |
ENV['APPLICATION_MODE'] = 'descending' | |
end | |
it ' sorts descending' do | |
subject = described_class.new(list) | |
expect(subject.priority_list).to eq list.sort.reverse | |
end | |
end | |
context 'default mode' do | |
it ' sorts ascending' do | |
subject = described_class.new(list) | |
expect(subject.priority_list).to eq list.sort | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment