<commit_before>require "label/summary_extractor"

describe Label::SummaryExtractor do

  describe "#extract_summary" do
    # TODO: use contexts
    context "for double quoted strings containing single quoted strings" do
      it "should extract summary" do
        content = "s.email       = [\"<EMAIL>\"]\n  s.homepage    = \"fespinoza.github.io\"\n  s.summary     = \"A series of generators an other rails 'defaults' for my projects\"\n  s.description = \"TODO.\"\n  s.license     = \"MIT\"\n\n"
        extractor = Label::SummaryExtractor.new(content)
        expect(extractor.extract_summary).to eq "A series of generators an other rails 'defaults' for my projects"
      end
    end

    context "for single quoted strings containing double quoted strings" do
      it "should extract summary" do
        content = "s.email       = [\"<EMAIL>\"]\n  s.homepage    = \"fespinoza.github.io\"\n  s.summary     = 'A series of generators an other rails \"defaults\" for my projects'\n  s.description = \"TODO.\"\n  s.license     = \"MIT\"\n\n"
        extractor = Label::SummaryExtractor.new(content)
        expect(extractor.extract_summary).to eq "A series of generators an other rails \"defaults\" for my projects"
      end
    end

    context "for strings defined with %q{}" do
      it "should extract summary" do
        content = "s.email       = [\"<EMAIL>\"]\n  s.homepage    = \"fespinoza.github.io\"\n  s.summary     = %q{A series of generators an other rails \"defaults\" for my 'projects'}\n  s.description = \"TODO.\"\n  s.license     = \"MIT\"\n\n"
        extractor = Label::SummaryExtractor.new(content)
        expect(extractor.extract_summary).to eq "A series of generators an other rails \"defaults\" for my 'projects'"
      end
    end

    context "for different gem configuration variable names" do
      it "should extract summary" do
        content = "g.email       = [\"<EMAIL>\"]\n  g.homepage    = \"fespinoza.github.io\"\n  g.summary     = %q{A series of generators an other rails \"defaults\" for my 'projects'}\n  g.description = \"TODO.\"\n  g.license     = \"MIT\"\n\n"
        extractor = Label::SummaryExtractor.new(content)
        expect(extractor.extract_summary).to eq "A series of generators an other rails \"defaults\" for my 'projects'"
      end
    end

  end
end<commit_msg>use shared example for common spec<commit_after>require "label/summary_extractor"

shared_examples "extracts summary" do |expected_summary|
  it "should extract summary" do
    extractor = Label::SummaryExtractor.new(content)
    expect(extractor.extract_summary).to eq expected_summary
  end
end

describe Label::SummaryExtractor do

  describe "#extract_summary" do
    context "for double quoted strings containing single quoted strings" do
      let(:content) { "s.email       = [\"<EMAIL>\"]\n  s.homepage    = \"fespinoza.github.io\"\n  s.summary     = \"A series of generators an other rails 'defaults' for my projects\"\n  s.description = \"TODO.\"\n  s.license     = \"MIT\"\n\n" }

      include_examples "extracts summary", "A series of generators an other rails 'defaults' for my projects"
    end

    context "for single quoted strings containing double quoted strings" do
      let(:content) { "s.email       = [\"<EMAIL>\"]\n  s.homepage    = \"fespinoza.github.io\"\n  s.summary     = 'A series of generators an other rails \"defaults\" for my projects'\n  s.description = \"TODO.\"\n  s.license     = \"MIT\"\n\n" }

      include_examples "extracts summary", "A series of generators an other rails \"defaults\" for my projects"
    end

    context "for strings defined with %q{}" do
      let(:content) { "s.email       = [\"<EMAIL>\"]\n  s.homepage    = \"fespinoza.github.io\"\n  s.summary     = %q{A series of generators an other rails \"defaults\" for my 'projects'}\n  s.description = \"TODO.\"\n  s.license     = \"MIT\"\n\n" }

      include_examples "extracts summary", "A series of generators an other rails \"defaults\" for my 'projects'"
    end

    context "for different gem configuration variable names" do
      let(:content) { "g.email       = [\"<EMAIL>\"]\n  g.homepage    = \"fespinoza.github.io\"\n  g.summary     = %q{A series of generators an other rails \"defaults\" for my 'projects'}\n  g.description = \"TODO.\"\n  g.license     = \"MIT\"\n\n" }

      include_examples "extracts summary", "A series of generators an other rails \"defaults\" for my 'projects'"
    end

  end
end
{'fraction_non_alphanumeric': 0.13171499213306362, 'fraction_numerical': 0.0, 'mean_word_length': 2.79045996592845, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3382023', 'n_tokens_mistral': 1384, 'n_tokens_neox': 1317, 'n_words': 430}