ruby - functional test for rails controller private method -


i have private method in controller. used database update. method calling controller method. , works fine.

but when trying write test case method tripping on accessing (session variable , params) in functional other methods working fine problem private method?

in setup method in functional test, setting session also.?

you should avoid testing private methods. "goal" behind having public/private/protected methods encapsulate logic , make easy change parts of code without having worry how 1 function or class interacts another.

that being said, if still feel need test private methods, there work arounds. found utility function via jay field's blog:

class class   def publicize_methods     saved_private_instance_methods = self.private_instance_methods     self.class_eval { public *saved_private_instance_methods }     yield     self.class_eval { private *saved_private_instance_methods }   end end 

check link usage details, seems quick , simple way you're looking do.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -