0

I have a helper module named "AppHelper" and private method "sum" which I want to test using rspec.

For example:

module AppHelper
 private
 def sum(a,b)
   puts a+b
 end
end
  • I disagree with testing private methods. [More here](https://stackoverflow.com/a/16197778/3784008). – anothermh May 26 '19 at 07:49
  • 2
    Possible duplicate of [How to spec a private method](https://stackoverflow.com/questions/4154409/how-to-spec-a-private-method) – anothermh May 26 '19 at 07:49

1 Answers1

2

create a dummy class and access private method using .send(:private_method, args)

example

obj = Class.new { extend AppHelper } obj.send(:sum, 1,2)

sonal save
  • 98
  • 7