forked from rubocop/rubocop-rake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
desc_spec.rb
79 lines (67 loc) · 1.79 KB
/
desc_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
68
69
70
71
72
73
74
75
76
77
78
79
# frozen_string_literal: true
RSpec.describe RuboCop::Cop::Rake::Desc, :config do
it 'register an offense for task on the top level' do
expect_offense(<<~RUBY)
task :foo
^^^^^^^^^ Describe the task with `desc` method.
task :foo do
^^^^^^^^^ Describe the task with `desc` method.
bar
end
RUBY
end
it 'register an offense for task with block in a block' do
expect_offense(<<~RUBY)
tap do
task :foo
^^^^^^^^^ Describe the task with `desc` method.
end
tap do
something 'foo'
task :foo do
^^^^^^^^^ Describe the task with `desc` method.
bar
end
end
RUBY
end
it 'register an offense for task in kwbegin' do
expect_offense(<<~RUBY)
begin
task :foo
^^^^^^^^^ Describe the task with `desc` method.
end
RUBY
end
it 'does not register an offense for task with desc' do
expect_no_offenses(<<~RUBY)
desc 'Do foo'
task :foo do
end
desc 'Do bar'
task :bar
RUBY
end
it 'does not register an offense for the default task' do
expect_no_offenses(<<~RUBY)
task default: :spec
task default: [:spec, :rubocop]
RUBY
end
it 'does not register an offense when `task` is not a definition' do
expect_no_offenses(<<~RUBY)
task.name
RUBY
end
it 'registers an offense for one prerequisite declaration (alias)' do
expect_offense(<<~RUBY)
task release: 'changelog:check_clean'
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Describe the task with `desc` method.
RUBY
end
it 'does not register an offense for multiple prerequisite declarations' do
expect_no_offenses(<<~RUBY)
task release: ['changelog:check_clean', 'changelog:create']
RUBY
end
end