Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

BugFix: Random test failure when tracking compilation time #1713

Merged
merged 2 commits into from
Jan 31, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions spec/acceptance/activesupport_instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,15 @@ def subscribed(callback, *args)
end

it "tracks proper time of compiling the factory" do
time_to_execute = 0
callback = ->(_name, start, finish, _id, _payload) { time_to_execute = finish - start }
time_to_execute = {user: 0}
callback = ->(_name, start, finish, _id, _payload) {
time_to_execute[_payload[:name]] = (finish - start)
neilvcarvalho marked this conversation as resolved.
Show resolved Hide resolved
}
ActiveSupport::Notifications.subscribed(callback, "factory_bot.compile_factory") do
FactoryBot.build(:user)
end

expect(time_to_execute).to be > 0
expect(time_to_execute[:user]).to be > 0
end

it "builds the correct payload" do
Expand Down