Sha256: 421bffd0c79f1c0b5f0016d4b3d6b82e76a3eb00f2d25a0cb3441547804907e2
Contents?: true
Size: 810 Bytes
Versions: 23
Compression:
Stored size: 810 Bytes
Contents
require_relative 'helper' class User < DTO.new(:first_name, :last_name) end class DTOTest < Minitest::Test def setup @user = User.new(first_name: 'John', last_name: 'Doe', another: 'Yeah!') end def test_accessors assert_equal 'John', @user.first_name assert_equal 'Doe', @user.last_name refute @user.respond_to? :another end def test_to_json assert_equal({ first_name: 'John', last_name: 'Doe' }.to_json, @user.to_json) another = Class.new(DTO.new :first_name, :childs ) with_childs = another.new(first_name: 'Jess', childs: [ 'Albert', 'Margo' ]) assert_equal({ first_name: 'Jess', childs: ['Albert', 'Margo']}.to_json, with_childs.to_json) end def test_to_s expected = "first_name: John, last_name: Doe" assert_equal expected, @user.to_s end end
Version data entries
23 entries across 23 versions & 1 rubygems