CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/spec/rubocop/cop/lint/deprecated_gem_version_spec.rb
Views: 11784
1
require 'spec_helper'
2
require 'rubocop/cop/lint/deprecated_gem_version'
3
4
RSpec.describe RuboCop::Cop::Lint::DeprecatedGemVersion do
5
subject(:cop) { described_class.new(config) }
6
let(:empty_rubocop_config) { { } }
7
let(:config) { RuboCop::Config.new(empty_rubocop_config) }
8
9
it 'corrects `Gem::Version`' do
10
expect_offense(<<~RUBY)
11
Gem::Version
12
^^^^^^^^^^^^ Use `Rex::Version` instead of `Gem::Version`.
13
RUBY
14
15
expect_correction(<<~RUBY)
16
Rex::Version
17
RUBY
18
end
19
20
it 'corrects `Gem::Version.new`' do
21
expect_offense(<<~RUBY)
22
Gem::Version.new("1.0.0")
23
^^^^^^^^^^^^ Use `Rex::Version` instead of `Gem::Version`.
24
RUBY
25
26
expect_correction(<<~RUBY)
27
Rex::Version.new("1.0.0")
28
RUBY
29
end
30
31
it 'corrects `::Gem::Version`' do
32
expect_offense(<<~RUBY)
33
::Gem::Version
34
^^^^^^^^^^^^^^ Use `Rex::Version` instead of `Gem::Version`.
35
RUBY
36
37
expect_correction(<<~RUBY)
38
::Rex::Version
39
RUBY
40
end
41
42
it 'does not correct `Abc::Gem::Version`' do
43
expect_no_offenses(<<~RUBY)
44
Abc::Gem::Version
45
RUBY
46
end
47
end
48
49