Add test for DropDownList model
This commit is contained in:
parent
2ac0d2241f
commit
21dc35215e
2 changed files with 37 additions and 0 deletions
5
spec/factories/drop_down_list.rb
Normal file
5
spec/factories/drop_down_list.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
FactoryGirl.define do
|
||||
factory :drop_down_list do
|
||||
value ''
|
||||
end
|
||||
end
|
32
spec/models/drop_down_list_spec.rb
Normal file
32
spec/models/drop_down_list_spec.rb
Normal 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
|
Loading…
Reference in a new issue