<commit_before>require "spec_helper"

module Guideline
  describe HashCommaChecker do
    describe "#check" do
      subject do
        checker.check(path)
        checker
      end

      let(:checker) do
        described_class.new
      end

      let(:path) do
        mock(:read => content)
      end

      context "when there is no last comma in sigleline hash" do
        let(:content) do
          <<-EOF
            { :a => 1 }
          EOF
        end

        specify "checker does not detect error" do
          should_not have_error
        end
      end

      context "when there is last comma in sigleline hash" do
        let(:content) do
          <<-EOF
            { :a => 1, }
          EOF
        end

        specify "checker does not detect error" do
          should_not have_error
        end
      end

      context "when there is no last comma in multiline hash" do
        let(:content) do
          <<-EOF
            {
              :a => 1
            }
          EOF
        end

        specify "checker detects error" do
          should have_error
        end
      end

      context "when there is no last comma in multiline hash with array" do
        let(:content) do
          <<-EOF
            {
              :a => [1, 2, 3]
            }
          EOF
        end

        specify "checker detects error" do
          should have_error
        end
      end

      context "when there is last comma in multiline hash" do
        let(:content) do
          <<-EOF
            {
              :a => 1,
            }
          EOF
        end

        specify "checker does not detect error" do
          should_not have_error
        end
      end

      context "when there is no last comma in multiline nested hash" do
        let(:content) do
          <<-EOF
            {
              :a => {
                :b => 1,
              }
            }
          EOF
        end

        specify "checker detects error" do
          should have_error
        end
      end
    end
  end
end<commit_msg>Replace the word of content with a word script<commit_after>require "spec_helper"

module Guideline
  describe HashCommaChecker do
    describe "#check" do
      subject do
        checker.check(path)
        checker
      end

      let(:checker) do
        described_class.new
      end

      let(:path) do
        mock(:read => script)
      end

      context "when there is no last comma in sigleline hash" do
        let(:script) do
          <<-EOF
            { :a => 1 }
          EOF
        end

        specify "checker does not detect error" do
          should_not have_error
        end
      end

      context "when there is last comma in sigleline hash" do
        let(:script) do
          <<-EOF
            { :a => 1, }
          EOF
        end

        specify "checker does not detect error" do
          should_not have_error
        end
      end

      context "when there is no last comma in multiline hash" do
        let(:script) do
          <<-EOF
            {
              :a => 1
            }
          EOF
        end

        specify "checker detects error" do
          should have_error
        end
      end

      context "when there is no last comma in multiline hash with array" do
        let(:script) do
          <<-EOF
            {
              :a => [1, 2, 3]
            }
          EOF
        end

        specify "checker detects error" do
          should have_error
        end
      end

      context "when there is last comma in multiline hash" do
        let(:script) do
          <<-EOF
            {
              :a => 1,
            }
          EOF
        end

        specify "checker does not detect error" do
          should_not have_error
        end
      end

      context "when there is no last comma in multiline nested hash" do
        let(:script) do
          <<-EOF
            {
              :a => {
                :b => 1,
              }
            }
          EOF
        end

        specify "checker detects error" do
          should have_error
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.0605913717886573, 'fraction_numerical': 0.003877847794474067, 'mean_word_length': 1.110997442455243, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 19, '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': '5389807', 'n_tokens_mistral': 1155, 'n_tokens_neox': 1084, 'n_words': 405}