<commit_before>RSpec.describe Errorgutan::Aliases do
  let(:exception_class) { FakeException }
  let(:aliased_exception_class) { AliasedException }

  describe "instance" do
    describe "#bind" do
      context "when correct arguments" do
        it "creates an alias" do
          expect { subject.bind(exception_class, with: aliased_exception_class) }
            .to change { subject[exception_class] }
              .from(nil)
              .to(aliased_exception_class)
        end
      end

      context "when wrong arguments" do
        context "when `exception` and alias `with:` are `nil` or not provided" do
          it "raises an exception" do
            expect { subject.bind(nil, with: nil) }.to raise_error(ArgumentError)
            expect { subject.bind }.to raise_error(ArgumentError)
          end
        end

        context "when `exception` is `nil` or not provided" do
          it "raises an exception" do
            expect { subject.bind(nil, with: aliased_exception_class) }.to raise_error(ArgumentError)
            expect { subject.bind(with: aliased_exception_class) }.to raise_error(ArgumentError)
          end
        end

        context "when alias `with:` is `nil` or not provided" do
          it "raises an exception" do
            expect { subject.bind(exception_class, with: nil) }.to raise_error(ArgumentError)
            expect { subject.bind(exception_class) }.to raise_error(ArgumentError)
          end
        end
      end
    end

    describe "#[]" do
      context "when correct arguments" do
        context "when has alias" do
          it "returns an alias" do
            subject.bind exception_class, with: aliased_exception_class

            expect(subject[exception_class]).to be aliased_exception_class
          end
        end

        context "when has no alias" do
          it "returns `nil`" do
            expect(subject[exception_class]).to be_nil
          end
        end
      end

      context "when wrong arguments" do
        context "when `exception` is `nil` or not provided" do
          it "raises an exception" do
            expect { subject[nil] }.to raise_error(ArgumentError)
            expect { subject[] }.to raise_error(ArgumentError)
          end
        end
      end
    end
  end
end<commit_msg>specs: Aliases 100% coverage with Mutant<commit_after>RSpec.describe Errorgutan::Aliases do
  let(:exception_class) { FakeException }
  let(:aliased_exception_class) { AliasedException }

  describe "instance" do
    describe "#bind" do
      context "when correct arguments" do
        it "creates an alias" do
          expect { subject.bind(exception_class, with: aliased_exception_class) }
            .to change { subject[exception_class] }
              .from(nil)
              .to(aliased_exception_class)
        end
      end

      context "when wrong arguments" do
        context "when `exception_classes` and alias `with:` are `nil`, not provided or not exception classes" do
          it "raises ArgumentError" do
            expect { subject.bind(nil, with: nil) }.to raise_error(ArgumentError)
            expect { subject.bind }.to raise_error(ArgumentError)
            expect { subject.bind(Class.new, with: Class.new) }.to raise_error(ArgumentError)
          end
        end

        context "when `exception_classes` is `nil`, not provided or not exception class" do
          it "raises ArgumentError" do
            expect { subject.bind(nil, with: aliased_exception_class) }.to raise_error(ArgumentError)
            expect { subject.bind(with: aliased_exception_class) }.to raise_error(ArgumentError)
            expect { subject.bind(Class.new, with: aliased_exception_class) }.to raise_error(ArgumentError)
          end
        end

        context "when alias `with:` is `nil`, not provided or not exception class" do
          it "raises an exception" do
            expect { subject.bind(exception_class, with: nil) }.to raise_error(ArgumentError)
            expect { subject.bind(exception_class) }.to raise_error(ArgumentError)
            expect { subject.bind(exception_class, with: Class.new) }.to raise_error(ArgumentError)
          end
        end

        context "when `exception_classes` contains `nil`s" do
          it "raises ArgumentError" do
            expect { subject.bind nil, exception_class, with: aliased_exception_class }.to raise_error(ArgumentError)
          end
        end

        context "when `exception_classes` contains objects which aren't Exceptions" do
          it "raises ArgumentError" do
            expect { subject.bind Class.new, exception_class, with: aliased_exception_class }.to raise_error(ArgumentError)
          end
        end

        context "when `exception_classes` is empty" do
          it "raises ArgumentError" do
            expect { subject.bind *[], with: aliased_exception_class }.to raise_error(ArgumentError)
          end
        end
      end
    end

    describe "#[]" do
      context "when correct arguments" do
        context "when has alias" do
          it "returns an alias" do
            subject.bind exception_class, with: aliased_exception_class

            expect(subject[exception_class]).to be aliased_exception_class
          end
        end

        context "when has no alias" do
          it "returns `nil`" do
            expect(subject[exception_class]).to be_nil
          end
        end
      end

      context "when wrong arguments" do
        context "when `exception` is `nil`, not provided or not an exception class" do
          it "raises ArgumentError" do
            expect { subject[nil] }.to raise_error(ArgumentError)
            expect { subject[] }.to raise_error(ArgumentError)
            expect { subject[Class.new] }.to raise_error(ArgumentError)
          end
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07859589041095891, 'fraction_numerical': 0.0005136986301369863, 'mean_word_length': 2.279618192026951, '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': '6774236', 'n_tokens_mistral': 1573, 'n_tokens_neox': 1547, 'n_words': 493}