Skip to content

Instantly share code, notes, and snippets.

@wshihadeh
Last active December 21, 2019 12:12
Show Gist options
  • Save wshihadeh/6bf5da67356be649261cfc5a6f5ff92e to your computer and use it in GitHub Desktop.
Save wshihadeh/6bf5da67356be649261cfc5a6f5ff92e to your computer and use it in GitHub Desktop.
PriorityList Unit Tests
# 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