Add ChampDecorator tests

This commit is contained in:
Xavier J 2016-12-16 14:40:20 +01:00
parent e85cb4c24b
commit f627957869
2 changed files with 26 additions and 4 deletions

View file

@ -1,4 +1,5 @@
class ChampDecorator < Draper::Decorator
delegate_all
def value
if type_champ == 'checkbox'
@ -6,8 +7,4 @@ class ChampDecorator < Draper::Decorator
end
object.value
end
def type_champ
object.type_de_champ.type_champ
end
end

View file

@ -0,0 +1,25 @@
require 'spec_helper'
describe ChampDecorator do
let(:champ) {create :champ, type_de_champ: (create :type_de_champ_public, type_champ: :checkbox)}
let(:decorator) { champ.decorate }
describe 'value' do
subject { decorator.value }
context 'when type_champ is checkbox' do
context 'when value is on' do
before do
champ.update value: 'on'
end
it { is_expected.to eq 'Oui' }
end
context 'when value is other' do
it { is_expected.to eq 'Non' }
end
end
end
end