forked from rubocop/rubocop
/
insecure_protocol_source_spec.rb
67 lines (55 loc) · 1.79 KB
/
insecure_protocol_source_spec.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::Bundler::InsecureProtocolSource, :config do
it 'registers an offense when using `source :gemcutter`' do
expect_offense(<<~RUBY)
source :gemcutter
^^^^^^^^^^ The source `:gemcutter` is deprecated [...]
RUBY
expect_correction(<<~RUBY)
source 'https://rubygems.org'
RUBY
end
it 'registers an offense when using `source :rubygems`' do
expect_offense(<<~RUBY)
source :rubygems
^^^^^^^^^ The source `:rubygems` is deprecated [...]
RUBY
expect_correction(<<~RUBY)
source 'https://rubygems.org'
RUBY
end
it 'registers an offense when using `source :rubyforge`' do
expect_offense(<<~RUBY)
source :rubyforge
^^^^^^^^^^ The source `:rubyforge` is deprecated [...]
RUBY
expect_correction(<<~RUBY)
source 'https://rubygems.org'
RUBY
end
it "does not register an offense when using `source 'https://rubygems.org'`" do
expect_no_offenses(<<~RUBY)
source 'https://rubygems.org'
RUBY
end
context 'when `AllowHttpProtocol: true`' do
let(:cop_config) { { 'AllowHttpProtocol' => true } }
it "does not register an offense when using `source 'http://rubygems.org'`" do
expect_no_offenses(<<~RUBY)
source 'http://rubygems.org'
RUBY
end
end
context 'when `AllowHttpProtocol: false`' do
let(:cop_config) { { 'AllowHttpProtocol' => false } }
it "registers an offense when using `source 'http://rubygems.org'`" do
expect_offense(<<~RUBY)
source 'http://rubygems.org'
^^^^^^^^^^^^^^^^^^^^^ Use `https://rubygems.org` instead of `http://rubygems.org`.
RUBY
expect_correction(<<~RUBY)
source 'https://rubygems.org'
RUBY
end
end
end