diff options
author | Andrew White <andrew.white@unboxed.co> | 2016-11-13 15:31:05 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2016-11-13 15:31:05 +0000 |
commit | d2890f76d49542ab853bfcbe5f1c4c6924231591 (patch) | |
tree | d7c13e0694597ac8e89bcc0332f68ed7ab18d8de /activesupport/test | |
parent | c85d305a67f83f3a92488a641654b85b90b8747a (diff) | |
download | rails-d2890f76d49542ab853bfcbe5f1c4c6924231591.tar.gz rails-d2890f76d49542ab853bfcbe5f1c4c6924231591.tar.bz2 rails-d2890f76d49542ab853bfcbe5f1c4c6924231591.zip |
Use literal values in assertions
Using the method you're testing to generate expected
values can lead to bugs being masked.
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/json/encoding_test.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/activesupport/test/json/encoding_test.rb b/activesupport/test/json/encoding_test.rb index e745f5e190..95bdc4283a 100644 --- a/activesupport/test/json/encoding_test.rb +++ b/activesupport/test/json/encoding_test.rb @@ -434,24 +434,22 @@ EXPECTED class InfiniteNumber def as_json(options = nil) - { "number" => 1.0 / 0 } + { "number" => Float::INFINITY } end end def test_to_json_works_when_as_json_returns_infinite_number - expected = { number: nil }.to_json - assert_equal expected, InfiniteNumber.new.to_json + assert_equal '{"number":null}', InfiniteNumber.new.to_json end class NaNNumber def as_json(options = nil) - { "number" => 0.0 / 0 } + { "number" => Float::INFINITY } end end def test_to_json_works_when_as_json_returns_NaN_number - expected = { number: nil }.to_json - assert_equal expected, NaNNumber.new.to_json + assert_equal '{"number":null}', NaNNumber.new.to_json end protected |