demarches-normaliennes/spec/models/siret_spec.rb

48 lines
1 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
2015-12-03 15:02:22 +01:00
describe Siret, type: :model do
2024-05-13 16:38:37 +02:00
subject { Siret.new(siret: siret.dup) } # .dup in order to simulate a non literal user string
2015-12-03 15:02:22 +01:00
context 'with no siret provided' do
2018-09-19 10:15:42 +02:00
let(:siret) { '' }
it { is_expected.to be_invalid }
end
context 'with a siret that contains letters' do
let(:siret) { 'A1B1C6D9E0F0G1' }
it { is_expected.to be_invalid }
2015-12-03 15:02:22 +01:00
end
2018-09-19 10:15:42 +02:00
context 'with a siret that is too short' do
let(:siret) { '1234567890' }
it { is_expected.to be_invalid }
2015-12-03 15:02:22 +01:00
end
2018-09-19 10:15:42 +02:00
context 'with a siret that is too long' do
let(:siret) { '12345678901234567890' }
it { is_expected.to be_invalid }
2015-12-03 15:02:22 +01:00
end
2018-09-19 10:15:42 +02:00
context 'with a lunh-invalid siret' do
let(:siret) { '41816609600052' }
it { is_expected.to be_invalid }
2015-12-03 15:02:22 +01:00
end
context 'with a lunh-invalid La Poste siret' do
let(:siret) { '35600000018723' }
it { is_expected.to be_valid }
end
2018-09-19 10:15:42 +02:00
context 'with a valid siret' do
let(:siret) { '41816609600051' }
it { is_expected.to be_valid }
2015-12-03 15:02:22 +01:00
end
end