Sha256: a86ddbec2d08d877e9354a566e33e529f62ec52b977b284a7cde24eb877c227f

Contents?: true

Size: 1.18 KB

Versions: 4

Compression:

Stored size: 1.18 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Lint::DeprecatedClassMethods do
  subject(:cop) { described_class.new }

  it 'registers an offense for File.exists?' do
    inspect_source(cop, 'File.exists?(o)')
    expect(cop.offenses.size).to eq(1)
    expect(cop.messages)
      .to eq(['`File.exists?` is deprecated in favor of `File.exist?`.'])
  end

  it 'registers an offense for ::File.exists?' do
    inspect_source(cop, '::File.exists?(o)')
    expect(cop.offenses.size).to eq(1)
    expect(cop.messages)
      .to eq(['`File.exists?` is deprecated in favor of `File.exist?`.'])
  end

  it 'registers an offense for Dir.exists?' do
    inspect_source(cop, 'Dir.exists?(o)')
    expect(cop.offenses.size).to eq(1)
    expect(cop.messages)
      .to eq(['`Dir.exists?` is deprecated in favor of `Dir.exist?`.'])
  end

  it 'auto-corrects File.exists? with File.exist?' do
    new_source = autocorrect_source(cop, 'File.exists?(something)')
    expect(new_source).to eq('File.exist?(something)')
  end

  it 'auto-corrects Dir.exists? with Dir.exist?' do
    new_source = autocorrect_source(cop, 'Dir.exists?(something)')
    expect(new_source).to eq('Dir.exist?(something)')
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/lint/deprecated_class_methods_spec.rb
rubocop-0.21.0 spec/rubocop/cop/lint/deprecated_class_methods_spec.rb
rubocop-0.20.1 spec/rubocop/cop/lint/deprecated_class_methods_spec.rb
rubocop-0.20.0 spec/rubocop/cop/lint/deprecated_class_methods_spec.rb