<commit_before># encoding: utf-8

require 'spec_helper'

describe RuboCop::Cop::Style::PredicateName, :config do
  subject(:cop) { described_class.new(config) }

  context 'with blacklisted prefixes' do
    let(:cop_config) do
      { 'NamePrefix' => %w(has_ is_),
        'NamePrefixBlacklist' => %w(has_ is_) }
    end

    %w(has is).each do |prefix|
      it 'registers an offense when method name starts with known prefix' do
        inspect_source(cop, ["def #{prefix}_attr",
                             '  # ...',
                             'end'])
        expect(cop.offenses.size).to eq(1)
        expect(cop.messages).to eq(["Rename `#{prefix}_attr` to `attr?`."])
        expect(cop.highlights).to eq(["#{prefix}_attr"])
      end
    end

    it 'accepts method name that starts with unknown prefix' do
      inspect_source(cop, ['def have_attr',
                           '  # ...',
                           'end'])
      expect(cop.offenses).to be_empty
    end

    context 'with blacklisted prefixes' do
      let(:cop_config) do
        { 'NamePrefix' => %w(has_ is_), 'NamePrefixBlacklist' => [] }
      end

      %w(has is).each do |prefix|
        it 'registers an offense when method name starts with known prefix' do
          inspect_source(cop, ["def #{prefix}_attr",
                               '  # ...',
                               'end'])
          expect(cop.offenses.size).to eq(1)
          expect(cop.messages)
            .to eq(["Rename `#{prefix}_attr` to `#{prefix}_attr?`."])
          expect(cop.highlights).to eq(["#{prefix}_attr"])
        end
      end

      it 'accepts method name that starts with unknown prefix' do
        inspect_source(cop, ['def have_attr',
                             '  # ...',
                             'end'])
        expect(cop.offenses).to be_empty
      end
    end
  end
end<commit_msg>Correct nesting (and inaccurate context description) in Style/PredicateName specs<commit_after># encoding: utf-8

require 'spec_helper'

describe RuboCop::Cop::Style::PredicateName, :config do
  subject(:cop) { described_class.new(config) }

  context 'with blacklisted prefixes' do
    let(:cop_config) do
      { 'NamePrefix' => %w(has_ is_),
        'NamePrefixBlacklist' => %w(has_ is_) }
    end

    %w(has is).each do |prefix|
      it 'registers an offense when method name starts with known prefix' do
        inspect_source(cop, ["def #{prefix}_attr",
                             '  # ...',
                             'end'])
        expect(cop.offenses.size).to eq(1)
        expect(cop.messages).to eq(["Rename `#{prefix}_attr` to `attr?`."])
        expect(cop.highlights).to eq(["#{prefix}_attr"])
      end
    end

    it 'accepts method name that starts with unknown prefix' do
      inspect_source(cop, ['def have_attr',
                           '  # ...',
                           'end'])
      expect(cop.offenses).to be_empty
    end
  end

  context 'without blacklisted prefixes' do
    let(:cop_config) do
      { 'NamePrefix' => %w(has_ is_), 'NamePrefixBlacklist' => [] }
    end

    %w(has is).each do |prefix|
      it 'registers an offense when method name starts with known prefix' do
        inspect_source(cop, ["def #{prefix}_attr",
                             '  # ...',
                             'end'])
        expect(cop.offenses.size).to eq(1)
        expect(cop.messages)
          .to eq(["Rename `#{prefix}_attr` to `#{prefix}_attr?`."])
        expect(cop.highlights).to eq(["#{prefix}_attr"])
      end
    end

    it 'accepts method name that starts with unknown prefix' do
      inspect_source(cop, ['def have_attr',
                           '  # ...',
                           'end'])
      expect(cop.offenses).to be_empty
    end
  end
end
{'fraction_non_alphanumeric': 0.1330335889976197, 'fraction_numerical': 0.0015868817773075905, 'mean_word_length': 1.8738601823708207, 'pattern_counts': {'":': 0, '<': 3, '<?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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6262434', 'n_tokens_mistral': 1122, 'n_tokens_neox': 1120, 'n_words': 281}