Add ChampDecorator tests
This commit is contained in:
parent
e85cb4c24b
commit
f627957869
2 changed files with 26 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
||||||
class ChampDecorator < Draper::Decorator
|
class ChampDecorator < Draper::Decorator
|
||||||
|
delegate_all
|
||||||
|
|
||||||
def value
|
def value
|
||||||
if type_champ == 'checkbox'
|
if type_champ == 'checkbox'
|
||||||
|
@ -6,8 +7,4 @@ class ChampDecorator < Draper::Decorator
|
||||||
end
|
end
|
||||||
object.value
|
object.value
|
||||||
end
|
end
|
||||||
|
|
||||||
def type_champ
|
|
||||||
object.type_de_champ.type_champ
|
|
||||||
end
|
|
||||||
end
|
end
|
25
spec/decorators/champ_decorator_spec.rb
Normal file
25
spec/decorators/champ_decorator_spec.rb
Normal 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
|
Loading…
Reference in a new issue