Somewhere I have read that private methods aren't supposed to be tested. Your tests should only care about the real thing - your public API. If your public methods work, then the private ones they call will also work
So is it not necessary to test private methods, but consider below example
private
def valid_extension?(file_path)
extension = file_type(file_path)
extension.in?(%w(csv xls xlsx)) ? true : false
end
the above private method returns whether the file extension is valid or not, so what if someone changes my private method like this
private
def valid_extension?(file_path)
true
end
it will always give me valid extension
So, is it not necessary to test private methods also.
Since we cannot access private method outside class, so how to test the private methods using rspec-rails.