Skip to content

Commit

Permalink
Change World Index spec to compare hashes, not JSON string
Browse files Browse the repository at this point in the history
The world index spec if currently comparing JSON strings, which means
the test has to specify the keys in exactly the same order as they are
included in the JSON.

Additionally, rspec doesn't give a useful diff when this test fails when
comparing JSON strings, like it would with a hash.

Therefore changing this spec to compare hashes, like we are doing in the
other GraphQL integration tests.
  • Loading branch information
brucebolt committed Dec 2, 2024
1 parent 08d5ffd commit 287cd3a
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions spec/integration/graphql/world_index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,35 +64,35 @@
}

expected = {
"data": {
"edition": {
"title": "Help and services around the world",
"worldLocations": [
data: {
edition: {
title: "Help and services around the world",
worldLocations: [
{
"active": true,
"analyticsIdentifier": "WL1",
"contentId": "d3b7ba48-5027-4a98-a594-1108d205dc66",
"name": "Test World Location",
"slug": "test-world-location",
"updatedAt": "2024-10-18T14:22:38+01:00",
active: true,
analyticsIdentifier: "WL1",
contentId: "d3b7ba48-5027-4a98-a594-1108d205dc66",
name: "Test World Location",
slug: "test-world-location",
updatedAt: "2024-10-18T14:22:38+01:00",
},
],
"internationalDelegations": [
internationalDelegations: [
{
"active": false,
"analyticsIdentifier": "WL2",
"contentId": "f0313f16-e25c-4bfe-a0fc-e561833f705f",
"name": "Test International Delegation",
"slug": "test-international-delegation",
"updatedAt": "2024-10-19T15:07:44+01:00",
active: false,
analyticsIdentifier: "WL2",
contentId: "f0313f16-e25c-4bfe-a0fc-e561833f705f",
name: "Test International Delegation",
slug: "test-international-delegation",
updatedAt: "2024-10-19T15:07:44+01:00",
},
],
},

},
}.to_json
}

expect(response.body).to eq(expected)
parsed_response = JSON.parse(response.body).deep_symbolize_keys
expect(parsed_response).to eq(expected)
end
end
end

0 comments on commit 287cd3a

Please sign in to comment.