<commit_before>require 'rails_helper'

RSpec.describe CourseInstance, type: :model do
  before do
    @course_instance_yesterday = FactoryGirl.build(:course_instance, end_date: Date.today-1)
    @course_instance_today = FactoryGirl.build(:course_instance, end_date: Date.today)
    @course_instance_tomorrow = FactoryGirl.build(:course_instance, end_date: Date.today+1)
  end

  describe ".schedulable?" do
    it "should return true if the class hasn't ended yet" do
      expect(@course_instance_tomorrow.schedulable?).to be true
    end

    it "should return false if the class has ended" do
      expect(@course_instance_yesterday.schedulable?).to be false
    end

    it "should return false if the class ends today" do
      expect(@course_instance_today.schedulable?).to be false
    end
  end

end<commit_msg>adding tests for course_instance method I added<commit_after>require 'rails_helper'

RSpec.describe CourseInstance, type: :model do
  before do
    @course_instance_yesterday = FactoryGirl.build(:course_instance, end_date: Date.today-1)
    @course_instance_today = FactoryGirl.build(:course_instance, end_date: Date.today)
    @course_instance_tomorrow = FactoryGirl.build(:course_instance, end_date: Date.today+1)
  end

  describe ".schedulable?" do
    it "should return true if the class hasn't ended yet" do
      expect(@course_instance_tomorrow.schedulable?).to be true
    end

    it "should return false if the class has ended" do
      expect(@course_instance_yesterday.schedulable?).to be false
    end

    it "should return false if the class ends today" do
      expect(@course_instance_today.schedulable?).to be false
    end
  end

  describe '#schedule' do
    context 'when there are no meetings' do
      let(:course_instance) { FactoryGirl.build(:course_instance) }

      it 'returns "TBA"' do
        expect(course_instance.schedule).to eq 'TBA'
      end
    end

    context 'when there are meetings' do
      let(:meetings) { FactoryGirl.build_list(:meeting, 2, schedule: 'MW 10:00 AM - 10:50 AM') }
      let(:course_instance) { FactoryGirl.build(:course_instance, meetings: meetings) }

      it 'returns the meeting schedules separated by a ;' do
        expect(course_instance.schedule).to eq 'MW 10:00 AM - 10:50 AM; MW 10:00 AM - 10:50 AM'
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.08796895213454076, 'fraction_numerical': 0.01250539025442001, 'mean_word_length': 3.8333333333333335, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4806687', 'n_tokens_mistral': 753, 'n_tokens_neox': 686, 'n_words': 209}