<commit_before>require 'abstract_unit'

class Category < Struct.new(:id, :name)
end

class FormCollectionsHelperTest < ActionView::TestCase
  def assert_no_select(selector, value = nil)
    assert_select(selector, :text => value, :count => 0)
  end

  def with_collection_radio_buttons(*args, &block)
    @output_buffer = collection_radio_buttons(*args, &block)
  end

  def with_collection_check_boxes(*args, &block)
    @output_buffer = collection_check_boxes(*args, &block)
  end

  # COLLECTION RADIO BUTTONS
  test 'collection radio accepts a collection and generate inputs from value method' do
    with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s

    assert_select 'input[type=radio][value=true]#user_active_true'
    assert_select 'input[type=radio][value=false]#user_active_false'
  end

  test 'collection radio accepts a collection and generate inputs from label method' do
    with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s

    assert_select 'label[for=user_active_true]', 'true'
    assert_select 'label[for=user_active_false]', 'false'
  end<commit_msg>"generates" applies to "collection radio" so it should be singular<commit_after>require 'abstract_unit'

class Category < Struct.new(:id, :name)
end

class FormCollectionsHelperTest < ActionView::TestCase
  def assert_no_select(selector, value = nil)
    assert_select(selector, :text => value, :count => 0)
  end

  def with_collection_radio_buttons(*args, &block)
    @output_buffer = collection_radio_buttons(*args, &block)
  end

  def with_collection_check_boxes(*args, &block)
    @output_buffer = collection_check_boxes(*args, &block)
  end

  # COLLECTION RADIO BUTTONS
  test 'collection radio accepts a collection and generates inputs from value method' do
    with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s

    assert_select 'input[type=radio][value=true]#user_active_true'
    assert_select 'input[type=radio][value=false]#user_active_false'
  end

  test 'collection radio accepts a collection and generates inputs from label method' do
    with_collection_radio_buttons :user, :active, [true, false], :to_s, :to_s

    assert_select 'label[for=user_active_true]', 'true'
    assert_select 'label[for=user_active_false]', 'false'
  end
{'fraction_non_alphanumeric': 0.10100130605137135, 'fraction_numerical': 0.0008707009142359599, 'mean_word_length': 5.839285714285714, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3629134', 'n_tokens_mistral': 724, 'n_tokens_neox': 707, 'n_words': 186}