Reformat the _render_list_champs template test

This commit is contained in:
gregoirenovel 2017-04-26 12:44:32 +02:00
parent 6e8ee504a9
commit 4ce6c92394

View file

@ -1,27 +1,29 @@
describe 'users/description/champs/render_list_champs.html.haml', type: :view do describe 'users/description/champs/render_list_champs.html.haml', type: :view do
let(:type_champ) { create(:type_de_champ_public, :checkbox) } let(:type_champ) { create(:type_de_champ_public, :checkbox) }
context "with a checkbox champ with value equals nil" do context "with a checkbox champ" do
let!(:champ_checkbox_checked) { create(:champ, type_de_champ: type_champ, value: nil) } context "whose value equals nil" do
let!(:champ_checkbox_checked) { create(:champ, type_de_champ: type_champ, value: nil) }
before do before do
render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0 render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0
end
it 'should not render a checked checkbox' do
expect(rendered).not_to have_css('input[type=checkbox][checked]')
end
end end
it 'should not render a checked checkbox' do context "whose value equals 'on'" do
expect(rendered).not_to have_css('input[type=checkbox][checked]') let!(:champ_checkbox_checked) { create(:champ, type_de_champ: type_champ, value: 'on') }
end
end
context "with a checkbox champ with value equals 'on'" do before do
let!(:champ_checkbox_checked) { create(:champ, type_de_champ: type_champ, value: 'on') } render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0
end
before do it 'should render a checked checkbox' do
render 'users/description/champs/render_list_champs.html.haml', champs: Champ.all, order_place: 0 expect(rendered).to have_css('input[type=checkbox][checked]')
end end
it 'should render a checked checkbox' do
expect(rendered).to have_css('input[type=checkbox][checked]')
end end
end end