I have integrated rails application with omniauth and devise integration. In one the controller I have –
def create
# some
# stuff
# here
sign_in_and_redirect(:person, @person)
# some
# stuff
# here
end
as this action is from devise, i shouldn’t be testing this action but only presence of it(correct me here if i am wrong.). Also, as I am mocking this person object, it doesn’t have methods to pass origin sign_in_and_redirect action.
So, how can test this controller ?
UPDATE
I tried this in my before do block –
controller.stub!(:sign_in_and_redirect).and_return(true)
But this give me error as – Missing templace authentications/create
I don’t have any create.html.erb, as it redirects in normal workflow.
UPDATE
My AuthencationController#create method code can be seen here – http://www.pastie.org/2116067
My Test code can be seen here – http://www.pastie.org/2116081
Finally I found that it has to do with devise.
This solved issues – devise wiki – How To: Controllers and Views tests with Rails 3 (and rspec)
I had to include support/devise.rb file and below lines –
After that I just added required methods to person class by stubbing it and it worked.