diff --git a/spec/controllers/administrateurs/types_de_champ_controller_spec.rb b/spec/controllers/administrateurs/types_de_champ_controller_spec.rb index d69fd852e63..f026b2edf2a 100644 --- a/spec/controllers/administrateurs/types_de_champ_controller_spec.rb +++ b/spec/controllers/administrateurs/types_de_champ_controller_spec.rb @@ -140,8 +140,7 @@ def morpheds expect(type_de_champ.reload.referentiel).to eq Referentiel.last expect(Referentiel.last.types_de_champ).to eq [type_de_champ] expect(Referentiel.last.name).to eq referentiel_file.original_filename - expect(ReferentielItem.first.option).to eq({ 'dessert' => 'Éclair au café' }) - expect(ReferentielItem.first.data).to eq({ "calorie (kcal)" => "145", "poids (g)" => "60" }) + expect(ReferentielItem.first.data).to eq({ "dessert" => "Éclair au café", "poids_g" => "60", "calorie_kcal" => "145" }) expect(ReferentielItem.first.referentiel_id).to eq(Referentiel.last.id) end end @@ -151,8 +150,7 @@ def morpheds it 'creates a valid referentiel' do expect { subject }.to change(Referentiel, :count).by(1).and change(ReferentielItem, :count).by(3) - expect(ReferentielItem.first.option).to eq({ 'dessert' => 'Éclair au café' }) - expect(ReferentielItem.first.data).to eq({}) + expect(ReferentielItem.first.data).to eq({ 'dessert' => 'Éclair au café' }) end end @@ -327,7 +325,7 @@ def morpheds keys = csv_to_code.first.keys csv_to_code.each do |row| - referentiel.items.create!(option: row.slice(keys.first), data: row.except(keys.first)) + referentiel.items.create!(data: row) end end @@ -335,7 +333,7 @@ def morpheds context 'working case with multi column file' do it 'nullifies referentiel' do - expect { subject }.not_to change(Referentiel, :count).and change(ReferentielItem, :count) + expect { subject }.to not_change(Referentiel, :count).and not_change(ReferentielItem, :count) expect(type_de_champ.reload.referentiel).to be_nil expect(Referentiel.count).to eq 1 expect(ReferentielItem.count).to eq 3 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 3de5955f22b..dbc72f4056c 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -67,6 +67,8 @@ end end end + + RSpec::Matchers.define_negated_matcher(:not_change, :change) end RSpec.configure do |config|