From 11d2bd97165bf68439a8d2293c48b1fcefc8930c Mon Sep 17 00:00:00 2001
From: Matt Jankowski <matt@jankowski.online>
Date: Mon, 11 Dec 2023 02:55:07 -0500
Subject: [PATCH] Fix intermittent failure from unspecified order in
 `api/v1/accounts/relationships` spec (#28306)

---
 .../api/v1/accounts/relationships_spec.rb     | 42 +++++++++++--------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/spec/requests/api/v1/accounts/relationships_spec.rb b/spec/requests/api/v1/accounts/relationships_spec.rb
index cea45168a..b06ce0509 100644
--- a/spec/requests/api/v1/accounts/relationships_spec.rb
+++ b/spec/requests/api/v1/accounts/relationships_spec.rb
@@ -31,8 +31,8 @@ describe 'GET /api/v1/accounts/relationships' do
         .to have_http_status(200)
       expect(body_as_json)
         .to be_an(Enumerable)
-        .and have_attributes(
-          first: include(
+        .and contain_exactly(
+          include(
             following: true,
             followed_by: false
           )
@@ -53,9 +53,11 @@ describe 'GET /api/v1/accounts/relationships' do
           expect(body_as_json)
             .to be_an(Enumerable)
             .and have_attributes(
-              size: 2,
-              first: include(simon_item),
-              second: include(lewis_item)
+              size: 2
+            )
+            .and contain_exactly(
+              include(simon_item),
+              include(lewis_item)
             )
         end
       end
@@ -71,10 +73,12 @@ describe 'GET /api/v1/accounts/relationships' do
           expect(body_as_json)
             .to be_an(Enumerable)
             .and have_attributes(
-              size: 3,
-              first: include(simon_item),
-              second: include(lewis_item),
-              third: include(bob_item)
+              size: 3
+            )
+            .and contain_exactly(
+              include(simon_item),
+              include(lewis_item),
+              include(bob_item)
             )
         end
       end
@@ -88,9 +92,11 @@ describe 'GET /api/v1/accounts/relationships' do
           expect(body_as_json)
             .to be_an(Enumerable)
             .and have_attributes(
-              size: 2,
-              first: include(simon_item),
-              second: include(lewis_item)
+              size: 2
+            )
+            .and contain_exactly(
+              include(simon_item),
+              include(lewis_item)
             )
         end
       end
@@ -116,7 +122,6 @@ describe 'GET /api/v1/accounts/relationships' do
           muting: false,
           requested: false,
           domain_blocking: false,
-
         }
       end
 
@@ -129,7 +134,6 @@ describe 'GET /api/v1/accounts/relationships' do
           muting: false,
           requested: false,
           domain_blocking: false,
-
         }
       end
     end
@@ -149,8 +153,10 @@ describe 'GET /api/v1/accounts/relationships' do
       expect(body_as_json)
         .to be_an(Enumerable)
         .and have_attributes(
-          size: 1,
-          first: include(
+          size: 1
+        )
+        .and contain_exactly(
+          include(
             following: true,
             showing_reblogs: true
           )
@@ -168,8 +174,8 @@ describe 'GET /api/v1/accounts/relationships' do
 
       expect(body_as_json)
         .to be_an(Enumerable)
-        .and have_attributes(
-          first: include(
+        .and contain_exactly(
+          include(
             following: false,
             showing_reblogs: false
           )