How can I test this code in my controller? My problem is with the wizard_incompleted? method
class ApplicantsController < ApplicationController
def index
@applicant = current_user.applicant
@application = @applicant.applications.last
if @application.wizard_incompleted?
# some redirect
end
end
end
describe "GET #index" do
let(:application) { double('application')}
it "redirect to wizard if it is incompleted" do
get :index
allow_any_instance_of(application).to receive(:wizard_incompleted?).and_return(true)
expect(response).to redirect_to(new_applicants_application_path)
end
end
Aucun commentaire:
Enregistrer un commentaire