<commit_before>describe Putter do
  it 'has a version number' do
    expect(Putter::VERSION).not_to be nil
  end

  shared_examples "follow" do
    describe "#follow" do
      it "creates a follower for the object" do
        follower = get_follower(subject)

        expect(follower.object).to eq(subject)
      end

      it "creates a method proxy" do
        follower = Putter.follow(subject)

        expect(subject.singleton_class.ancestors.first).to be_an_instance_of(Putter::MethodProxy)
      end

      it "accepts specific methods" do
        Putter.configuration.method_strategy = Putter::PrintStrategy::MethodTesting
        follower = Putter.follow(subject, methods: [:test_method_arg])

        expect do
          follower.test_method_arg("World")
        end.to output(/Method: :test_method_arg, Args: \["World"\]/).to_stdout
      end

      it "ignores unspecified methods" do
        Putter.configuration.method_strategy = Putter::PrintStrategy::MethodTesting
        follower = Putter.follow(subject, methods: [:test_method])

        expect do
          follower.test_method_arg("World")
        end.to_not output(/:test_method_arg/).to_stdout
      end

      it "prints debugging info for method calls" do
        Putter.configuration.method_strategy = Putter::PrintStrategy::MethodTesting
        follower = Putter.follow(subject)

        expect do
          follower.test_method
          follower.test_method_arg("World")
        end.to output(/Method: :test_method, Args: \[\]\nMethod: :test_method_arg, Args: \["World"\]/m).to_stdout
      end

      it "prints the debugging info for results" do
        Putter.configure do |config|
          config.result_strategy = Putter::PrintStrategy::ResultTesting
          config.print_results = true
        end
        follower = Putter.follow(subject)

        expect do
          follower.test_method
        end.to output(/Result: Hello World!/).to_stdout
      end

      it "does not print debugging info if print results is false" do
        Putter.configure do |config|
          config.result_strategy = Putter::PrintStrategy::ResultTesting
          config.print_results = false
        end
        follower = Putter.follow(subject)

        expect do
          follower.test_method
        end.to_not output(/Result: Hello World!/).to_stdout
      end

      it "prints the label option if it is present" do
        Putter.configuration.method_strategy = Putter::PrintStrategy::MethodStrategy
        follower = Putter.follow(subject, label: "custom label")

        expect do
          follower.test_method
        end.to output(/Putter Debugging:.*custom label/).to_stdout
      end
    end
  end


  describe "#follow" do
    context "instances" do
      subject { Test.new }

      include_examples "follow"
    end

    context "classes" do
      subject do
        Class.new do
          def self.test_method
            "Hello World!"
          end

          def self.test_method_arg(arg)
            "Hello #{arg}!"
          end

          def self.test_method_block(&blk)<commit_msg>Add missing spec for newline before debugging information<commit_after>describe Putter do
  it 'has a version number' do
    expect(Putter::VERSION).not_to be nil
  end

  shared_examples "follow" do
    describe "#follow" do
      it "creates a follower for the object" do
        follower = get_follower(subject)

        expect(follower.object).to eq(subject)
      end

      it "creates a method proxy" do
        follower = Putter.follow(subject)

        expect(subject.singleton_class.ancestors.first).to be_an_instance_of(Putter::MethodProxy)
      end

      it "accepts specific methods" do
        Putter.configuration.method_strategy = Putter::PrintStrategy::MethodTesting
        follower = Putter.follow(subject, methods: [:test_method_arg])

        expect do
          follower.test_method_arg("World")
        end.to output(/Method: :test_method_arg, Args: \["World"\]/).to_stdout
      end

      it "ignores unspecified methods" do
        Putter.configuration.method_strategy = Putter::PrintStrategy::MethodTesting
        follower = Putter.follow(subject, methods: [:test_method])

        expect do
          follower.test_method_arg("World")
        end.to_not output(/:test_method_arg/).to_stdout
      end

      it "prints debugging info for method calls" do
        Putter.configuration.method_strategy = Putter::PrintStrategy::MethodTesting
        follower = Putter.follow(subject)

        expect do
          follower.test_method
          follower.test_method_arg("World")
        end.to output(/Method: :test_method, Args: \[\]\nMethod: :test_method_arg, Args: \["World"\]/m).to_stdout
      end

      it "prints the debugging info for results" do
        Putter.configure do |config|
          config.result_strategy = Putter::PrintStrategy::ResultTesting
          config.print_results = true
        end
        follower = Putter.follow(subject)

        expect do
          follower.test_method
        end.to output(/Result: Hello World!/).to_stdout
      end

      it "does not print debugging info if print results is false" do
        Putter.configure do |config|
          config.result_strategy = Putter::PrintStrategy::ResultTesting
          config.print_results = false
        end
        follower = Putter.follow(subject)

        expect do
          follower.test_method
        end.to_not output(/Result: Hello World!/).to_stdout
      end

      it "prints the label option if it is present" do
        Putter.configuration.method_strategy = Putter::PrintStrategy::MethodStrategy
        follower = Putter.follow(subject, label: "custom label")

        expect do
          follower.test_method
        end.to output(/\n.*Putter Debugging:.*custom label/).to_stdout
      end
    end
  end


  describe "#follow" do
    context "instances" do
      subject { Test.new }

      include_examples "follow"
    end

    context "classes" do
      subject do
        Class.new do
          def self.test_method
            "Hello World!"
          end

          def self.test_method_arg(arg)
            "Hello #{arg}!"
          end

          def self.test_method_block(&blk)
{'fraction_non_alphanumeric': 0.08556235900741219, 'fraction_numerical': 0.0, 'mean_word_length': 2.3955142231947484, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3784494', 'n_tokens_mistral': 1813, 'n_tokens_neox': 1718, 'n_words': 442}