Skip to content

Commit

Permalink
Handle default expected_roundtrip more explicitly for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
cjlarose committed Nov 6, 2020
1 parent 1015bad commit 0bb2df3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/test_json.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,14 @@ def test_generate_raises_error_for_unexpected_value_type

private

def assert_puma_json_generates_string(expected_output, value_to_serialize, expected_roundtrip: value_to_serialize)
def assert_puma_json_generates_string(expected_output, value_to_serialize, expected_roundtrip: nil)
actual_output = Puma::JSON.generate(value_to_serialize)
assert_equal expected_output, actual_output

if value_to_serialize.nil?
assert_nil ::JSON.parse(actual_output)
else
expected_roundtrip ||= value_to_serialize
assert_equal expected_roundtrip, ::JSON.parse(actual_output)
end
end
Expand Down

0 comments on commit 0bb2df3

Please sign in to comment.