demarches-normaliennes/spec/models/siret_spec.rb

46 lines
936 B
Ruby
Raw Normal View History

2015-12-03 15:02:22 +01:00
describe Siret, type: :model do
2018-09-19 10:15:42 +02:00
subject { Siret.new(siret: siret) }
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