From 0e7a248498d36649dba53fc6dc60c6899f3ad2b5 Mon Sep 17 00:00:00 2001 From: Bohdan Date: Sun, 8 Dec 2024 12:38:03 +0200 Subject: [PATCH] Refactored tests --- spec/services/calculators/peferable_service_spec.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spec/services/calculators/peferable_service_spec.rb b/spec/services/calculators/peferable_service_spec.rb index f8cb21dcc..7b6475c39 100644 --- a/spec/services/calculators/peferable_service_spec.rb +++ b/spec/services/calculators/peferable_service_spec.rb @@ -7,8 +7,9 @@ describe "#perform!" do context "when preferable is set to 1" do + let!(:service) { Calculators::PreferableService.new(preferable: 1, slug: calculator1.slug) } + it "updates other calculators to have preferable set to false" do - service = Calculators::PreferableService.new(preferable: 1, slug: calculator1.slug) service.perform! expect(calculator1.reload.preferable).to eq(true) @@ -18,8 +19,9 @@ end context "when preferable is not set to 1" do + let!(:service) { Calculators::PreferableService.new(preferable: 0, slug: calculator1.slug) } + it "does not change any preferable values" do - service = Calculators::PreferableService.new(preferable: 0, slug: "calculator1") service.perform! expect(calculator1.reload.preferable).to eq(true)