demarches-normaliennes/spec/models/or_spec.rb
2022-06-17 14:53:27 +02:00

17 lines
490 B
Ruby

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
it { expect(or_from([true, false, true]).to_s).to eq "(true || false || true)" }
end
def or_from(boolean_to_constants)
ds_or(boolean_to_constants.map { |b| constant(b) })
end
end