Sha256: fcc4d012b04ccff7fc90af034904ce82c10d0de058c1dc753f06b0f83327a6d4

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::PredicateName, :config do
  subject(:cop) { described_class.new(config) }
  let(:cop_config) { { 'NamePrefixBlacklist' => %w(has_ is_) } }

  %w(has_ is_).each do |prefix|
    it 'registers an offense for blacklisted method_name' do
      inspect_source(cop, ["def #{prefix}_attr",
                           '  # ...',
                           'end'])
      expect(cop.offenses.size).to eq(1)
      expect(cop.highlights).to eq(["#{prefix}_attr"])
    end
  end

  it 'accepts non-blacklisted method name' do
    inspect_source(cop, ['def have_attr',
                         '  # ...',
                         'end'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.19.1 spec/rubocop/cop/style/predicate_name_spec.rb
rubocop-0.19.0 spec/rubocop/cop/style/predicate_name_spec.rb