<commit_before>module Chop
  class Form < Struct.new(:table, :session)
    def self.fill_in! table, session: Capybara.current_session
      new(table, session).fill_in!
    end

    def fill_in!
      table.rows_hash.each do |label, value|
        field = session.find_field(label)
        if field[:type] == "file"
          session.attach_file label, "features/support/fixtures/#{value}"
        else
          session.fill_in label, with: value
        end
      end
    end
  end
end
<commit_msg>teach Chop::Form about select fields.<commit_after>module Chop
  class Form < Struct.new(:table, :session)
    def self.fill_in! table, session: Capybara.current_session
      new(table, session).fill_in!
    end

    def fill_in!
      table.rows_hash.each do |label, value|
        field = session.find_field(label)
        if field.tag_name == "select"
          session.select value, from: label
        elsif field[:type] == "file"
          session.attach_file label, "features/support/fixtures/#{value}"
        else
          session.fill_in label, with: value
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.10009017132551848, 'fraction_numerical': 0.0, 'mean_word_length': 2.4472049689440993, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2591621', 'n_tokens_mistral': 344, 'n_tokens_neox': 341, 'n_words': 87}