demarches-normaliennes/spec/models/logic/constant_spec.rb
simon lehericey 58da4805fa add constant
2022-06-17 14:53:27 +02:00

24 lines
637 B
Ruby

describe Logic::Constant do
include Logic
describe '#compute' do
it { expect(constant(1).compute).to eq(1) }
end
describe '#type' do
it { expect(constant(1).type).to eq(:number) }
it { expect(constant(1.0).type).to eq(:number) }
it { expect(constant('a').type).to eq(:string) }
it { expect(constant(true).type).to eq(:boolean) }
it { expect(constant(false).type).to eq(:boolean) }
end
describe '#errors' do
it { expect(constant(1).errors).to eq([]) }
end
describe '#==' do
it { expect(constant(1)).to eq(constant(1)) }
it { expect(constant(1)).not_to eq(constant('a')) }
end
end