diff options
Diffstat (limited to 'activemodel/test/cases/serializers/json_serialization_test.rb')
-rw-r--r-- | activemodel/test/cases/serializers/json_serialization_test.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/activemodel/test/cases/serializers/json_serialization_test.rb b/activemodel/test/cases/serializers/json_serialization_test.rb index d765a47636..d15ba64eb0 100644 --- a/activemodel/test/cases/serializers/json_serialization_test.rb +++ b/activemodel/test/cases/serializers/json_serialization_test.rb @@ -1,15 +1,15 @@ -require 'cases/helper' -require 'models/contact' -require 'active_support/core_ext/object/instance_variables' +require "cases/helper" +require "models/contact" +require "active_support/core_ext/object/instance_variables" class JsonSerializationTest < ActiveModel::TestCase def setup @contact = Contact.new - @contact.name = 'Konata Izumi' + @contact.name = "Konata Izumi" @contact.age = 16 @contact.created_at = Time.utc(2006, 8, 1) @contact.awesome = true - @contact.preferences = { 'shows' => 'anime' } + @contact.preferences = { "shows" => "anime" } end test "should not include root in json (class method)" do @@ -18,7 +18,7 @@ class JsonSerializationTest < ActiveModel::TestCase assert_no_match %r{^\{"contact":\{}, json assert_match %r{"name":"Konata Izumi"}, json assert_match %r{"age":16}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) + assert_includes json, %("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}) assert_match %r{"awesome":true}, json assert_match %r{"preferences":\{"shows":"anime"\}}, json end @@ -32,7 +32,7 @@ class JsonSerializationTest < ActiveModel::TestCase assert_match %r{^\{"contact":\{}, json assert_match %r{"name":"Konata Izumi"}, json assert_match %r{"age":16}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) + assert_includes json, %("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}) assert_match %r{"awesome":true}, json assert_match %r{"preferences":\{"shows":"anime"\}}, json ensure @@ -53,12 +53,12 @@ class JsonSerializationTest < ActiveModel::TestCase end test "should include custom root in json" do - json = @contact.to_json(root: 'json_contact') + json = @contact.to_json(root: "json_contact") assert_match %r{^\{"json_contact":\{}, json assert_match %r{"name":"Konata Izumi"}, json assert_match %r{"age":16}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) + assert_includes json, %("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}) assert_match %r{"awesome":true}, json assert_match %r{"preferences":\{"shows":"anime"\}}, json end @@ -68,7 +68,7 @@ class JsonSerializationTest < ActiveModel::TestCase assert_match %r{"name":"Konata Izumi"}, json assert_match %r{"age":16}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) + assert_includes json, %("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}) assert_match %r{"awesome":true}, json assert_match %r{"preferences":\{"shows":"anime"\}}, json end @@ -79,7 +79,7 @@ class JsonSerializationTest < ActiveModel::TestCase assert_match %r{"name":"Konata Izumi"}, json assert_match %r{"age":16}, json assert_no_match %r{"awesome":true}, json - assert !json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) + assert_not_includes json, %("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}) assert_no_match %r{"preferences":\{"shows":"anime"\}}, json end @@ -89,7 +89,7 @@ class JsonSerializationTest < ActiveModel::TestCase assert_no_match %r{"name":"Konata Izumi"}, json assert_no_match %r{"age":16}, json assert_match %r{"awesome":true}, json - assert json.include?(%("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))})) + assert_includes json, %("created_at":#{ActiveSupport::JSON.encode(Time.utc(2006, 8, 1))}) assert_match %r{"preferences":\{"shows":"anime"\}}, json end @@ -134,9 +134,9 @@ class JsonSerializationTest < ActiveModel::TestCase json = @contact.as_json assert_kind_of Hash, json - assert_kind_of Hash, json['contact'] + assert_kind_of Hash, json["contact"] %w(name age created_at awesome preferences).each do |field| - assert_equal @contact.send(field), json['contact'][field] + assert_equal @contact.send(field), json["contact"][field] end ensure Contact.include_root_in_json = original_include_root_in_json |