Sha256: 02f0797aabf180b8c1a9405fb5237cb4a149001c33f52966b54f3f6c64e50b23

Contents?: true

Size: 692 Bytes

Versions: 4

Compression:

Stored size: 692 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::Not do
  subject(:cop) { described_class.new }

  it 'registers an offense for not' do
    inspect_source(cop, 'not test')
    expect(cop.offenses.size).to eq(1)
  end

  it 'does not register an offense for !' do
    inspect_source(cop, '!test')
    expect(cop.offenses).to be_empty
  end

  it 'auto-corrects "not" with !' do
    new_source = autocorrect_source(cop, 'x = 10 if not y')
    expect(new_source).to eq('x = 10 if !y')
  end

  it 'leaves "not" as is if auto-correction changes the meaning' do
    src = 'not x < y'
    new_source = autocorrect_source(cop, src)
    expect(new_source).to eq(src)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/style/not_spec.rb
rubocop-0.21.0 spec/rubocop/cop/style/not_spec.rb
rubocop-0.20.1 spec/rubocop/cop/style/not_spec.rb
rubocop-0.20.0 spec/rubocop/cop/style/not_spec.rb