# frozen_string_literal: true

require 'rails_helper'

describe ActiveCoursesController do
  render_views

  describe '#index' do
    let!(:course) do
      create(:course, title: 'My awesome course', end: 1.day.from_now)
    end

    it 'lists a soon-ending course' do
      get :index
      expect(response.body).to have_content(course.title)
    end
  end
end

# frozen_string_literal: true

require 'rails_helper'

describe ActiveCoursesController, type: :request do
  describe '#index' do
    let!(:course) do
      create(:course, title: 'My awesome course', end: 1.day.from_now)
    end

    it 'lists a soon-ending course' do
      get '/active_courses'
      expect(response.body).to include(course.title)
    end
  end
end

Convert controller spec to request spec
Convert controller spec to request spec

Controller specs are no longer a supported part of Rails core, and request specs are now the recommended replacement since they hit the router and middlewhare, and they render views by default.
