<commit_before>require "test_helper"

class AbTestController < ActionController::Base
  use_vanity :current_user
  attr_accessor :current_user

  def test_render
    render :text=>ab_test(:simple)
  end

  def test_view
    render :inline=>"<%= ab_test(:simple) %>"
  end

  def test_capture
    if defined?(Rails::Railtie)
      render :inline=>"<%= ab_test :simple do |value| %><%= value %><% end %>"
    else
      render :inline=>"<% ab_test :simple do |value| %><%= value %><% end %>"
    end
  end

  def track
    track! :coolness
    render :text=>""
  end
end


class AbTestTest < ActionController::TestCase
  tests AbTestController

  def setup
    super
    metric "Coolness"
  end

  def teardown
    super
    if RUBY_VERSION == '1.8.7'
      GC.enable
      GC.start
      GC.disable
    end
  end

  # --  Experiment definition --

  def test_requires_at_least_two_alternatives_per_experiment
    assert_raises RuntimeError do
      new_ab_test :none do
        alternatives []<commit_msg>Remove GC fiddling from tests.<commit_after>require "test_helper"

class AbTestController < ActionController::Base
  use_vanity :current_user
  attr_accessor :current_user

  def test_render
    render :text=>ab_test(:simple)
  end

  def test_view
    render :inline=>"<%= ab_test(:simple) %>"
  end

  def test_capture
    if defined?(Rails::Railtie)
      render :inline=>"<%= ab_test :simple do |value| %><%= value %><% end %>"
    else
      render :inline=>"<% ab_test :simple do |value| %><%= value %><% end %>"
    end
  end

  def track
    track! :coolness
    render :text=>""
  end
end


class AbTestTest < ActionController::TestCase
  tests AbTestController

  def setup
    super
    metric "Coolness"
  end

  # --  Experiment definition --

  def test_requires_at_least_two_alternatives_per_experiment
    assert_raises RuntimeError do
      new_ab_test :none do
        alternatives []
{'fraction_non_alphanumeric': 0.10703043022035677, 'fraction_numerical': 0.0015739769150052466, 'mean_word_length': 3.2377777777777776, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 27, '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': '7629395', 'n_tokens_mistral': 656, 'n_tokens_neox': 619, 'n_words': 161}