Sha256: b80b36c0599d81f34902c83c3537b91d453876a52e35803a934f3f306fc7e40f
Contents?: true
Size: 820 Bytes
Versions: 32
Compression:
Stored size: 820 Bytes
Contents
require_relative 'helper' class User < DTO.new(:first_name, :last_name) end class DTOTest < MiniTest::Unit::TestCase 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
32 entries across 32 versions & 1 rubygems