minitestでprivateメソッドをテスト
解決
__send__を使用する
Class Person def initialize(name) @name = name end private def tom(generation) @name = 'tom' + generation.to_s end end person = Person.new('tarou') person.__send__(:tom, 2) assert { re_inquiry.instance_eval('@name').size == 'tom2' } #<= インスタンス変数を参照 assignsメソッドなる物があるらしいが動作せず、instance_evalを利用。
This post is licensed under CC BY 4.0 by the author.