From 86c43702c3019d22730dfa5b13231c32bce7d9a0 Mon Sep 17 00:00:00 2001 From: mohammednasser-32 Date: Fri, 30 Aug 2024 23:10:06 +0300 Subject: [PATCH] fix rubocop offenses --- spec/acceptance/callbacks_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/acceptance/callbacks_spec.rb b/spec/acceptance/callbacks_spec.rb index 2dc3e0b0..f0cbebdd 100644 --- a/spec/acceptance/callbacks_spec.rb +++ b/spec/acceptance/callbacks_spec.rb @@ -251,24 +251,24 @@ def name end describe "before build callback" do - class TitleSetter - def self.title=(new_title) - @@title = new_title - end + before do + define_class("TitleSetter") do + def self.title=(new_title) + class_variable_set(:@@title, new_title) + end - def self.title - @@title + def self.title + class_variable_get(:@@title) + end end - end - before do define_model("Article", title: :string) - + FactoryBot.define do factory :article_with_before_callbacks, class: :article do before(:build) { TitleSetter.title = "title from before build" } after(:build) { TitleSetter.title = "title from after build" } - + title { TitleSetter.title } end end