<commit_before>require 'rubygems'
require 'bacon'
# require 'test/unit'
# require 'context' #gem install jeremymcanally-context -s http://gems.github.com
# require 'protest'
# def context(*args,&block); Protest.context(*args,&block); end
require 'rr'
# require 'matchy'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'lightning'
#set up valid global config file
Lightning::Config.config_file = File.join(File.dirname(__FILE__), 'lightning.yml')

module Helpers
  def run_command(*args)
    Lightning::Cli.run_command(*args)
  end
  
  def generate(*bolts)
    run_command :generate, bolts
  end

  def assert_arrays_equal(a1, a2)
    assert_equal a1.map {|e| e.to_s}.sort, a2.map{|e| e.to_s}.sort
  end

  def capture_stdout(&block)
    original_stdout = $stdout
    $stdout = fake = StringIO.new
    begin
      yield
    ensure
      $stdout = original_stdout
    end
    fake.string
  end

  # from ActiveSupport
  def slice_hash(*keys)
    keys.shift.reject { |key,| !keys.include?(key) }
  end
end

class Bacon::Context
  include Helpers

  include RR::Adapters::RRMethods
  RR.trim_backtrace = true
  alias_method :old_it, :it
	def it(description)
		old_it(description) do
			RR.reset
			yield
			RR.verify
		end
	end

  def before_all
    yield
  end
  alias_method :test, :it
  alias_method :context, :describe
  def assert(description, &block)
    it(description) do
      block.call.should == true
    end
  end
end

class <<self
  alias_method :context, :describe
end

__END__
class Object
  def should(expectation)
    expectation.match?(self)
  end
end<commit_msg>finished making bacon RR compatible<commit_after>require 'rubygems'
require 'bacon'
# require 'test/unit'
# require 'context' #gem install jeremymcanally-context -s http://gems.github.com
# require 'protest'
# def context(*args,&block); Protest.context(*args,&block); end
require 'rr'
# require 'matchy'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'lightning'
#set up valid global config file
Lightning::Config.config_file = File.join(File.dirname(__FILE__), 'lightning.yml')

module Helpers
  def run_command(*args)
    Lightning::Cli.run_command(*args)
  end
  
  def generate(*bolts)
    run_command :generate, bolts
  end

  def assert_arrays_equal(a1, a2)
    assert_equal a1.map {|e| e.to_s}.sort, a2.map{|e| e.to_s}.sort
  end

  def capture_stdout(&block)
    original_stdout = $stdout
    $stdout = fake = StringIO.new
    begin
      yield
    ensure
      $stdout = original_stdout
    end
    fake.string
  end

  # from ActiveSupport
  def slice_hash(*keys)
    keys.shift.reject { |key,| !keys.include?(key) }
  end
end

class Bacon::Context
  include Helpers

  include RR::Adapters::RRMethods
  RR.trim_backtrace = true
  alias_method :old_it, :it
	def it(description)
		old_it(description) do
			RR.reset
			# Add at least one requirement to ensure mock-only tests don't fail
			Bacon::Counter[:requirements] += 1
			yield
			Bacon::Counter[:requirements] -= 1 if RR.double_injections.size.zero?
			RR.verify
		end
	end

  def before_all
    yield
  end
  alias_method :test, :it
  alias_method :context, :describe
  def assert(description, &block)
    it(description) do
      block.call.should == true
    end
  end
end

class <<self
  alias_method :context, :describe
end

__END__
class Object
  def should(expectation)
    expectation.match?(self)
  end
end
{'fraction_non_alphanumeric': 0.11335676625659051, 'fraction_numerical': 0.0029291154071470417, 'mean_word_length': 3.8166431593794075, 'pattern_counts': {'":': 0, '<': 7, '<?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': '6302104', 'n_tokens_mistral': 1218, 'n_tokens_neox': 1159, 'n_words': 292}