<commit_before>describe Student do
  let(:student) { Factory.create(:student) }
  describe "relations" do
    it "should have a user" do
      student.user.should be_instance_of(User)
    end

    it "should have a list of registered courses" do
      student = create(:student, student_registered_for_courses: [create(:student_registered_for_course)])
      student.should have(1).student_registered_for_courses
    end

    it "should have a list of given courses" do
      student = create(:student, given_courses: [create(:given_course)])
      student.should have(1).given_courses
    end

    it "should have a list of lab groups" do
      group = create(:lab_group)
      create(:student_registered_for_course, lab_groups: [group], student: student)
      student.should have(1).lab_groups
    end

    it "should have a list of labs" do
      student.should have(0).labs
      srfc = Factory.create(:student_registered_for_course, {
        student: student
      })

      lab_group = Factory.create(:lab_group)
      lab = Factory.create(:lab, {
        active: true
      })

      srfc.lab_groups << lab_group

      Factory.create(:lab_has_group, {
        lab: lab,
        lab_group: lab_group
      })

      student.should have(1).labs
    end
  end

  describe "validation" do
    it "should start with a valid student" do
      Factory.build(:student).should be_valid
    end

    it "should have a user" do
      Factory.build(:student, user: nil).should_not be_valid
    end
  end

  describe "#register" do
    it "should register to course" do
      student.register!({
        course: create(:given_course)
      })
<commit_msg>Student spec should respect LabHasGroup#given_courses_match validation [#111]<commit_after>describe Student do
  let(:student) { Factory.create(:student) }
  describe "relations" do
    it "should have a user" do
      student.user.should be_instance_of(User)
    end

    it "should have a list of registered courses" do
      student = create(:student, student_registered_for_courses: [create(:student_registered_for_course)])
      student.should have(1).student_registered_for_courses
    end

    it "should have a list of given courses" do
      student = create(:student, given_courses: [create(:given_course)])
      student.should have(1).given_courses
    end

    it "should have a list of lab groups" do
      group = create(:lab_group)
      create(:student_registered_for_course, lab_groups: [group], student: student)
      student.should have(1).lab_groups
    end

    it "should have a list of labs" do
      student.should have(0).labs
      gc = create(:given_course)
      srfc = Factory.create(:student_registered_for_course, {
        student: student
      })

      lab_group = Factory.create(:lab_group, {
        given_course: gc
      })
      
      lab = Factory.create(:lab, {
        active: true,
        given_course: gc
      })

      srfc.lab_groups << lab_group

      Factory.create(:lab_has_group, {
        lab: lab,
        lab_group: lab_group
      })

      student.should have(1).labs
    end
  end

  describe "validation" do
    it "should start with a valid student" do
      Factory.build(:student).should be_valid
    end

    it "should have a user" do
      Factory.build(:student, user: nil).should_not be_valid
    end
  end

  describe "#register" do
    it "should register to course" do
      student.register!({
        course: create(:given_course)
      })

{'fraction_non_alphanumeric': 0.09164265129682997, 'fraction_numerical': 0.0037463976945244955, 'mean_word_length': 2.8017524644030667, 'pattern_counts': {'":': 0, '<': 7, '<?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': '3073237', 'n_tokens_mistral': 1066, 'n_tokens_neox': 1011, 'n_words': 286}