<commit_before>require 'draper/test/view_context'

module MiniTest
  class Spec
    class Decorator < Spec
      before { Draper::ViewContext.infect!(self) }
    end
  end
end

class MiniTest::Unit::DecoratorTestCase < MiniTest::Unit::TestCase
  add_setup_hook { Draper::ViewContext.infect!(self) }
end

MiniTest::Spec.register_spec_type(MiniTest::Spec::Decorator) do |desc|
  desc.superclass == Draper::Base
end<commit_msg>Use the before_setup hook when it is available.<commit_after>require 'draper/test/view_context'

module MiniTest
  class Spec
    class Decorator < Spec
      before { Draper::ViewContext.infect!(self) }
    end
  end
end

class MiniTest::Unit::DecoratorTestCase < MiniTest::Unit::TestCase
  if method_defined?(:before_setup)
    # for minitext >= 2.11
    def before_setup
      super
      Draper::ViewContext.infect!(self)
    end
  else
    # for older minitest, like what ships w/Ruby 1.9
    add_setup_hook { Draper::ViewContext.infect!(self) }
  end
end

MiniTest::Spec.register_spec_type(MiniTest::Spec::Decorator) do |desc|
  desc.superclass == Draper::Base
end
{'fraction_non_alphanumeric': 0.10694698354661791, 'fraction_numerical': 0.004570383912248629, 'mean_word_length': 4.53030303030303, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 4, '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': '2543258', 'n_tokens_mistral': 380, 'n_tokens_neox': 361, 'n_words': 78}