<commit_before>require 'rails_helper'

RSpec.describe PersonFormBuilder, type: :form_builder do

  let(:object) { Object.new }
  let(:template) { ActionView::Base.new({}, {}, nil) }
  let(:options) { {} }
  let(:builder) { described_class.new(:person, object, template, options) }

  # patch String#strip_heredoc to remove whitespace resulting from line breaks
  class String
    def squish_heredoc
      squish.gsub(/\s*</, "<").gsub(/>\s*/, ">").strip_heredoc
    end
  end

  describe '#check_box' do
    subject { builder.check_box(:works_monday) }

    before do
      I18n.backend.store_translations(
        :en,
        helpers: {
          label: {
            person: {
              works_monday: 'Monday'
            }
          }
        }
      )
    end

    let(:output) do
      <<~HTML.squish_heredoc
        <div class="form-group">
          <label class="block-label selection-button-checkbox" for="person_works_monday">
            <input name="person[works_monday]" type="hidden" value="0" /><commit_msg>Fix spec<commit_after>require 'rails_helper'

RSpec.describe PersonFormBuilder, type: :form_builder do

  let(:object) { Object.new }
  let(:template) { ActionView::Base.new({}, {}, nil) }
  let(:options) { {} }
  let(:builder) { described_class.new(:person, object, template, options) }

  # patch String#strip_heredoc to remove whitespace resulting from line breaks
  class String
    def squish_heredoc
      squish.gsub(/\s*</, "<").gsub(/>\s*/, ">").strip_heredoc
    end
  end

  describe '#check_box' do
    subject { builder.check_box(:works_monday) }

    before do
      I18n.backend.store_translations(
        :en,
        helpers: {
          label: {
            person: {
              works_monday: 'Monday'
            }
          }
        }
      )
    end

    let(:output) do
      <<~HTML.squish_heredoc
        <div class="form-group">
          <label class="block-label selection-button-checkbox" for="person_works_monday">
            <input name="person[works_monday]" type="hidden" value="0" autocomplete="off" />
{'fraction_non_alphanumeric': 0.1387814313346228, 'fraction_numerical': 0.0029013539651837525, 'mean_word_length': 2.5734024179620034, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 13, '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': '4731505', 'n_tokens_mistral': 680, 'n_tokens_neox': 643, 'n_words': 130}