-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
gem_comment_spec.rb
65 lines (57 loc) · 1.49 KB
/
gem_comment_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
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::Bundler::GemComment, :config do
let(:cop_config) do
{
'Include' => ['**/Gemfile'],
'IgnoredGems' => ['rake']
}
end
context 'when investigating Ruby files' do
it 'does not register any offenses' do
expect_no_offenses(<<~RUBY)
gem('rubocop')
RUBY
end
end
context 'when investigating Gemfiles' do
context 'and the file is empty' do
it 'does not register any offenses' do
expect_no_offenses('', 'Gemfile')
end
end
context 'and the gem is commented' do
it 'does not register any offenses' do
expect_no_offenses(<<~RUBY, 'Gemfile')
# Style-guide enforcer.
gem 'rubocop'
RUBY
end
end
context 'and the gem is permitted' do
it 'does not register any offenses' do
expect_no_offenses(<<~RUBY, 'Gemfile')
gem 'rake'
RUBY
end
end
context 'and the file contains source and group' do
it 'does not register any offenses' do
expect_no_offenses(<<~RUBY, 'Gemfile')
source 'http://rubygems.org'
# Style-guide enforcer.
group :development do
# …
end
RUBY
end
end
context 'and a gem has no comment' do
it 'registers an offense' do
expect_offense(<<-GEM, 'Gemfile')
gem 'rubocop'
^^^^^^^^^^^^^ Missing gem description comment.
GEM
end
end
end
end