I’m writing the rspec unit test for the update method of controller. The method is:
def update
@people = People.find(params[:id])
if @people.update(people_params)
respond_to do |format|
format.html {redirect_to people_path(@people), flash: { info:'Update Success'}}
format.js {render json: { success: 'Update Success' }}
end
else
render :edit
end
I wonder how can I set up something so that I can make the tests like “if the format is HTML, then test these things”, and “if the format is js, then test those things”. Please give me some help, thank you so much!