demarches-normaliennes/spec/models/logic/or_spec.rb

20 lines
517 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2022-06-09 14:00:18 +02:00
describe Logic::Or do
include Logic
describe '#compute' do
it { expect(or_from([true, true, true]).compute).to be true }
it { expect(or_from([true, true, false]).compute).to be true }
it { expect(or_from([false, false, false]).compute).to be false }
end
describe '#to_s' do
2022-06-27 12:32:00 +02:00
it { expect(or_from([true, false, true]).to_s).to eq "(Oui || Non || Oui)" }
2022-06-09 14:00:18 +02:00
end
def or_from(boolean_to_constants)
ds_or(boolean_to_constants.map { |b| constant(b) })
end
end