<commit_before>begin
  require 'rack'
rescue LoadError
  require 'rubygems'
  require 'rack'
end

libdir = File.dirname(File.dirname(__FILE__)) + '/lib'
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)

require 'sinatra/base'
require 'sinatra/test/unit'

module Sinatra::Test
  # Sets up a Sinatra::Base subclass defined with the block
  # given. Used in setup or individual spec methods to establish
  # the application.
  def mock_app(base=Sinatra::Base, &block)
    @app = Sinatra.new(base, &block)
  end
end

class Sinatra::Base
  # Allow assertions in request context
  include Test::Unit::Assertions
end

##
# test/spec/mini
# http://pastie.caboo.se/158871
# <EMAIL>
#
def describe(*args, &block)
  return super unless (name = args.first) && block
  name = "#{name.gsub(/\W/, '')}Test"
  Object.send :const_set, name, Class.new(Test::Unit::TestCase)
  klass = Object.const_get(name)
  klass.class_eval do
    def self.it(name, &block)
      define_method("test_#{name.gsub(/\W/,'_').downcase}", &block)
    end
    def self.xspecify(*args) end
    def self.before(&block) define_method(:setup, &block)    end
    def self.after(&block)  define_method(:teardown, &block) end
  end
  klass.class_eval &block
end<commit_msg>Don't depend on sinatra/test/unit in internal test<commit_after>begin
  require 'rack'
rescue LoadError
  require 'rubygems'
  require 'rack'
end

libdir = File.dirname(File.dirname(__FILE__)) + '/lib'
$LOAD_PATH.unshift libdir unless $LOAD_PATH.include?(libdir)

require 'test/unit'
require 'sinatra/test'

Sinatra::Default.set(
  :environment => :test,
  :run => false,
  :raise_errors => true,
  :logging => false
)

class Sinatra::Base
  # Allow assertions in request context
  include Test::Unit::Assertions
end

class Test::Unit::TestCase
  include Sinatra::Test

  # Sets up a Sinatra::Base subclass defined with the block
  # given. Used in setup or individual spec methods to establish
  # the application.
  def mock_app(base=Sinatra::Base, &block)
    @app = Sinatra.new(base, &block)
  end
end

##
# test/spec/mini
# http://pastie.caboo.se/158871
# <EMAIL>
#
def describe(*args, &block)
  return super unless (name = args.first) && block
  name = "#{name.gsub(/\W/, '')}Test"
  Object.send :const_set, name, Class.new(Test::Unit::TestCase)
  klass = Object.const_get(name)
  klass.class_eval do
    def self.it(name, &block)
      define_method("test_#{name.gsub(/\W/,'_').downcase}", &block)
    end
    def self.xspecify(*args) end
    def self.before(&block) define_method(:setup, &block)    end
    def self.after(&block)  define_method(:teardown, &block) end
  end
  klass.class_eval &block
end
{'fraction_non_alphanumeric': 0.13849056603773585, 'fraction_numerical': 0.004528301886792453, 'mean_word_length': 4.270377733598409, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4068002', 'n_tokens_mistral': 936, 'n_tokens_neox': 922, 'n_words': 232}