<commit_before>require File.expand_path('../test_helper', File.dirname(__FILE__))

class BaseTest < Test::Unit::TestCase
  
  should "start should enable coverage" do
    coverband = Coverband::Base.new
    assert_equal false, coverband.instance_variable_get("@enabled")
    coverband.expects(:record_coverage).once
    coverband.start
    assert_equal true, coverband.instance_variable_get("@enabled")
  end
  
  should "stop should disable coverage" do
    coverband = Coverband::Base.new
    assert_equal false, coverband.instance_variable_get("@enabled")
    coverband.expects(:record_coverage).once
    coverband.start
    assert_equal true, coverband.instance_variable_get("@enabled")
    coverband.stop
    assert_equal false, coverband.instance_variable_get("@enabled")
    assert_equal false, coverband.instance_variable_get("@tracer_set")
  end
  
  should "allow for sampling with a block and enable when 100 percent sample" do
    coverband = Coverband::Base.new
    coverband.instance_variable_set("@sample_percentage", 100.0)
    coverband.instance_variable_set("@verbose", true)
    coverband.instance_variable_set("@reporter", nil)
    assert_equal false, coverband.instance_variable_get("@enabled")
    coverband.expects(:puts).at_least_once
    coverband.sample { 1 + 1 }
    assert_equal true, coverband.instance_variable_get("@enabled")
  end
  
  should "allow reporting with start stop save" do
    coverband = Coverband::Base.new
    coverband.instance_variable_set("@sample_percentage", 100.0)
    coverband.instance_variable_set("@verbose", true)
    coverband.instance_variable_set("@reporter", nil)
    assert_equal false, coverband.instance_variable_get("@enabled")
    coverband.expects(:puts).at_least_once
    coverband.start
    1 + 1
    coverband.stop
    coverband.save
  end
  
  should "allow reporting to redis start stop save" do
    coverband = Coverband::Base.new
    coverband.instance_variable_set("@sample_percentage", 100.0)
    coverband.instance_variable_set("@verbose", true)
    store = Coverband::RedisStore.new(Redis.new)
    coverband.instance_variable_set("@reporter", store)
    store.expects(:store_report).once.with { |files|
      files.keys.include?("#{File.expand_path('../../../', __FILE__)}/lib/coverband/base.rb")
    }
    assert_equal false, coverband.instance_variable_get("@enabled")
    coverband.start
    1 + 1
    coverband.stop
    coverband.save
  end

end
<commit_msg>fix broken tests<commit_after>require File.expand_path('../test_helper', File.dirname(__FILE__))

class BaseTest < Test::Unit::TestCase

  should "start should enable coverage" do
    coverband = Coverband::Base.new
    assert_equal false, coverband.instance_variable_get("@enabled")
    coverband.expects(:record_coverage).once
    coverband.start
    assert_equal true, coverband.instance_variable_get("@enabled")
  end
  
  should "stop should disable coverage" do
    coverband = Coverband::Base.new
    assert_equal false, coverband.instance_variable_get("@enabled")
    coverband.expects(:record_coverage).once
    coverband.start
    assert_equal true, coverband.instance_variable_get("@enabled")
    coverband.stop
    assert_equal false, coverband.instance_variable_get("@enabled")
    assert_equal false, coverband.instance_variable_get("@tracer_set")
  end
  
  should "allow for sampling with a block and enable when 100 percent sample" do
    logger = Logger.new(STDOUT)
    coverband = Coverband::Base.new
    coverband.instance_variable_set("@sample_percentage", 100.0)
    coverband.instance_variable_set("@verbose", true)
    coverband.instance_variable_set("@logger", logger)
    coverband.instance_variable_set("@reporter", nil)
    assert_equal false, coverband.instance_variable_get("@enabled")
    logger.expects(:info).at_least_once
    coverband.sample { 1 + 1 }
    assert_equal true, coverband.instance_variable_get("@enabled")
  end
  
  should "allow reporting with start stop save" do
    logger = Logger.new(STDOUT)
    coverband = Coverband::Base.new
    coverband.instance_variable_set("@sample_percentage", 100.0)
    coverband.instance_variable_set("@verbose", true)
    coverband.instance_variable_set("@logger", logger)
    coverband.instance_variable_set("@reporter", nil)
    assert_equal false, coverband.instance_variable_get("@enabled")
    logger.expects(:info).at_least_once
    coverband.start
    1 + 1
    coverband.stop
    coverband.save
  end
  
  should "allow reporting to redis start stop save" do
    coverband = Coverband::Base.new
    coverband.instance_variable_set("@sample_percentage", 100.0)
    coverband.instance_variable_set("@verbose", true)
    store = Coverband::RedisStore.new(Redis.new)
    coverband.instance_variable_set("@reporter", store)
    store.expects(:store_report).once.with { |files|
      files.keys.include?("#{File.expand_path('../../../', __FILE__)}/lib/coverband/base.rb")
    }
    assert_equal false, coverband.instance_variable_get("@enabled")
    coverband.start
    1 + 1
    coverband.stop
    coverband.save
  end

end

{'fraction_non_alphanumeric': 0.11007721243318155, 'fraction_numerical': 0.008315185111859039, 'mean_word_length': 4.557755775577558, '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': '3478120', 'n_tokens_mistral': 1586, 'n_tokens_neox': 1546, 'n_words': 288}