Sha256: a65a6a8f59e4fd777b17a47dd361f32124b7c7ce774119adf8d46cb0810acbff
Contents?: true
Size: 1.8 KB
Versions: 3
Compression:
Stored size: 1.8 KB
Contents
require 'test_helper' module ActiveModel class Serializer class IncludeTree module Parsing class IncludeArgsToHashTest < MiniTest::Test def test_include_args_to_hash_from_symbol expected = { author: {} } input = :author actual = Parsing.include_args_to_hash(input) assert_equal(expected, actual) end def test_include_args_to_hash_from_array expected = { author: {}, comments: {} } input = [:author, :comments] actual = Parsing.include_args_to_hash(input) assert_equal(expected, actual) end def test_include_args_to_hash_from_nested_array expected = { author: {}, comments: { author: {} } } input = [:author, comments: [:author]] actual = Parsing.include_args_to_hash(input) assert_equal(expected, actual) end def test_include_args_to_hash_from_array_of_hashes expected = { author: {}, blogs: { posts: { contributors: {} } }, comments: { author: { blogs: { posts: {} } } } } input = [ :author, blogs: [posts: :contributors], comments: { author: { blogs: :posts } } ] actual = Parsing.include_args_to_hash(input) assert_equal(expected, actual) end def test_array_of_string expected = { comments: { author: {}, attachment: {} } } input = [ 'comments.author', 'comments.attachment' ] actual = Parsing.include_args_to_hash(input) assert_equal(expected, actual) end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems