Skip to content

Commit

Permalink
fix rubocop offenses
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammednasser-32 committed Aug 30, 2024
1 parent 6a63eea commit 35db09f
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions spec/acceptance/callbacks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -251,29 +251,29 @@ def name
end

describe "before build callback" do
class TitleSetter
def self.title=(new_title)
@@title = new_title
end

def self.title
@@title
end
end

before do
define_class("TitleSetter") do
def self.title=(new_title)
class_variable_set(:@@title, new_title)
end

def self.title
class_variable_get(:@@title)
end
end

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
end

it "runs the before callback" do
article = FactoryBot.build(:article_with_before_callbacks)
expect(article.title).to eq("title from before build")
Expand Down

0 comments on commit 35db09f

Please sign in to comment.