How to write tests for respond_to in controller?

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' }}
    render :edit

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!

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs