demarches-normaliennes/spec/models/procedure_path_spec.rb
2016-06-24 16:41:44 +02:00

38 lines
No EOL
1.1 KiB
Ruby

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
context 'path' do
let(:admin) { create(:administrateur) }
let(:procedure) { create(:procedure) }
let(:procedure_path) { create(:procedure_path, administrateur: admin, procedure: procedure, path: path) }
context 'path is nil' do
let(:path) { nil }
it { expect{procedure_path}.to raise_error }
end
context 'path is empty' do
let(:path) { '' }
it { expect{procedure_path}.to raise_error }
end
context 'path is invalid' do
let(:path) { 'Demande de subvention' }
it { expect{procedure_path}.to raise_error(ActiveRecord::RecordInvalid) }
end
context 'path is invalid' do
let(:path) { 'ma_super_procedure' }
it { expect{procedure_path}.not_to raise_error }
end
end
end
end