blob: 2ea58777adebfb9235bc440d0b5d5dbbaee288a6 (
plain)
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
|
require_relative "../../rubocops/class_cop"
describe RuboCop::Cop::FormulaAudit::ClassName do
subject(:cop) { described_class.new }
it "reports an offense when using ScriptFileFormula" do
expect_offense(<<~RUBY)
class Foo < ScriptFileFormula
^^^^^^^^^^^^^^^^^ ScriptFileFormula is deprecated, use Formula instead
url 'http://example.com/foo-1.0.tgz'
end
RUBY
end
it "reports an offense when using GithubGistFormula" do
expect_offense(<<~RUBY)
class Foo < GithubGistFormula
^^^^^^^^^^^^^^^^^ GithubGistFormula is deprecated, use Formula instead
url 'http://example.com/foo-1.0.tgz'
end
RUBY
end
it "reports an offense when using AmazonWebServicesFormula" do
expect_offense(<<~RUBY)
class Foo < AmazonWebServicesFormula
^^^^^^^^^^^^^^^^^^^^^^^^ AmazonWebServicesFormula is deprecated, use Formula instead
url 'http://example.com/foo-1.0.tgz'
end
RUBY
end
it "supports auto-correcting deprecated parent classes" do
source = <<~EOS
class Foo < AmazonWebServicesFormula
url 'http://example.com/foo-1.0.tgz'
end
EOS
corrected_source = <<~EOS
class Foo < Formula
url 'http://example.com/foo-1.0.tgz'
end
EOS
new_source = autocorrect_source(source)
expect(new_source).to eq(corrected_source)
end
end
describe RuboCop::Cop::FormulaAuditStrict::Test do
subject(:cop) { described_class.new }
it "reports an offense when there is no test block" do
expect_offense(<<~RUBY)
class Foo < Formula
^^^^^^^^^^^^^^^^^^^ A `test do` test block should be added
url 'http://example.com/foo-1.0.tgz'
end
RUBY
end
end
|