From 34d9408ed3327fe5ba529bc93e5e79f9bb9a8e11 Mon Sep 17 00:00:00 2001 From: Frederic Merizen Date: Wed, 20 Dec 2017 09:54:12 +0100 Subject: [PATCH] [#1110] DRYer spec --- spec/models/attestation_template_spec.rb | 26 +++++++++--------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/spec/models/attestation_template_spec.rb b/spec/models/attestation_template_spec.rb index 088dc54d5..23aac7166 100644 --- a/spec/models/attestation_template_spec.rb +++ b/spec/models/attestation_template_spec.rb @@ -282,10 +282,8 @@ describe AttestationTemplate, type: :model do context "match breaking and non breaking spaces" do before { dossier.champs.first.update_attributes(value: 'valeur') } - context "when the tag contains a non breaking space" do - let(:template_body) { 'body --mon tag--' } - - context 'and the champ contains the non breaking space' do + shared_examples "treat all kinds of space as equivalent" do + context 'and the champ has a non breaking space' do let(:types_de_champ) { [create(:type_de_champ_public, libelle: 'mon tag')] } it { expect(view_args[:body]).to eq('body valeur') } @@ -298,20 +296,16 @@ describe AttestationTemplate, type: :model do 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--' } - context 'and the champ contains a non breaking space' do - 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 + it_behaves_like "treat all kinds of space as equivalent" end end end