From 15b8cf1434bbac092cdea387ab93cfa0b81b0dc9 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 5 Apr 2026 10:56:18 -0400 Subject: [PATCH] Fix flaky lost spec when fabricated user names collide When two users are fabricated without explicit user_name, Faker can generate the same name for both. In 'lost to two players' tests, if winner and winner2 get the same name, the command parser resolves them as one player, causing the match message to drop one name. Fix by assigning distinct explicit user_name values to winner, winner2, and loser2 in the affected tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- spec/slack-gamebot/commands/lost_spec.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/spec/slack-gamebot/commands/lost_spec.rb b/spec/slack-gamebot/commands/lost_spec.rb index d0e7abe..3d94547 100644 --- a/spec/slack-gamebot/commands/lost_spec.rb +++ b/spec/slack-gamebot/commands/lost_spec.rb @@ -134,7 +134,7 @@ context 'lost to' do let(:loser) { Fabricate(:user, user_name: 'username') } - let(:winner) { Fabricate(:user) } + let(:winner) { Fabricate(:user, user_name: 'winner') } it 'a player' do expect do @@ -160,8 +160,8 @@ end it 'two players' do - winner2 = Fabricate(:user, team:) - loser2 = Fabricate(:user, team:) + winner2 = Fabricate(:user, team:, user_name: 'winner2') + loser2 = Fabricate(:user, team:, user_name: 'loser2') expect do expect do expect(message: "#{SlackRubyBot.config.user} lost to #{winner.user_name} #{winner2.user_name} with #{loser2.user_name}", user: loser.user_id, channel: 'pongbot').to respond_with_slack_message( @@ -175,8 +175,8 @@ end it 'two players with scores' do - winner2 = Fabricate(:user, team:) - loser2 = Fabricate(:user, team:) + winner2 = Fabricate(:user, team:, user_name: 'winner2') + loser2 = Fabricate(:user, team:, user_name: 'loser2') expect do expect do expect(message: "#{SlackRubyBot.config.user} lost to #{winner.user_name} #{winner2.user_name} with #{loser2.user_name} 15:21", user: loser.user_id, channel: 'pongbot').to respond_with_slack_message(