<commit_before>require 'spec_helper'

describe Guard::Hook do
  before(:all) { class Guard::Dummy < Guard::Guard; end }

  let(:guard_class) { ::Guard::Dummy }
  let(:listener) { double('listener').as_null_object }

  after { described_class.reset_callbacks! }

  after(:all) { ::Guard.instance_eval { remove_const(:Dummy) } }

  describe "--module methods--" do
    before { described_class.add_callback(listener, guard_class, :start_begin) }

    describe ".add_callback" do
      it "can add a single callback" do
        described_class.has_callback?(listener, guard_class, :start_begin).should be_true
      end

      it "can add multiple callbacks" do
        described_class.add_callback(listener, guard_class, [:event1, :event2])
        described_class.has_callback?(listener, guard_class, :event1).should be_true
        described_class.has_callback?(listener, guard_class, :event2).should be_true
      end<commit_msg>Remove const only when defined.<commit_after>require 'spec_helper'

describe Guard::Hook do
  before(:all) { class Guard::Dummy < Guard::Guard; end }

  let(:guard_class) { ::Guard::Dummy }
  let(:listener) { double('listener').as_null_object }

  after { described_class.reset_callbacks! }

  after(:all) { ::Guard.instance_eval { remove_const(:Dummy) if defined?(::Dummy) } }

  describe "--module methods--" do
    before { described_class.add_callback(listener, guard_class, :start_begin) }

    describe ".add_callback" do
      it "can add a single callback" do
        described_class.has_callback?(listener, guard_class, :start_begin).should be_true
      end

      it "can add multiple callbacks" do
        described_class.add_callback(listener, guard_class, [:event1, :event2])
        described_class.has_callback?(listener, guard_class, :event1).should be_true
        described_class.has_callback?(listener, guard_class, :event2).should be_true
      end
{'fraction_non_alphanumeric': 0.11795681937862032, 'fraction_numerical': 0.00421274354923644, 'mean_word_length': 4.337078651685394, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2937557', 'n_tokens_mistral': 580, 'n_tokens_neox': 570, 'n_words': 127}