[#1110] DRYer spec

This commit is contained in:
Frederic Merizen 2017-12-20 09:54:12 +01:00
parent b603af1ec7
commit 34d9408ed3

View file

@ -282,10 +282,8 @@ describe AttestationTemplate, type: :model do
context "match breaking and non breaking spaces" do context "match breaking and non breaking spaces" do
before { dossier.champs.first.update_attributes(value: 'valeur') } before { dossier.champs.first.update_attributes(value: 'valeur') }
context "when the tag contains a non breaking space" do shared_examples "treat all kinds of space as equivalent" do
let(:template_body) { 'body --mon tag--' } context 'and the champ has a non breaking space' do
context 'and the champ contains the non breaking space' do
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] } let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] }
it { expect(view_args[:body]).to eq('body valeur') } it { expect(view_args[:body]).to eq('body valeur') }
@ -298,20 +296,16 @@ describe AttestationTemplate, type: :model do
end end
end end
context "when the tag contains an ordinay space" do context "when the tag has a non breaking space" do
let(:template_body) { 'body --mon tag--' }
it_behaves_like "treat all kinds of space as equivalent"
end
context "when the tag has an ordinary space" do
let(:template_body) { 'body --mon tag--' } let(:template_body) { 'body --mon tag--' }
context 'and the champ contains a non breaking space' do it_behaves_like "treat all kinds of space as equivalent"
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] }
it { expect(view_args[:body]).to eq('body valeur') }
end
context 'and the champ has an ordinary space' do
let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] }
it { expect(view_args[:body]).to eq('body valeur') }
end
end end
end end
end end