ChampsService: add tests and refactor

This commit is contained in:
Simon Lehericey 2017-03-29 13:37:07 +02:00
parent c5159dde4b
commit 4df03fc28e
6 changed files with 119 additions and 23 deletions

View file

@ -14,6 +14,33 @@ shared_examples 'champ_spec' do
it { is_expected.to delegate_method(:order_place).to(:type_de_champ) }
end
describe 'mandatory_and_blank?' do
let(:type_de_champ) { TypeDeChamp.new(mandatory: mandatory) }
let(:champ) { Champ.new(type_de_champ: type_de_champ, value: value) }
let(:value) { '' }
let(:mandatory) { true }
context 'when mandatory and blank' do
it { expect(champ.mandatory_and_blank?).to be(true) }
end
context 'when not blank' do
let(:value) { 'yop' }
it { expect(champ.mandatory_and_blank?).to be(false) }
end
context 'when not mandatory' do
let(:mandatory) { false }
it { expect(champ.mandatory_and_blank?).to be(false) }
end
context 'when not mandatory or blank' do
let(:value) { 'u' }
let(:mandatory) { false }
it { expect(champ.mandatory_and_blank?).to be(false) }
end
end
describe 'data_provide' do
let(:champ) { create :champ }