|
5 | 5 | RSpec.describe RuboCop::Cop::Homebrew::NoFileutilsRmrf do
|
6 | 6 | subject(:cop) { described_class.new }
|
7 | 7 |
|
8 |
| - it "registers an offense when using FileUtils.rm_rf" do |
9 |
| - expect_offense(<<~RUBY) |
10 |
| - FileUtils.rm_rf("path/to/directory") |
11 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Homebrew/NoFileutilsRmrf: #{RuboCop::Cop::Homebrew::NoFileutilsRmrf::MSG} |
12 |
| - RUBY |
13 |
| - end |
| 8 | + describe "FileUtils.rm_rf" do |
| 9 | + it "registers an offense" do |
| 10 | + expect_offense(<<~RUBY) |
| 11 | + FileUtils.rm_rf("path/to/directory") |
| 12 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Homebrew/NoFileutilsRmrf: #{RuboCop::Cop::Homebrew::NoFileutilsRmrf::MSG} |
| 13 | + RUBY |
| 14 | + end |
14 | 15 |
|
15 |
| - it "registers an offense when using FileUtils.rm_f" do |
16 |
| - expect_offense(<<~RUBY) |
17 |
| - FileUtils.rm_f("path/to/directory") |
18 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Homebrew/NoFileutilsRmrf: #{RuboCop::Cop::Homebrew::NoFileutilsRmrf::MSG} |
19 |
| - RUBY |
20 |
| - end |
| 16 | + it "autocorrects" do |
| 17 | + corrected = autocorrect_source(<<~RUBY) |
| 18 | + FileUtils.rm_rf("path/to/directory") |
| 19 | + RUBY |
21 | 20 |
|
22 |
| - it "registers an offense when using FileUtils.rmtree" do |
23 |
| - expect_offense(<<~RUBY) |
24 |
| - FileUtils.rmtree("path/to/directory") |
25 |
| - ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Homebrew/NoFileutilsRmrf: #{RuboCop::Cop::Homebrew::NoFileutilsRmrf::MSG} |
26 |
| - RUBY |
| 21 | + expect(corrected).to eq(<<~RUBY) |
| 22 | + FileUtils.rm_r("path/to/directory") |
| 23 | + RUBY |
| 24 | + end |
27 | 25 | end
|
28 | 26 |
|
29 |
| - it "autocorrects" do |
30 |
| - corrected = autocorrect_source(<<~RUBY) |
31 |
| - FileUtils.rm_rf("path/to/directory") |
32 |
| - RUBY |
| 27 | + describe "FileUtils.rm_f" do |
| 28 | + it "registers an offense" do |
| 29 | + expect_offense(<<~RUBY) |
| 30 | + FileUtils.rm_f("path/to/directory") |
| 31 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Homebrew/NoFileutilsRmrf: #{RuboCop::Cop::Homebrew::NoFileutilsRmrf::MSG} |
| 32 | + RUBY |
| 33 | + end |
33 | 34 |
|
34 |
| - expect(corrected).to eq(<<~RUBY) |
35 |
| - FileUtils.rm_r("path/to/directory") |
36 |
| - RUBY |
37 |
| - end |
| 35 | + it "autocorrects" do |
| 36 | + corrected = autocorrect_source(<<~RUBY) |
| 37 | + FileUtils.rm_f("path/to/directory") |
| 38 | + RUBY |
38 | 39 |
|
39 |
| - it "does not register an offense when using FileUtils.rm_r" do |
40 |
| - expect_no_offenses(<<~RUBY) |
41 |
| - FileUtils.rm_r("path/to/directory") |
42 |
| - RUBY |
| 40 | + expect(corrected).to eq(<<~RUBY) |
| 41 | + FileUtils.rm("path/to/directory") |
| 42 | + RUBY |
| 43 | + end |
43 | 44 | end
|
44 | 45 |
|
45 |
| - it "does not register an offense when using FileUtils.rm" do |
46 |
| - expect_no_offenses(<<~RUBY) |
47 |
| - FileUtils.rm("path/to/directory") |
48 |
| - RUBY |
| 46 | + describe "FileUtils.rmtree" do |
| 47 | + it "registers an offense when using FileUtils.rmtree" do |
| 48 | + expect_offense(<<~RUBY) |
| 49 | + FileUtils.rmtree("path/to/directory") |
| 50 | + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Homebrew/NoFileutilsRmrf: #{RuboCop::Cop::Homebrew::NoFileutilsRmrf::MSG} |
| 51 | + RUBY |
| 52 | + end |
| 53 | + |
| 54 | + it "autocorrects" do |
| 55 | + corrected = autocorrect_source(<<~RUBY) |
| 56 | + FileUtils.rmtree("path/to/directory") |
| 57 | + RUBY |
| 58 | + |
| 59 | + expect(corrected).to eq(<<~RUBY) |
| 60 | + FileUtils.rm_r("path/to/directory") |
| 61 | + RUBY |
| 62 | + end |
49 | 63 | end
|
50 | 64 | end
|
0 commit comments