title: How to test if else condition in rspec
body: <p>I'm new to RSpec and I want to test if-else condition of a controller, I searched on the internet but the found results are not properly satisfying my search query.</p>
  
  <p>Here is my rails controller:</p>
  
  <pre><code>class ScheduleTimeSlotsController &lt; ApplicationController
    def get_available_schedules
      if params[:for_date].to_date==Date.today
        available_schedules=ScheduleTimeSlot.where(:doctor_id =&gt; params[:dr_id],:date=&gt;params[:for_date].to_date,:status=&gt;"vacant",:archive=&gt;false).where("start_time &gt;=?",Time.now.seconds_since_midnight).reorder(:start_time)
      else
        available_schedules=ScheduleTimeSlot.where(:doctor_id =&gt; params[:dr_id],:date=&gt;params[:for_date].to_date,:status=&gt;"vacant",:archive=&gt;false).reorder(:start_time)
      end
      render :json =&gt;{:available_schedules=&gt;available_schedules}
    end
  end
  </code></pre>
  
  <p>I'm using ruby version 2.2.4 and rails version is 4.2.0</p>
  
  <p>Please guide me that how do I write RSpec for this condition, with the help of an example.</p>
  
  <p>Thanks in advance.</p>