foodcritic 11.1.0 → 11.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -1
- data/README.md +18 -0
- data/chef_dsl_metadata/{chef_12.8.1.json → chef_13.1.31.json} +4377 -1784
- data/features/009_check_for_unrecognised_resource_attributes.feature +0 -9
- data/features/038_check_for_invalid_action.feature +0 -9
- data/features/step_definitions/cookbook_steps.rb +6 -124
- data/lib/foodcritic/command_line.rb +1 -1
- data/lib/foodcritic/linter.rb +1 -1
- data/lib/foodcritic/rules/fc091.rb +10 -0
- data/lib/foodcritic/rules/fc092.rb +10 -0
- data/lib/foodcritic/version.rb +1 -1
- data/spec/functional/fc008_spec.rb +6 -6
- data/spec/functional/fc009_spec.rb +27 -0
- data/spec/functional/fc010_spec.rb +32 -0
- data/spec/functional/fc011_spec.rb +3 -3
- data/spec/functional/fc012_spec.rb +3 -3
- data/spec/functional/fc013_spec.rb +4 -4
- data/spec/functional/fc015_spec.rb +19 -0
- data/spec/functional/fc016_spec.rb +5 -5
- data/spec/functional/fc028_spec.rb +18 -18
- data/spec/functional/fc029_spec.rb +6 -6
- data/spec/functional/fc031_spec.rb +2 -2
- data/spec/functional/fc038_spec.rb +23 -0
- data/spec/functional/fc042_spec.rb +2 -2
- data/spec/functional/fc043_spec.rb +28 -0
- data/spec/functional/fc045_spec.rb +3 -3
- data/spec/functional/fc052_spec.rb +2 -2
- data/spec/functional/fc053_spec.rb +2 -2
- data/spec/functional/fc055_spec.rb +3 -3
- data/spec/functional/fc056_spec.rb +3 -3
- data/spec/functional/fc057_spec.rb +62 -0
- data/spec/functional/fc058_spec.rb +102 -0
- data/spec/functional/fc059_spec.rb +27 -0
- data/spec/functional/fc060_spec.rb +45 -0
- data/spec/functional/fc061_spec.rb +9 -9
- data/spec/functional/fc062_spec.rb +2 -2
- data/spec/functional/fc063_spec.rb +3 -3
- data/spec/functional/fc064_spec.rb +2 -2
- data/spec/functional/fc065_spec.rb +2 -2
- data/spec/functional/fc066_spec.rb +6 -6
- data/spec/functional/fc067_spec.rb +2 -2
- data/spec/functional/fc068_spec.rb +2 -2
- data/spec/functional/fc069_spec.rb +5 -5
- data/spec/functional/fc070_spec.rb +9 -9
- data/spec/functional/fc071_spec.rb +6 -6
- data/spec/functional/fc072_spec.rb +2 -2
- data/spec/functional/fc073_spec.rb +9 -9
- data/spec/functional/fc074_spec.rb +3 -3
- data/spec/functional/fc075_spec.rb +5 -5
- data/spec/functional/fc091_spec.rb +38 -0
- data/spec/functional/fc092_spec.rb +31 -0
- data/spec/regression/expected/aix.txt +1 -0
- data/spec/regression/expected/build-essential.txt +1 -0
- data/spec/regression/expected/drbd.txt +1 -0
- data/spec/regression/expected/perl.txt +1 -0
- data/spec/regression/expected/sudo.txt +1 -0
- data/spec/regression/expected/users.txt +1 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/unit/linter_spec.rb +1 -1
- metadata +18 -14
- data/chef_dsl_metadata/chef_12.6.0.json +0 -15760
- data/chef_dsl_metadata/chef_12.7.2.json +0 -16673
- data/features/010_check_search_syntax.feature +0 -20
- data/features/015_check_for_definitions.feature +0 -20
- data/features/043_check_for_old_notification_style.feature +0 -28
- data/features/057_check_for_library_provider_without_use_inline_resources.feature +0 -20
- data/features/058_check_for_library_provider_bad_action_methods.feature +0 -25
- data/features/059_check_for_lwrp_provider_without_use_inline_resources.feature +0 -15
- data/features/060_check_for_lwrp_provider_bad_action_methods.feature +0 -25
@@ -9,7 +9,7 @@ describe "FC016" do
|
|
9
9
|
|
10
10
|
attribute :name, String, name_attribute: true
|
11
11
|
EOH
|
12
|
-
it { is_expected.to_not violate_rule
|
12
|
+
it { is_expected.to_not violate_rule }
|
13
13
|
end
|
14
14
|
|
15
15
|
context "with a cookbook with a LWRP that includes a non-DSL default_action" do
|
@@ -23,7 +23,7 @@ describe "FC016" do
|
|
23
23
|
|
24
24
|
attribute :name, String, name_attribute: true
|
25
25
|
EOH
|
26
|
-
it { is_expected.to_not violate_rule
|
26
|
+
it { is_expected.to_not violate_rule }
|
27
27
|
end
|
28
28
|
|
29
29
|
context "with a cookbook with a LWRP that does not include a default_action" do
|
@@ -32,7 +32,7 @@ describe "FC016" do
|
|
32
32
|
|
33
33
|
attribute :name, String, name_attribute: true
|
34
34
|
EOH
|
35
|
-
it { is_expected.to violate_rule
|
35
|
+
it { is_expected.to violate_rule }
|
36
36
|
end
|
37
37
|
|
38
38
|
context "with a custom resource that includes a property" do
|
@@ -43,7 +43,7 @@ describe "FC016" do
|
|
43
43
|
cookbook_file "/etc/something"
|
44
44
|
end
|
45
45
|
EOH
|
46
|
-
it { is_expected.to_not violate_rule
|
46
|
+
it { is_expected.to_not violate_rule }
|
47
47
|
end
|
48
48
|
|
49
49
|
context "with a custom resource that includes only an action" do
|
@@ -52,6 +52,6 @@ describe "FC016" do
|
|
52
52
|
cookbook_file "/etc/something"
|
53
53
|
end
|
54
54
|
EOH
|
55
|
-
it { is_expected.to_not violate_rule
|
55
|
+
it { is_expected.to_not violate_rule }
|
56
56
|
end
|
57
57
|
end
|
@@ -3,91 +3,91 @@ require "spec_helper"
|
|
3
3
|
describe "FC028" do
|
4
4
|
context "with a cookbook with a single recipe that calls platform? without parentheses for a single platform" do
|
5
5
|
recipe_file "platform? 'ubuntu'"
|
6
|
-
it { is_expected.not_to violate_rule
|
6
|
+
it { is_expected.not_to violate_rule }
|
7
7
|
end
|
8
8
|
|
9
9
|
context "with a cookbook with a single recipe that calls platform? without parentheses for two platforms" do
|
10
10
|
recipe_file "platform?('ubuntu','windows')"
|
11
|
-
it { is_expected.not_to violate_rule
|
11
|
+
it { is_expected.not_to violate_rule }
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with a cookbook with a single recipe that calls platform? with parentheses for a single platform" do
|
15
15
|
recipe_file "platform?('ubuntu')"
|
16
|
-
it { is_expected.not_to violate_rule
|
16
|
+
it { is_expected.not_to violate_rule }
|
17
17
|
end
|
18
18
|
|
19
19
|
context "with a cookbook with a single recipe that calls platform? with parentheses for two platforms" do
|
20
20
|
recipe_file "platform?('ubuntu', 'windows')"
|
21
|
-
it { is_expected.not_to violate_rule
|
21
|
+
it { is_expected.not_to violate_rule }
|
22
22
|
end
|
23
23
|
|
24
24
|
context "with a cookbook with a single recipe that compares a value against node.platform" do
|
25
25
|
recipe_file "node.platform == 'ubuntu'"
|
26
|
-
it { is_expected.not_to violate_rule
|
26
|
+
it { is_expected.not_to violate_rule }
|
27
27
|
end
|
28
28
|
|
29
29
|
context "with a cookbook with a single recipe that uses checks a value against node.platform" do
|
30
30
|
recipe_file "node.platform == 'ubuntu'"
|
31
|
-
it { is_expected.not_to violate_rule
|
31
|
+
it { is_expected.not_to violate_rule }
|
32
32
|
end
|
33
33
|
|
34
34
|
context "with a cookbook with a single recipe that calls node.platform? without a parentheses" do
|
35
35
|
recipe_file "node.platform? 'ubuntu'"
|
36
|
-
it { is_expected.to violate_rule
|
36
|
+
it { is_expected.to violate_rule }
|
37
37
|
end
|
38
38
|
|
39
39
|
context "with a cookbook with a single recipe that calls node.platform? with a parentheses" do
|
40
40
|
recipe_file "node.platform?('ubuntu')"
|
41
|
-
it { is_expected.to violate_rule
|
41
|
+
it { is_expected.to violate_rule }
|
42
42
|
end
|
43
43
|
|
44
44
|
context "with a cookbook with a single recipe that calls node.platform? with a parentheses for 2 platforms" do
|
45
45
|
recipe_file "node.platform?('ubuntu', 'windows')"
|
46
|
-
it { is_expected.to violate_rule
|
46
|
+
it { is_expected.to violate_rule }
|
47
47
|
end
|
48
48
|
|
49
49
|
context "with a cookbook with a single recipe that calls platform_family? without parentheses for a single platform family" do
|
50
50
|
recipe_file "platform_family? 'debian'"
|
51
|
-
it { is_expected.not_to violate_rule
|
51
|
+
it { is_expected.not_to violate_rule }
|
52
52
|
end
|
53
53
|
|
54
54
|
context "with a cookbook with a single recipe that calls platform_family? without parentheses for two plaform families" do
|
55
55
|
recipe_file "platform_family?('debian','windows')"
|
56
|
-
it { is_expected.not_to violate_rule
|
56
|
+
it { is_expected.not_to violate_rule }
|
57
57
|
end
|
58
58
|
|
59
59
|
context "with a cookbook with a single recipe that calls platform_family? with parentheses for a single plaform family" do
|
60
60
|
recipe_file "platform_family?('debian')"
|
61
|
-
it { is_expected.not_to violate_rule
|
61
|
+
it { is_expected.not_to violate_rule }
|
62
62
|
end
|
63
63
|
|
64
64
|
context "with a cookbook with a single recipe that calls platform_family? with parentheses for two plaform families" do
|
65
65
|
recipe_file "platform_family?('debian', 'windows')"
|
66
|
-
it { is_expected.not_to violate_rule
|
66
|
+
it { is_expected.not_to violate_rule }
|
67
67
|
end
|
68
68
|
|
69
69
|
context "with a cookbook with a single recipe that compares a value against node.platform_family" do
|
70
70
|
recipe_file "node.platform_family == 'debian'"
|
71
|
-
it { is_expected.not_to violate_rule
|
71
|
+
it { is_expected.not_to violate_rule }
|
72
72
|
end
|
73
73
|
|
74
74
|
context "with a cookbook with a single recipe that uses checks a value against node.platform_family" do
|
75
75
|
recipe_file "node.platform_family == 'debian'"
|
76
|
-
it { is_expected.not_to violate_rule
|
76
|
+
it { is_expected.not_to violate_rule }
|
77
77
|
end
|
78
78
|
|
79
79
|
context "with a cookbook with a single recipe that calls node.platform_family? without a parentheses" do
|
80
80
|
recipe_file "node.platform_family? 'debian'"
|
81
|
-
it { is_expected.to violate_rule
|
81
|
+
it { is_expected.to violate_rule }
|
82
82
|
end
|
83
83
|
|
84
84
|
context "with a cookbook with a single recipe that calls node.platform_family? with a parentheses" do
|
85
85
|
recipe_file "node.platform_family?('debian')"
|
86
|
-
it { is_expected.to violate_rule
|
86
|
+
it { is_expected.to violate_rule }
|
87
87
|
end
|
88
88
|
|
89
89
|
context "with a cookbook with a single recipe that calls node.platform_family? with a parentheses for 2 plaform families" do
|
90
90
|
recipe_file "node.platform_family?('debian', 'windows')"
|
91
|
-
it { is_expected.to violate_rule
|
91
|
+
it { is_expected.to violate_rule }
|
92
92
|
end
|
93
93
|
end
|
@@ -3,31 +3,31 @@ require "spec_helper"
|
|
3
3
|
describe "FC029" do
|
4
4
|
context "with a cookbook with a metadata file that doesn't contain the recipe keyword" do
|
5
5
|
metadata_file("name 'example'")
|
6
|
-
it { is_expected.not_to violate_rule
|
6
|
+
it { is_expected.not_to violate_rule }
|
7
7
|
end
|
8
8
|
|
9
9
|
context "with a cookbook with a metadata file that contains contain the recipe keyword with the cookbook name only" do
|
10
10
|
metadata_file("name 'example'\nrecipe 'example', 'Installs Example'")
|
11
|
-
it { is_expected.not_to violate_rule
|
11
|
+
it { is_expected.not_to violate_rule }
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with a cookbook with a metadata file that contains the recipe keyword with the cookbook::recipe format name" do
|
15
15
|
metadata_file("name 'example'\nrecipe 'example::default', 'Installs Example'")
|
16
|
-
it { is_expected.not_to violate_rule
|
16
|
+
it { is_expected.not_to violate_rule }
|
17
17
|
end
|
18
18
|
|
19
19
|
context "with a cookbook with a metadata file that contains the recipe keyword and lacks the cookbook name" do
|
20
20
|
metadata_file("name 'example'\nrecipe 'default', 'Installs Example'")
|
21
|
-
it { is_expected.to violate_rule
|
21
|
+
it { is_expected.to violate_rule }
|
22
22
|
end
|
23
23
|
|
24
24
|
context "with a cookbook with a metadata file that contains the recipe keyword and stores full recipe name as a var" do
|
25
25
|
metadata_file("name 'example'\nvar = 'example::default'\nrecipe my_var, 'Installs Example'")
|
26
|
-
it { is_expected.not_to violate_rule
|
26
|
+
it { is_expected.not_to violate_rule }
|
27
27
|
end
|
28
28
|
|
29
29
|
context "with a cookbook with a metadata file that contains the recipe keyword and stores part of the recipe name as a var" do
|
30
30
|
metadata_file('name "example"\nvar = "example"\nrecipe "#{my_var}::default", "Installs Example"')
|
31
|
-
it { is_expected.not_to violate_rule
|
31
|
+
it { is_expected.not_to violate_rule }
|
32
32
|
end
|
33
33
|
end
|
@@ -4,11 +4,11 @@ describe "FC031" do
|
|
4
4
|
context "with a cookbook with a metadata file" do
|
5
5
|
metadata_file
|
6
6
|
recipe_file
|
7
|
-
it { is_expected.to_not violate_rule
|
7
|
+
it { is_expected.to_not violate_rule }
|
8
8
|
end
|
9
9
|
|
10
10
|
context "with a cookbook without a metadata file" do
|
11
11
|
recipe_file
|
12
|
-
it { is_expected.to violate_rule
|
12
|
+
it { is_expected.to violate_rule }
|
13
13
|
end
|
14
14
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC038" do
|
4
|
+
context "on chef 12.16.42 with a cookbook that locks an apt_package" do
|
5
|
+
foodcritic_command("--chef-version", "12.16.42", "--no-progress", ".")
|
6
|
+
recipe_file <<-EOH
|
7
|
+
apt_package 'foo' do
|
8
|
+
action :lock
|
9
|
+
end
|
10
|
+
EOH
|
11
|
+
it { is_expected.not_to violate_rule }
|
12
|
+
end
|
13
|
+
|
14
|
+
context "on chef 12.15.19 with a cookbook that locks an apt_package" do
|
15
|
+
foodcritic_command("--chef-version", "12.15.19", "--no-progress", ".")
|
16
|
+
recipe_file <<-EOH
|
17
|
+
apt_package 'foo' do
|
18
|
+
action :lock
|
19
|
+
end
|
20
|
+
EOH
|
21
|
+
it { is_expected.to violate_rule }
|
22
|
+
end
|
23
|
+
end
|
@@ -3,11 +3,11 @@ require "spec_helper"
|
|
3
3
|
describe "FC042" do
|
4
4
|
context "with a cookbook with a single recipe that uses require_recipe" do
|
5
5
|
recipe_file "require_recipe 'my_recipe::default'"
|
6
|
-
it { is_expected.to violate_rule
|
6
|
+
it { is_expected.to violate_rule }
|
7
7
|
end
|
8
8
|
|
9
9
|
context "with a cookbook with a single recipe that uses include_recipe" do
|
10
10
|
recipe_file "include_recipe 'my_recipe::default'"
|
11
|
-
it { is_expected.not_to violate_rule
|
11
|
+
it { is_expected.not_to violate_rule }
|
12
12
|
end
|
13
13
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC043" do
|
4
|
+
context "with a cookbook that has no notifications" do
|
5
|
+
recipe_file <<-EOH
|
6
|
+
cookbook_file "something"
|
7
|
+
EOH
|
8
|
+
it { is_expected.not_to violate_rule }
|
9
|
+
end
|
10
|
+
|
11
|
+
context "with a cookbook with a resource that notifies a service to restart" do
|
12
|
+
recipe_file <<-EOH
|
13
|
+
template "/etc/apache.conf" do
|
14
|
+
notifies :start, "service[apache]"
|
15
|
+
end
|
16
|
+
EOH
|
17
|
+
it { is_expected.not_to violate_rule }
|
18
|
+
end
|
19
|
+
|
20
|
+
context "with a cookbook with a resource that uses the old notification syntax" do
|
21
|
+
recipe_file <<-EOH
|
22
|
+
template "/etc/www/configures-apache.conf" do
|
23
|
+
notifies :restart, resources(:service => "apache")
|
24
|
+
end
|
25
|
+
EOH
|
26
|
+
it { is_expected.to violate_rule }
|
27
|
+
end
|
28
|
+
end
|
@@ -3,16 +3,16 @@ require "spec_helper"
|
|
3
3
|
describe "FC045" do
|
4
4
|
context "with a cookbook with a metadata file that includes the name keyword" do
|
5
5
|
metadata_file "name 'food'"
|
6
|
-
it { is_expected.to_not violate_rule
|
6
|
+
it { is_expected.to_not violate_rule }
|
7
7
|
end
|
8
8
|
|
9
9
|
context "with a cookbook with a metadata file that doesn't include the name keyword" do
|
10
10
|
metadata_file
|
11
|
-
it { is_expected.to violate_rule
|
11
|
+
it { is_expected.to violate_rule }
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with a cookbook without a metadata file" do
|
15
15
|
recipe_file
|
16
|
-
it { is_expected.to_not violate_rule
|
16
|
+
it { is_expected.to_not violate_rule }
|
17
17
|
end
|
18
18
|
end
|
@@ -3,11 +3,11 @@ require "spec_helper"
|
|
3
3
|
describe "FC052" do
|
4
4
|
context "with a cookbook with a metadata file that does contain the suggests keyword" do
|
5
5
|
metadata_file "suggests 'runit'"
|
6
|
-
it { is_expected.to violate_rule
|
6
|
+
it { is_expected.to violate_rule }
|
7
7
|
end
|
8
8
|
|
9
9
|
context "with a cookbook with a metadata file that does not contain the suggests keyword" do
|
10
10
|
metadata_file
|
11
|
-
it { is_expected.to_not violate_rule
|
11
|
+
it { is_expected.to_not violate_rule }
|
12
12
|
end
|
13
13
|
end
|
@@ -3,11 +3,11 @@ require "spec_helper"
|
|
3
3
|
describe "FC053" do
|
4
4
|
context "with a cookbook with a metadata file that does contain the recommends keyword" do
|
5
5
|
metadata_file "recommends 'runit'"
|
6
|
-
it { is_expected.to violate_rule
|
6
|
+
it { is_expected.to violate_rule }
|
7
7
|
end
|
8
8
|
|
9
9
|
context "with a cookbook with a metadata file that does not contain the recommends keyword" do
|
10
10
|
metadata_file
|
11
|
-
it { is_expected.to_not violate_rule
|
11
|
+
it { is_expected.to_not violate_rule }
|
12
12
|
end
|
13
13
|
end
|
@@ -3,16 +3,16 @@ require "spec_helper"
|
|
3
3
|
describe "FC055" do
|
4
4
|
context "with a cookbook with a metadata file that does not specify a maintainer" do
|
5
5
|
metadata_file "name 'my_cookbook'"
|
6
|
-
it { is_expected.to violate_rule
|
6
|
+
it { is_expected.to violate_rule }
|
7
7
|
end
|
8
8
|
|
9
9
|
context "with a cookbook with a metadata file that specifies a maintainer" do
|
10
10
|
metadata_file "maintainer 'Some Person'"
|
11
|
-
it { is_expected.to_not violate_rule
|
11
|
+
it { is_expected.to_not violate_rule }
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with a cookbook with a metadata file that specifies a maintainer as an expression" do
|
15
15
|
metadata_file("maintainer an(expression)")
|
16
|
-
it { is_expected.to_not violate_rule
|
16
|
+
it { is_expected.to_not violate_rule }
|
17
17
|
end
|
18
18
|
end
|
@@ -3,16 +3,16 @@ require "spec_helper"
|
|
3
3
|
describe "FC056" do
|
4
4
|
context "with a cookbook with a metadata file that does not specify a maintainer_email" do
|
5
5
|
metadata_file
|
6
|
-
it { is_expected.to violate_rule
|
6
|
+
it { is_expected.to violate_rule }
|
7
7
|
end
|
8
8
|
|
9
9
|
context "with a cookbook with a metadata file that specifies a maintainer_email" do
|
10
10
|
metadata_file "maintainer_email 'foo@example.com'"
|
11
|
-
it { is_expected.to_not violate_rule
|
11
|
+
it { is_expected.to_not violate_rule }
|
12
12
|
end
|
13
13
|
|
14
14
|
context "with a cookbook with a metadata file that specifies a maintainer_email as an expression" do
|
15
15
|
metadata_file("maintainer_email an(expression)")
|
16
|
-
it { is_expected.to_not violate_rule
|
16
|
+
it { is_expected.to_not violate_rule }
|
17
17
|
end
|
18
18
|
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC057" do
|
4
|
+
context "with a cookbook with a library provider with use_inline_resources" do
|
5
|
+
library_file <<-EOF
|
6
|
+
class MyResources
|
7
|
+
class Site < Chef::Resource::LWRPBase
|
8
|
+
provides :site
|
9
|
+
resource_name :site
|
10
|
+
actions :create
|
11
|
+
attribute :name, :kind_of => String, :name_attribute => true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class MyProviders
|
16
|
+
class Site < Chef::Provider::LWRPBase
|
17
|
+
provides :site
|
18
|
+
|
19
|
+
use_inline_resources
|
20
|
+
|
21
|
+
action :create do
|
22
|
+
file "/tmp/foo.txt"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
EOF
|
27
|
+
it { is_expected.not_to violate_rule }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with a cookbook with a library provider without use_inline_resources" do
|
31
|
+
library_file <<-EOF
|
32
|
+
class MyResources
|
33
|
+
class Site < Chef::Resource::LWRPBase
|
34
|
+
provides :site
|
35
|
+
resource_name :site
|
36
|
+
actions :create
|
37
|
+
attribute :name, :kind_of => String, :name_attribute => true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class MyProviders
|
42
|
+
class Site < Chef::Provider::LWRPBase
|
43
|
+
provides :site
|
44
|
+
|
45
|
+
action :create do
|
46
|
+
file "/tmp/foo.txt"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
EOF
|
51
|
+
it { is_expected.to violate_rule }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with a cookbook with plain old library file" do
|
55
|
+
library_file <<-EOF
|
56
|
+
def something
|
57
|
+
puts "I'm just a method"
|
58
|
+
end
|
59
|
+
EOF
|
60
|
+
it { is_expected.not_to violate_rule }
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe "FC058" do
|
4
|
+
context "with a cookbook with a library provider with use_inline_resources and uses def action_create" do
|
5
|
+
library_file <<-EOF
|
6
|
+
class MyResources
|
7
|
+
class Site < Chef::Resource::LWRPBase
|
8
|
+
provides :site
|
9
|
+
resource_name :site
|
10
|
+
actions :create
|
11
|
+
attribute :name, :kind_of => String, :name_attribute => true
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class MyProviders
|
16
|
+
class Site < Chef::Provider::LWRPBase
|
17
|
+
provides :site
|
18
|
+
|
19
|
+
use_inline_resources
|
20
|
+
|
21
|
+
def action_create
|
22
|
+
file "/tmp/foo.txt"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
EOF
|
27
|
+
it { is_expected.to violate_rule }
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with a cookbook with a library provider without use_inline_resources and uses def action_create" do
|
31
|
+
library_file <<-EOF
|
32
|
+
class MyResources
|
33
|
+
class Site < Chef::Resource::LWRPBase
|
34
|
+
provides :site
|
35
|
+
resource_name :site
|
36
|
+
actions :create
|
37
|
+
attribute :name, :kind_of => String, :name_attribute => true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class MyProviders
|
42
|
+
class Site < Chef::Provider::LWRPBase
|
43
|
+
provides :site
|
44
|
+
|
45
|
+
def action_create
|
46
|
+
file "/tmp/foo.txt"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
EOF
|
51
|
+
it { is_expected.to_not violate_rule }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with a cookbook with a cookbook that contains a library provider with use_inline_resources" do
|
55
|
+
library_file <<-EOF
|
56
|
+
class MyResources
|
57
|
+
class Site < Chef::Resource::LWRPBase
|
58
|
+
provides :site
|
59
|
+
resource_name :site
|
60
|
+
actions :create
|
61
|
+
attribute :name, :kind_of => String, :name_attribute => true
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class MyProviders
|
66
|
+
class Site < Chef::Provider::LWRPBase
|
67
|
+
provides :site
|
68
|
+
use_inline_resources
|
69
|
+
|
70
|
+
action :create do
|
71
|
+
file "/tmp/foo.txt"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
EOF
|
76
|
+
it { is_expected.not_to violate_rule }
|
77
|
+
end
|
78
|
+
|
79
|
+
context "with a cookbook with a library provider without use_inline_resources" do
|
80
|
+
library_file <<-EOF
|
81
|
+
class MyResources
|
82
|
+
class Site < Chef::Resource::LWRPBase
|
83
|
+
provides :site
|
84
|
+
resource_name :site
|
85
|
+
actions :create
|
86
|
+
attribute :name, :kind_of => String, :name_attribute => true
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
class MyProviders
|
91
|
+
class Site < Chef::Provider::LWRPBase
|
92
|
+
provides :site
|
93
|
+
|
94
|
+
action :create do
|
95
|
+
file "/tmp/foo.txt"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
EOF
|
100
|
+
it { is_expected.not_to violate_rule }
|
101
|
+
end
|
102
|
+
end
|