<commit_before>And(/^I have (\d+) courses to search$/) do |num_classes|
  num_classes.to_i.times do
    FactoryGirl.create(:course, :with_course_instance)
  end
end

Given(/^The course ([A-Z]+) (\d+) exists$/) do |department, course_number|
  Course.exists?(department: department, course_number: course_number) ||
    FactoryGirl.create(:course, :with_course_instance,
                       department: department, course_number: course_number)
end

When(/^I search for a professor$/) do
  # Grab the first professor or course
  @professor = Professor.first
  fill_in 'professor', with: @professor.name
  click_button 'Search'
end

Then(/^I only see courses taught by that professor$/) do
  # Collect all classes returned
  page.all('#results tr').each do |row|
    course_data = row.all('td').first.text
    dept, num = course_data.split ' '
    professors = Course.includes(course_instances: :professor)
                       .find_by(department: dept, course_number: num)
                       .professors
    names = professors.map(&:name)
    expect(names.any? {|name| name.start_with?(@professor.name)}).to be true<commit_msg>Make expectation more conventional rspec style<commit_after>And(/^I have (\d+) courses to search$/) do |num_classes|
  num_classes.to_i.times do
    FactoryGirl.create(:course, :with_course_instance)
  end
end

Given(/^The course ([A-Z]+) (\d+) exists$/) do |department, course_number|
  Course.exists?(department: department, course_number: course_number) ||
    FactoryGirl.create(:course, :with_course_instance,
                       department: department, course_number: course_number)
end

When(/^I search for a professor$/) do
  # Grab the first professor or course
  @professor = Professor.first
  fill_in 'professor', with: @professor.name
  click_button 'Search'
end

Then(/^I only see courses taught by that professor$/) do
  # Collect all classes returned
  page.all('#results tr').each do |row|
    course_data = row.all('td').first.text
    dept, num = course_data.split ' '
    professors = Course.includes(course_instances: :professor)
                       .find_by(department: dept, course_number: num)
                       .professors
    names = professors.map(&:name)
    expect(names).to include(start_with(@professor.name))
{'fraction_non_alphanumeric': 0.1216097987751531, 'fraction_numerical': 0.0, 'mean_word_length': 3.564870259481038, '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': '2488999', 'n_tokens_mistral': 723, 'n_tokens_neox': 692, 'n_words': 183}