demarches-normaliennes/spec/models/procedure_path_spec.rb

50 lines
1.7 KiB
Ruby
Raw Normal View History

require 'spec_helper'
describe ProcedurePath do
describe 'assocations' do
it { is_expected.to belong_to(:administrateur) }
it { is_expected.to belong_to(:procedure) }
end
describe 'attributes' do
it { is_expected.to have_db_column(:path) }
end
describe 'validation' do
2016-06-30 10:24:01 +02:00
describe 'path' do
let(:admin) { create(:administrateur) }
let(:procedure) { create(:procedure) }
let(:procedure_path) { create(:procedure_path, administrateur: admin, procedure: procedure, path: path) }
2016-06-30 10:24:01 +02:00
context 'when path is nil' do
let(:path) { nil }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
2016-06-30 10:24:01 +02:00
context 'when path is empty' do
let(:path) { '' }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
context 'when path contains spaces' do
let(:path) { 'Demande de subvention' }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
context 'when path contains alphanumerics and underscores' do
let(:path) { 'ma_super_procedure_1' }
it { expect{ procedure_path }.not_to raise_error }
end
context 'when path contains dashes' do
let(:path) { 'ma-super-procedure' }
it { expect{ procedure_path }.not_to raise_error }
end
context 'when path is too long' do
let(:path) { 'ma-super-procedure-12345678901234567890123456789012345678901234567890' }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
context 'when path is too short' do
let(:path) { 'pr' }
it { expect{ procedure_path }.to raise_error ActiveRecord::RecordInvalid }
end
end
end
2017-04-04 15:27:04 +02:00
end