2015-12-03 15:02:22 +01:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2018-09-19 10:29:43 +02:00
|
|
|
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
|