Skip to content

Commit 891ce87

Browse files
committed
Revert pretty_json — rspec do nice diffs after all
1 parent 672f4ac commit 891ce87

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

spec/ios_send_app_size_metrics_spec.rb

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,7 @@
44
let(:test_data_dir) { File.join(File.dirname(__FILE__), 'test-data', 'app_size_metrics') }
55
let(:mocked_endpoint) { 'https://localhost/api/metrics' }
66
let(:mocked_token) { 'token/1' }
7-
8-
# Utility method to turn a minified JSON into a pretty-formatted JSON (without the GZIP fake prefix if any)
9-
# To make any test failure and diff easier to debug
10-
def pretty_json(json_string)
11-
JSON.pretty_generate(JSON.parse(json_string))
12-
end
7+
let(:fake_ipa_size) { 1337 } # The value used in the `app-thinning.plist` and `app-size-metrics-payload.json` fixtures
138

149
def test_app_size_action(fake_ipa_size:, expected_json:, **other_action_args)
1510
in_tmp_dir do |tmp_dir|
@@ -43,9 +38,9 @@ def test_app_size_action(fake_ipa_size:, expected_json:, **other_action_args)
4338
expect do
4439
last_received_body_uncompressed = Zlib.gunzip(last_received_body)
4540
end.not_to raise_error, 'Payload was not valid GZipped data'
46-
# Compare the payloads as pretty-formatted JSON, to make the diff in test failures more readable if one happen
47-
expect(pretty_json(last_received_body_uncompressed)).to eq(pretty_json(expected_json)), 'Decompressed JSON payload was not as expected'
48-
# Compare the payloads as raw uncompressed data as a final check
41+
# Compare the JSON payloads as parsed objects for nicer diffs
42+
expect(JSON.parse(last_received_body_uncompressed)).to eq(JSON.parse(expected_json)), 'Decompressed JSON payload was not as expected'
43+
# Compare the payloads as uncompressed, raw string as a final check
4944
expect(last_received_body_uncompressed).to eq(expected_json)
5045
end
5146
end
@@ -78,7 +73,7 @@ def test_app_size_action(fake_ipa_size:, expected_json:, **other_action_args)
7873
expected_json = JSON.parse(File.read(expected_fixture)).to_json
7974

8075
test_app_size_action(
81-
fake_ipa_size: 1337,
76+
fake_ipa_size: fake_ipa_size,
8277
expected_json: expected_json,
8378
app_thinning_plist_path: app_thinning_plist_path,
8479
app_name: 'wordpress',

0 commit comments

Comments
 (0)