Add test for DropDownList model

This commit is contained in:
Xavier J 2016-12-16 10:07:40 +01:00
parent 2ac0d2241f
commit 21dc35215e
2 changed files with 37 additions and 0 deletions

View file

@ -0,0 +1,5 @@
FactoryGirl.define do
factory :drop_down_list do
value ''
end
end

View file

@ -0,0 +1,32 @@
require 'spec_helper'
describe DropDownList do
describe 'database columns' do
it { is_expected.to have_db_column(:value) }
end
describe 'associations' do
it { is_expected.to belong_to(:type_de_champ) }
end
describe '#options' do
let(:value) { "Cohésion sociale
Dév.Eco / Emploi
Cadre de vie / Urb.
Pilotage / Ingénierie
" }
let(:dropdownlist) { create :drop_down_list, value: value }
it { expect(dropdownlist.options).to eq ["Cohésion sociale", "Dév.Eco / Emploi", "Cadre de vie / Urb.", "Pilotage / Ingénierie"] }
context 'when one value is empty' do
let(:value) { "Cohésion sociale
Cadre de vie / Urb.
Pilotage / Ingénierie
" }
it { expect(dropdownlist.options).to eq ["Cohésion sociale", "Cadre de vie / Urb.", "Pilotage / Ingénierie"] }
end
end
end