mardi 6 octobre 2015

How should I test a controller action that has a private method?

In my create action, I am calling a private method that basically returns true or false, only if it returns true will the record be created. my question is how should I control this private method to force it to return true inside my test to make my test pass? I want to perform a functional test.

My code is something like:

def create
  if limit_exceeded == true
    @review.save
  end
end

private 

def limit_excceded?
  #Some code that returns true or false. I want to force it to return true in my test
end

Aucun commentaire:

Enregistrer un commentaire