<commit_before>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'log_switch/mixin'


class Tester
end


describe LogSwitch::Mixin do
  describe ".included" do
    context "LogSwitch.extender is set" do
      let!(:logger_class) { double "LogSwitch.logger" }

      before do
        LogSwitch.stub(:extender).and_return logger_class
      end

      it "takes a class and defines the #log method on it" do
        Tester.should_receive(:send).with(:define_method, :log)

        class Tester
          include LogSwitch::Mixin
        end
      end

      it "results in an object with a #log message" do
        class Tester
          include LogSwitch::Mixin
        end

        Tester.new.methods.should include(:log)
      end

      context "LogSwitch.extender.log_class_name? is true" do
        before do
          LogSwitch.unstub(:extender)
        end

        context "just a log message passed to logger" do
          it "adds the class name to the log message" do
            class Tester
              extend LogSwitch
              include LogSwitch::Mixin
              def meow; log "hi"; end
            end<commit_msg>Fix for 1.8.x method checking<commit_after>require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
require 'log_switch/mixin'


class Tester
end


describe LogSwitch::Mixin do
  describe ".included" do
    context "LogSwitch.extender is set" do
      let!(:logger_class) { double "LogSwitch.logger" }

      before do
        LogSwitch.stub(:extender).and_return logger_class
      end

      it "takes a class and defines the #log method on it" do
        Tester.should_receive(:send).with(:define_method, :log)

        class Tester
          include LogSwitch::Mixin
        end
      end

      it "results in an object with a #log message" do
        class Tester
          include LogSwitch::Mixin
        end

        if RUBY_VERSION < "1.9"
          Tester.new.methods.should include("log")
        else
          Tester.new.methods.should include(:log)
        end
      end

      context "LogSwitch.extender.log_class_name? is true" do
        before do
          LogSwitch.unstub(:extender)
        end

        context "just a log message passed to logger" do
          it "adds the class name to the log message" do
            class Tester
              extend LogSwitch
              include LogSwitch::Mixin
              def meow; log "hi"; end
            end
{'fraction_non_alphanumeric': 0.07526444263628966, 'fraction_numerical': 0.0016273393002441008, 'mean_word_length': 2.032059186189889, 'pattern_counts': {'":': 0, '<': 4, '<?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': '4014010', 'n_tokens_mistral': 704, 'n_tokens_neox': 681, 'n_words': 220}