<commit_before>require 'helper'

describe "Form" do
  before do
    html = <<-EOF
    <form>
      <input name="input_1" value="value_1">
      <input type="text" name="text_input" value="text_input_value">

      <input type="password" name="password_input" value="password">

      <select name="colour">
        <option>red</option>
        <option selected>blue</option>
      </select>

      <select name="countries" multiple>
        <option>france</option>
        <option selected>spain</option>
        <option selected>germany</option>
      </select>

      <textarea name="essay">hello world</textarea>
      <input type="checkbox" name="checkbox_1" value="checkbox_value_1">
      <input type="checkbox" name="checkbox_2" value="checkbox_value_2" checked>

      <input type="radio" name="radio_button_1" value="radio_value_1">
      <input type="radio" name="radio_button_2" value="radio_value_2" checked>

      <input type="submit" value="submit button"></input>
      <input type="reset" value="reset button"></input>
      <input type="button" value="button button"></input>
      <button>button 2</button>
    </form>
    EOF
    @form = CapybaraPageObject::Form.from_string html, 'form'
  end

  context "#buttons" do
    it "return the buttons contained in the form" do
      @form.buttons.size.should == 4
    end
  end

  context "#inputs" do
    it "returns the inputs on the page (excluding buttons)" do
      @form.inputs.keys.should == ["input_1", "text_input", "password_input", "checkbox_1",
        "checkbox_2", "radio_button_1", "radio_button_2"]
    end
  end

  # context "#fields" do
  #   it "return the fields contained in the form - inputs, selects and textareas. Excludes button type inputs (submit, reset, etc.)" do
  #     f = {
  #       'input_1' => 'value_1',
  #       'text_input' => 'text_input_value',
  #       'password_input' => 'password',
  #       'colour' => 'blue',
  #       'essay' => 'hello world',
  #       'checkbox_1' => false,
  #       'checkbox_2' => true,
  #       'radio_button_1' => false,<commit_msg>Adding spec for #textareas, #selects<commit_after>require 'helper'

describe "Form" do
  before do
    html = <<-EOF
    <form>
      <input name="input_1" value="value_1">
      <input type="text" name="text_input" value="text_input_value">

      <input type="password" name="password_input" value="password">

      <select name="colour">
        <option>red</option>
        <option selected>blue</option>
      </select>

      <select name="countries" multiple>
        <option>france</option>
        <option selected>spain</option>
        <option selected>germany</option>
      </select>

      <textarea name="essay">hello world</textarea>
      <input type="checkbox" name="checkbox_1" value="checkbox_value_1">
      <input type="checkbox" name="checkbox_2" value="checkbox_value_2" checked>

      <input type="radio" name="radio_button_1" value="radio_value_1">
      <input type="radio" name="radio_button_2" value="radio_value_2" checked>

      <input type="submit" value="submit button"></input>
      <input type="reset" value="reset button"></input>
      <input type="button" value="button button"></input>
      <button>button 2</button>
    </form>
    EOF
    @form = CapybaraPageObject::Form.from_string html, 'form'
  end

  context "#buttons" do
    it "return the buttons contained in the form" do
      @form.buttons.size.should == 4
    end
  end

  context "#inputs" do
    it "returns the inputs on the page (excluding buttons)" do
      @form.inputs.keys.should == ["input_1", "text_input", "password_input", "checkbox_1",
        "checkbox_2", "radio_button_1", "radio_button_2"]
    end
  end

  context "#textareas" do
    it "returns the textareas on the page" do
      @form.textareas.keys.should == ["essay"]
    end
  end

  context "#selects" do
    it "returns the selects on the page" do
      @form.selects.keys.should == ["colour", "countries"]
    end
  end

  # context "#fields" do
  #   it "return the fields contained in the form - inputs, selects and textareas. Excludes button type inputs (submit, reset, etc.)" do
  #     f = {
  #       'input_1' => 'value_1',
  #       'text_input' => 'text_input_value',
  #       'password_input' => 'password',
  #       'colour' => 'blue',
  #       'essay' => 'hello world',
  #       'checkbox_1' => false,
  #       'checkbox_2' => true,
  #       'radio_button_1' => false,
{'fraction_non_alphanumeric': 0.14629754670267836, 'fraction_numerical': 0.00990321854602746, 'mean_word_length': 3.130111524163569, 'pattern_counts': {'":': 0, '<': 73, '<?xml version=': 0, '>': 85, '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': '3679684', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1393, 'n_words': 350}