How to test a private method in rspec

Since you can­not access a pri­vate method directly, in order to test a pri­vate method, you can make use of the ‘send’ method that is avail­able on all objects.

@obj = MyClass.new
result = @obj.send(:my_private_method, arguments)
expect(....)

Ryan Sukale

Ryan is just a regular guy next door trying to manage his life and finances.

You may also like...