foodcritic 14.3.0 → 15.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Rakefile +3 -3
- data/chef_dsl_metadata/{chef_13.11.3.json → chef_13.12.3.json} +0 -0
- data/chef_dsl_metadata/{chef_14.5.33.json → chef_14.7.17.json} +1231 -191
- data/foodcritic.gemspec +1 -1
- data/lib/foodcritic/api.rb +2 -2
- data/lib/foodcritic/domain.rb +2 -2
- data/lib/foodcritic/linter.rb +1 -1
- data/lib/foodcritic/rules/fc024.rb +1 -1
- data/lib/foodcritic/rules/fc042.rb +1 -1
- data/lib/foodcritic/version.rb +1 -1
- data/spec/functional/fc009_spec.rb +2 -2
- data/spec/unit/api_spec.rb +190 -190
- data/spec/unit/domain_spec.rb +3 -3
- data/spec/unit/linter_spec.rb +5 -5
- data/spec/unit/template_spec.rb +5 -5
- metadata +6 -12
- data/CHANGELOG.md +0 -780
- data/README.md +0 -79
- data/chef_dsl_metadata/chef_14.1.12.json +0 -26882
- data/chef_dsl_metadata/chef_14.2.0.json +0 -26904
- data/chef_dsl_metadata/chef_14.3.37.json +0 -27870
- data/chef_dsl_metadata/chef_14.4.56.json +0 -29761
data/foodcritic.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
Dir["misc/**/*"]
|
18
18
|
s.files += Dir["Rakefile"] + Dir["Gemfile"] + Dir["*.gemspec"]
|
19
19
|
s.files += Dir["spec/**/*"] + Dir["features/**/*"]
|
20
|
-
s.files += Dir["
|
20
|
+
s.files += Dir["LICENSE"] + Dir["man/*"]
|
21
21
|
|
22
22
|
s.add_dependency("cucumber-core", ">= 1.3", "< 4.0")
|
23
23
|
s.add_dependency("nokogiri", ">= 1.5", "< 2.0")
|
data/lib/foodcritic/api.rb
CHANGED
@@ -560,7 +560,7 @@ module FoodCritic
|
|
560
560
|
source = if file.to_s.split(File::SEPARATOR).include?("templates")
|
561
561
|
template_expressions_only(file)
|
562
562
|
else
|
563
|
-
File.read(file).encode("utf-8", "binary", :
|
563
|
+
File.read(file).encode("utf-8", "binary", undef: :replace)
|
564
564
|
end
|
565
565
|
begin
|
566
566
|
build_xml(Ripper::SexpBuilder.new(source).parse)
|
@@ -625,7 +625,7 @@ module FoodCritic
|
|
625
625
|
|
626
626
|
def template_expressions_only(file)
|
627
627
|
exprs = Template::ExpressionExtractor.new.extract(
|
628
|
-
File.read(file).encode("utf-8", "binary", :
|
628
|
+
File.read(file).encode("utf-8", "binary", undef: :replace)
|
629
629
|
)
|
630
630
|
lines = Array.new(exprs.map { |e| e[:line] }.max || 0, "")
|
631
631
|
exprs.each do |e|
|
data/lib/foodcritic/domain.rb
CHANGED
data/lib/foodcritic/linter.rb
CHANGED
@@ -9,7 +9,7 @@ module FoodCritic
|
|
9
9
|
|
10
10
|
# The default version that will be used to determine relevant rules. This
|
11
11
|
# can be over-ridden at the command line with the `--chef-version` option.
|
12
|
-
DEFAULT_CHEF_VERSION = "14.
|
12
|
+
DEFAULT_CHEF_VERSION = "14.7.17".freeze
|
13
13
|
attr_reader :chef_version
|
14
14
|
|
15
15
|
# Perform a lint check. This method is intended for use by the command-line
|
@@ -1,6 +1,6 @@
|
|
1
1
|
rule "FC024", "Consider adding platform equivalents" do
|
2
2
|
tags %w{portability}
|
3
|
-
RHEL = %w{centos redhat scientific oracle}
|
3
|
+
RHEL = %w{centos redhat scientific oracle}.freeze
|
4
4
|
recipe do |ast, filename|
|
5
5
|
next if Pathname.new(filename).basename.to_s == "metadata.rb"
|
6
6
|
metadata_path = Pathname.new(
|
data/lib/foodcritic/version.rb
CHANGED
@@ -11,8 +11,8 @@ describe "FC009" do
|
|
11
11
|
it { is_expected.not_to violate_rule }
|
12
12
|
end
|
13
13
|
|
14
|
-
context "on chef 13.
|
15
|
-
foodcritic_command("--chef-version", "13.
|
14
|
+
context "on chef 13.12.3 with a cookbook that uses ifconfig attributes introduced in 14.0" do
|
15
|
+
foodcritic_command("--chef-version", "13.12.3", "--no-progress", ".")
|
16
16
|
recipe_file <<-EOH
|
17
17
|
ifconfig 'foo' do
|
18
18
|
family 'inet'
|
data/spec/unit/api_spec.rb
CHANGED
@@ -62,24 +62,24 @@ describe FoodCritic::Api do
|
|
62
62
|
describe "#attribute_access" do
|
63
63
|
let(:ast) { double() }
|
64
64
|
it "returns empty if the provided ast does not support XPath" do
|
65
|
-
expect(api.attribute_access(nil, :
|
65
|
+
expect(api.attribute_access(nil, type: :vivified)).to be_empty
|
66
66
|
end
|
67
67
|
it "returns empty if the provided ast has no matches" do
|
68
68
|
expect(ast).to receive(:xpath).with(kind_of(String), kind_of(FoodCritic::Api::AttFilter)).and_return([]).exactly(3).times
|
69
69
|
[:vivified, :string, :symbol].each do |access_type|
|
70
|
-
expect(api.attribute_access(ast, :
|
70
|
+
expect(api.attribute_access(ast, type: access_type)).to be_empty
|
71
71
|
end
|
72
72
|
end
|
73
73
|
it "raises if the specified node type is not recognised" do
|
74
74
|
allow(ast).to receive(:xpath)
|
75
|
-
expect { api.attribute_access(ast, :
|
75
|
+
expect { api.attribute_access(ast, type: :cymbals) }.to raise_error ArgumentError
|
76
76
|
end
|
77
77
|
it "does not raise if the specified node type is valid" do
|
78
78
|
expect(ast).to receive(:xpath).with(/field/, FoodCritic::Api::AttFilter).and_return([])
|
79
79
|
expect(ast).to receive(:xpath).with(/symbol/, FoodCritic::Api::AttFilter).and_return([])
|
80
80
|
expect(ast).to receive(:xpath).with(/tstring_content/, FoodCritic::Api::AttFilter).and_return([])
|
81
81
|
[:vivified, :symbol, :string].each do |access_type|
|
82
|
-
api.attribute_access(ast, :
|
82
|
+
api.attribute_access(ast, type: access_type)
|
83
83
|
end
|
84
84
|
end
|
85
85
|
it "returns vivified attributes access" do
|
@@ -88,11 +88,11 @@ describe FoodCritic::Api do
|
|
88
88
|
expect(call).to receive(:xpath).with(/ident/).and_return(%w{node bar})
|
89
89
|
expect(call).to receive(:xpath).with(/@value/).and_return("foo")
|
90
90
|
expect(ast).to receive(:xpath).with(kind_of(String), kind_of(FoodCritic::Api::AttFilter)).and_return([call])
|
91
|
-
expect(api.attribute_access(ast, :
|
91
|
+
expect(api.attribute_access(ast, type: :vivified)).to eq [call]
|
92
92
|
end
|
93
93
|
it "doesn't flag searching for a node by name as symbol access" do
|
94
94
|
ast = parse_ast(%q{baz = search(:node, "name:#{node['foo']['bar']}")[0]})
|
95
|
-
expect(api.attribute_access(ast, :
|
95
|
+
expect(api.attribute_access(ast, type: :symbol)).to be_empty
|
96
96
|
end
|
97
97
|
describe :ignoring_attributes do
|
98
98
|
it "doesn't ignore run_state by default for backwards compatibility" do
|
@@ -101,23 +101,23 @@ describe FoodCritic::Api do
|
|
101
101
|
end
|
102
102
|
it "allows run_state to be ignored" do
|
103
103
|
ast = parse_ast("node.run_state['bar'] = 'baz'")
|
104
|
-
expect(api.attribute_access(ast, :
|
104
|
+
expect(api.attribute_access(ast, ignore: ["run_state"])).to be_empty
|
105
105
|
end
|
106
106
|
it "allows run_state to be ignored (symbols access)" do
|
107
107
|
ast = parse_ast("node.run_state[:bar] = 'baz'")
|
108
|
-
expect(api.attribute_access(ast, :
|
108
|
+
expect(api.attribute_access(ast, ignore: ["run_state"])).to be_empty
|
109
109
|
end
|
110
110
|
it "allows any attribute to be ignored" do
|
111
111
|
ast = parse_ast("node['bar'] = 'baz'")
|
112
|
-
expect(api.attribute_access(ast, :
|
112
|
+
expect(api.attribute_access(ast, ignore: ["bar"])).to be_empty
|
113
113
|
end
|
114
114
|
it "allows any attribute to be ignored (symbols access)" do
|
115
115
|
ast = parse_ast("node[:bar] = 'baz'")
|
116
|
-
expect(api.attribute_access(ast, :
|
116
|
+
expect(api.attribute_access(ast, ignore: ["bar"])).to be_empty
|
117
117
|
end
|
118
118
|
it "allows any attribute to be ignored (dot access)" do
|
119
119
|
ast = parse_ast("node.bar = 'baz'")
|
120
|
-
expect(api.attribute_access(ast, :
|
120
|
+
expect(api.attribute_access(ast, ignore: ["bar"])).to be_empty
|
121
121
|
end
|
122
122
|
it "includes the children of attributes" do
|
123
123
|
ast = parse_ast("node['foo']['bar'] = 'baz'")
|
@@ -125,18 +125,18 @@ describe FoodCritic::Api do
|
|
125
125
|
end
|
126
126
|
it "does not include children of removed attributes" do
|
127
127
|
ast = parse_ast("node['foo']['bar'] = 'baz'")
|
128
|
-
expect(api.attribute_access(ast, :
|
128
|
+
expect(api.attribute_access(ast, ignore: ["foo"])).to be_empty
|
129
129
|
end
|
130
130
|
it "coerces ignore values to enumerate them" do
|
131
131
|
ast = parse_ast("node.run_state['bar'] = 'baz'")
|
132
|
-
expect(api.attribute_access(ast, :
|
132
|
+
expect(api.attribute_access(ast, ignore: "run_state")).to be_empty
|
133
133
|
end
|
134
134
|
it "can ignore multiple attributes" do
|
135
135
|
ast = parse_ast(%q{
|
136
136
|
node['bar'] = 'baz'
|
137
137
|
node.foo = 'baz'
|
138
138
|
})
|
139
|
-
expect(api.attribute_access(ast, :
|
139
|
+
expect(api.attribute_access(ast, ignore: %w{foo bar})).to be_empty
|
140
140
|
end
|
141
141
|
end
|
142
142
|
end
|
@@ -404,11 +404,11 @@ describe FoodCritic::Api do
|
|
404
404
|
end
|
405
405
|
it "restricts by resource type when provided an array" do
|
406
406
|
expect(ast).to receive(:xpath).with("//method_add_block[command/ident[@value='file' or @value='template']][command/ident/@value != 'action']").and_return(["method_add_block"])
|
407
|
-
api.find_resources(ast, :
|
407
|
+
api.find_resources(ast, type: %w{file template})
|
408
408
|
end
|
409
409
|
it "restricts by resource type when provided a string" do
|
410
410
|
expect(ast).to receive(:xpath).with("//method_add_block[command/ident[@value='file']][command/ident/@value != 'action']").and_return(["method_add_block"])
|
411
|
-
api.find_resources(ast, :
|
411
|
+
api.find_resources(ast, type: "file")
|
412
412
|
end
|
413
413
|
it "does not restrict by resource type when not provided" do
|
414
414
|
expect(ast).to receive(:xpath).with("//method_add_block[command/ident][command/ident/@value != 'action']").and_return(["method_add_block"])
|
@@ -416,7 +416,7 @@ describe FoodCritic::Api do
|
|
416
416
|
end
|
417
417
|
it "allows resource type to be specified as :any" do
|
418
418
|
expect(ast).to receive(:xpath).with("//method_add_block[command/ident][command/ident/@value != 'action']").and_return(["method_add_block"])
|
419
|
-
api.find_resources(ast, :
|
419
|
+
api.find_resources(ast, type: :any)
|
420
420
|
end
|
421
421
|
it "returns any matches" do
|
422
422
|
expect(ast).to receive(:xpath).with(kind_of(String)).and_return(["method_add_block"])
|
@@ -460,10 +460,10 @@ describe FoodCritic::Api do
|
|
460
460
|
expect(api.included_recipes(ast)["foo::"].first).to respond_to :xpath
|
461
461
|
end
|
462
462
|
it "returns empty if asked to exclude statements with embedded expressions" do
|
463
|
-
expect(api.included_recipes(ast, :
|
463
|
+
expect(api.included_recipes(ast, with_partial_names: false)).to be_empty
|
464
464
|
end
|
465
465
|
it "returns the literals if asked to include statements with embedded expressions" do
|
466
|
-
expect(api.included_recipes(ast, :
|
466
|
+
expect(api.included_recipes(ast, with_partial_names: true).keys).to eq ["foo::"]
|
467
467
|
end
|
468
468
|
end
|
469
469
|
describe "embedded expression - cookbook name" do
|
@@ -479,7 +479,7 @@ describe FoodCritic::Api do
|
|
479
479
|
expect(api.included_recipes(ast)["::bar"].first).to respond_to :xpath
|
480
480
|
end
|
481
481
|
it "returns empty if asked to exclude statements with embedded expressions" do
|
482
|
-
expect(api.included_recipes(ast, :
|
482
|
+
expect(api.included_recipes(ast, with_partial_names: false)).to be_empty
|
483
483
|
end
|
484
484
|
end
|
485
485
|
describe "embedded expression - partial cookbook name" do
|
@@ -495,7 +495,7 @@ describe FoodCritic::Api do
|
|
495
495
|
expect(api.included_recipes(ast)["_foo::bar"].first).to respond_to :xpath
|
496
496
|
end
|
497
497
|
it "returns empty if asked to exclude statements with embedded expressions" do
|
498
|
-
expect(api.included_recipes(ast, :
|
498
|
+
expect(api.included_recipes(ast, with_partial_names: false)).to be_empty
|
499
499
|
end
|
500
500
|
end
|
501
501
|
end
|
@@ -565,11 +565,11 @@ describe FoodCritic::Api do
|
|
565
565
|
end
|
566
566
|
it "includes the name of the node in the match" do
|
567
567
|
expect(node).to receive(:name).and_return("command")
|
568
|
-
expect(api.match(node)).to eq({ :
|
569
|
-
:
|
568
|
+
expect(api.match(node)).to eq({ matched: "command", line: 1,
|
569
|
+
column: 10 })
|
570
570
|
end
|
571
571
|
it "sets the matched name to empty if the element does not have a name" do
|
572
|
-
expect(api.match(node)).to eq({ :
|
572
|
+
expect(api.match(node)).to eq({ matched: "", line: 1, column: 10 })
|
573
573
|
end
|
574
574
|
end
|
575
575
|
end
|
@@ -804,12 +804,12 @@ describe FoodCritic::Api do
|
|
804
804
|
end
|
805
805
|
})
|
806
806
|
expect(api.notifications(ast)).to eq [{
|
807
|
-
:
|
808
|
-
:
|
809
|
-
:
|
810
|
-
:
|
811
|
-
:
|
812
|
-
:
|
807
|
+
type: :notifies,
|
808
|
+
action: :restart,
|
809
|
+
resource_type: :service,
|
810
|
+
resource_name: "nscd",
|
811
|
+
timing: :delayed,
|
812
|
+
style: :old,
|
813
813
|
}]
|
814
814
|
end
|
815
815
|
it "understands old-style notifications with :'symbol' literals as action" do
|
@@ -822,12 +822,12 @@ describe FoodCritic::Api do
|
|
822
822
|
end
|
823
823
|
})
|
824
824
|
expect(api.notifications(ast)).to eq [{
|
825
|
-
:
|
826
|
-
:
|
827
|
-
:
|
828
|
-
:
|
829
|
-
:
|
830
|
-
:
|
825
|
+
type: :notifies,
|
826
|
+
action: :'soft-restart',
|
827
|
+
resource_type: :service,
|
828
|
+
resource_name: "nscd",
|
829
|
+
timing: :delayed,
|
830
|
+
style: :old,
|
831
831
|
}]
|
832
832
|
end
|
833
833
|
it "understands old-style notifications with added parentheses" do
|
@@ -840,12 +840,12 @@ describe FoodCritic::Api do
|
|
840
840
|
end
|
841
841
|
})
|
842
842
|
expect(api.notifications(ast)).to eq [{
|
843
|
-
:
|
844
|
-
:
|
845
|
-
:
|
846
|
-
:
|
847
|
-
:
|
848
|
-
:
|
843
|
+
type: :notifies,
|
844
|
+
action: :restart,
|
845
|
+
resource_type: :service,
|
846
|
+
resource_name: "nscd",
|
847
|
+
timing: :delayed,
|
848
|
+
style: :old,
|
849
849
|
}]
|
850
850
|
end
|
851
851
|
it "understands old-style notifications with ruby 1.9 hash syntax" do
|
@@ -858,12 +858,12 @@ describe FoodCritic::Api do
|
|
858
858
|
end
|
859
859
|
})
|
860
860
|
expect(api.notifications(ast)).to eq [{
|
861
|
-
:
|
862
|
-
:
|
863
|
-
:
|
864
|
-
:
|
865
|
-
:
|
866
|
-
:
|
861
|
+
type: :notifies,
|
862
|
+
action: :restart,
|
863
|
+
resource_type: :service,
|
864
|
+
resource_name: "nscd",
|
865
|
+
timing: :delayed,
|
866
|
+
style: :old,
|
867
867
|
}]
|
868
868
|
end
|
869
869
|
it "understands the old-style subscriptions" do
|
@@ -876,12 +876,12 @@ describe FoodCritic::Api do
|
|
876
876
|
end
|
877
877
|
})
|
878
878
|
expect(api.notifications(ast)).to eq [{
|
879
|
-
:
|
880
|
-
:
|
881
|
-
:
|
882
|
-
:
|
883
|
-
:
|
884
|
-
:
|
879
|
+
type: :subscribes,
|
880
|
+
action: :restart,
|
881
|
+
resource_type: :service,
|
882
|
+
resource_name: "nscd",
|
883
|
+
timing: :delayed,
|
884
|
+
style: :old,
|
885
885
|
}]
|
886
886
|
end
|
887
887
|
it "understands old-style subscriptions with added parentheses" do
|
@@ -894,12 +894,12 @@ describe FoodCritic::Api do
|
|
894
894
|
end
|
895
895
|
})
|
896
896
|
expect(api.notifications(ast)).to eq [{
|
897
|
-
:
|
898
|
-
:
|
899
|
-
:
|
900
|
-
:
|
901
|
-
:
|
902
|
-
:
|
897
|
+
type: :subscribes,
|
898
|
+
action: :restart,
|
899
|
+
resource_type: :service,
|
900
|
+
resource_name: "nscd",
|
901
|
+
timing: :delayed,
|
902
|
+
style: :old,
|
903
903
|
}]
|
904
904
|
end
|
905
905
|
it "understands the new-style notifications" do
|
@@ -912,12 +912,12 @@ describe FoodCritic::Api do
|
|
912
912
|
end
|
913
913
|
})
|
914
914
|
expect(api.notifications(ast)).to eq [{
|
915
|
-
:
|
916
|
-
:
|
917
|
-
:
|
918
|
-
:
|
919
|
-
:
|
920
|
-
:
|
915
|
+
type: :notifies,
|
916
|
+
action: :restart,
|
917
|
+
resource_type: :service,
|
918
|
+
resource_name: "nscd",
|
919
|
+
timing: :delayed,
|
920
|
+
style: :new,
|
921
921
|
}]
|
922
922
|
end
|
923
923
|
it "understands new-style notifications with :'symbol' literals as action" do
|
@@ -930,12 +930,12 @@ describe FoodCritic::Api do
|
|
930
930
|
end
|
931
931
|
})
|
932
932
|
expect(api.notifications(ast)).to eq [{
|
933
|
-
:
|
934
|
-
:
|
935
|
-
:
|
936
|
-
:
|
937
|
-
:
|
938
|
-
:
|
933
|
+
type: :notifies,
|
934
|
+
action: :'soft-restart',
|
935
|
+
resource_type: :service,
|
936
|
+
resource_name: "nscd",
|
937
|
+
timing: :delayed,
|
938
|
+
style: :new,
|
939
939
|
}]
|
940
940
|
end
|
941
941
|
it "understands new-style notifications with added parentheses" do
|
@@ -948,12 +948,12 @@ describe FoodCritic::Api do
|
|
948
948
|
end
|
949
949
|
})
|
950
950
|
expect(api.notifications(ast)).to eq [{
|
951
|
-
:
|
952
|
-
:
|
953
|
-
:
|
954
|
-
:
|
955
|
-
:
|
956
|
-
:
|
951
|
+
type: :notifies,
|
952
|
+
action: :restart,
|
953
|
+
resource_type: :service,
|
954
|
+
resource_name: "nscd",
|
955
|
+
timing: :delayed,
|
956
|
+
style: :new,
|
957
957
|
}]
|
958
958
|
end
|
959
959
|
it "understands the new-style subscriptions" do
|
@@ -966,12 +966,12 @@ describe FoodCritic::Api do
|
|
966
966
|
end
|
967
967
|
})
|
968
968
|
expect(api.notifications(ast)).to eq [{
|
969
|
-
:
|
970
|
-
:
|
971
|
-
:
|
972
|
-
:
|
973
|
-
:
|
974
|
-
:
|
969
|
+
type: :subscribes,
|
970
|
+
action: :restart,
|
971
|
+
resource_type: :service,
|
972
|
+
resource_name: "nscd",
|
973
|
+
timing: :delayed,
|
974
|
+
style: :new,
|
975
975
|
}]
|
976
976
|
end
|
977
977
|
it "understands new-style subscriptions with added parentheses" do
|
@@ -984,12 +984,12 @@ describe FoodCritic::Api do
|
|
984
984
|
end
|
985
985
|
})
|
986
986
|
expect(api.notifications(ast)).to eq [{
|
987
|
-
:
|
988
|
-
:
|
989
|
-
:
|
990
|
-
:
|
991
|
-
:
|
992
|
-
:
|
987
|
+
type: :subscribes,
|
988
|
+
action: :restart,
|
989
|
+
resource_type: :service,
|
990
|
+
resource_name: "nscd",
|
991
|
+
timing: :delayed,
|
992
|
+
style: :new,
|
993
993
|
}]
|
994
994
|
end
|
995
995
|
describe "supports a resource both notifying and subscribing" do
|
@@ -1005,20 +1005,20 @@ describe FoodCritic::Api do
|
|
1005
1005
|
})
|
1006
1006
|
expect(api.notifications(ast)).to eq [
|
1007
1007
|
{
|
1008
|
-
:
|
1009
|
-
:
|
1010
|
-
:
|
1011
|
-
:
|
1012
|
-
:
|
1013
|
-
:
|
1008
|
+
type: :notifies,
|
1009
|
+
action: :restart,
|
1010
|
+
resource_type: :service,
|
1011
|
+
resource_name: "nscd",
|
1012
|
+
timing: :delayed,
|
1013
|
+
style: :old,
|
1014
1014
|
},
|
1015
1015
|
{
|
1016
|
-
:
|
1017
|
-
:
|
1018
|
-
:
|
1019
|
-
:
|
1020
|
-
:
|
1021
|
-
:
|
1016
|
+
type: :subscribes,
|
1017
|
+
action: :create,
|
1018
|
+
resource_type: :template,
|
1019
|
+
resource_name: "/etc/nscd.conf",
|
1020
|
+
timing: :delayed,
|
1021
|
+
style: :old,
|
1022
1022
|
},
|
1023
1023
|
]
|
1024
1024
|
end
|
@@ -1034,20 +1034,20 @@ describe FoodCritic::Api do
|
|
1034
1034
|
})
|
1035
1035
|
expect(api.notifications(ast)).to eq [
|
1036
1036
|
{
|
1037
|
-
:
|
1038
|
-
:
|
1039
|
-
:
|
1040
|
-
:
|
1041
|
-
:
|
1042
|
-
:
|
1037
|
+
type: :notifies,
|
1038
|
+
action: :restart,
|
1039
|
+
resource_type: :service,
|
1040
|
+
resource_name: "nscd",
|
1041
|
+
timing: :delayed,
|
1042
|
+
style: :new,
|
1043
1043
|
},
|
1044
1044
|
{
|
1045
|
-
:
|
1046
|
-
:
|
1047
|
-
:
|
1048
|
-
:
|
1049
|
-
:
|
1050
|
-
:
|
1045
|
+
type: :subscribes,
|
1046
|
+
action: :create,
|
1047
|
+
resource_type: :template,
|
1048
|
+
resource_name: "/etc/nscd.conf",
|
1049
|
+
timing: :delayed,
|
1050
|
+
style: :new,
|
1051
1051
|
},
|
1052
1052
|
]
|
1053
1053
|
end
|
@@ -1062,12 +1062,12 @@ describe FoodCritic::Api do
|
|
1062
1062
|
end
|
1063
1063
|
})
|
1064
1064
|
expect(api.notifications(ast)).to eq [{
|
1065
|
-
:
|
1066
|
-
:
|
1067
|
-
:
|
1068
|
-
:
|
1069
|
-
:
|
1070
|
-
:
|
1065
|
+
type: :notifies,
|
1066
|
+
action: :restart,
|
1067
|
+
resource_type: :service,
|
1068
|
+
resource_name: "nscd",
|
1069
|
+
timing: :immediate,
|
1070
|
+
style: :old,
|
1071
1071
|
}]
|
1072
1072
|
end
|
1073
1073
|
it "understands the old-style subscriptions with timing" do
|
@@ -1080,12 +1080,12 @@ describe FoodCritic::Api do
|
|
1080
1080
|
end
|
1081
1081
|
})
|
1082
1082
|
expect(api.notifications(ast)).to eq [{
|
1083
|
-
:
|
1084
|
-
:
|
1085
|
-
:
|
1086
|
-
:
|
1087
|
-
:
|
1088
|
-
:
|
1083
|
+
type: :subscribes,
|
1084
|
+
action: :restart,
|
1085
|
+
resource_type: :service,
|
1086
|
+
resource_name: "nscd",
|
1087
|
+
timing: :immediate,
|
1088
|
+
style: :old,
|
1089
1089
|
}]
|
1090
1090
|
end
|
1091
1091
|
it "understands the new-style notifications with timing" do
|
@@ -1098,12 +1098,12 @@ describe FoodCritic::Api do
|
|
1098
1098
|
end
|
1099
1099
|
})
|
1100
1100
|
expect(api.notifications(ast)).to eq [{
|
1101
|
-
:
|
1102
|
-
:
|
1103
|
-
:
|
1104
|
-
:
|
1105
|
-
:
|
1106
|
-
:
|
1101
|
+
type: :notifies,
|
1102
|
+
action: :restart,
|
1103
|
+
resource_type: :service,
|
1104
|
+
resource_name: "nscd",
|
1105
|
+
timing: :immediate,
|
1106
|
+
style: :new,
|
1107
1107
|
}]
|
1108
1108
|
end
|
1109
1109
|
it "understands the new-style subscriptions with timing" do
|
@@ -1116,12 +1116,12 @@ describe FoodCritic::Api do
|
|
1116
1116
|
end
|
1117
1117
|
})
|
1118
1118
|
expect(api.notifications(ast)).to eq [{
|
1119
|
-
:
|
1120
|
-
:
|
1121
|
-
:
|
1122
|
-
:
|
1123
|
-
:
|
1124
|
-
:
|
1119
|
+
type: :subscribes,
|
1120
|
+
action: :restart,
|
1121
|
+
resource_type: :service,
|
1122
|
+
resource_name: "nscd",
|
1123
|
+
timing: :immediate,
|
1124
|
+
style: :new,
|
1125
1125
|
}]
|
1126
1126
|
end
|
1127
1127
|
describe "can be passed an individual resource" do
|
@@ -1137,10 +1137,10 @@ describe FoodCritic::Api do
|
|
1137
1137
|
notifies :restart, resources(:service => "nscd")
|
1138
1138
|
end
|
1139
1139
|
})
|
1140
|
-
expect(api.notifications(api.find_resources(ast, :
|
1141
|
-
{ :
|
1142
|
-
:
|
1143
|
-
:
|
1140
|
+
expect(api.notifications(api.find_resources(ast, type: :template).first)).to eq [
|
1141
|
+
{ type: :notifies, action: :restart, resource_type: :service,
|
1142
|
+
resource_name: "nscd", timing: :delayed,
|
1143
|
+
style: :old },
|
1144
1144
|
]
|
1145
1145
|
end
|
1146
1146
|
it "old-style subscriptions" do
|
@@ -1155,10 +1155,10 @@ describe FoodCritic::Api do
|
|
1155
1155
|
subscribes :restart, resources(:service => "nscd")
|
1156
1156
|
end
|
1157
1157
|
})
|
1158
|
-
expect(api.notifications(api.find_resources(ast, :
|
1159
|
-
{ :
|
1160
|
-
:
|
1161
|
-
:
|
1158
|
+
expect(api.notifications(api.find_resources(ast, type: :template).first)).to eq [
|
1159
|
+
{ type: :subscribes, action: :restart, resource_type: :service,
|
1160
|
+
resource_name: "nscd", timing: :delayed,
|
1161
|
+
style: :old },
|
1162
1162
|
]
|
1163
1163
|
end
|
1164
1164
|
it "new-style notifications" do
|
@@ -1173,10 +1173,10 @@ describe FoodCritic::Api do
|
|
1173
1173
|
notifies :restart, "service[nscd]"
|
1174
1174
|
end
|
1175
1175
|
})
|
1176
|
-
expect(api.notifications(api.find_resources(ast, :
|
1177
|
-
{ :
|
1178
|
-
:
|
1179
|
-
:
|
1176
|
+
expect(api.notifications(api.find_resources(ast, type: :template).first)).to eq [
|
1177
|
+
{ type: :notifies, action: :restart, resource_type: :service,
|
1178
|
+
resource_name: "nscd", timing: :delayed,
|
1179
|
+
style: :new },
|
1180
1180
|
]
|
1181
1181
|
end
|
1182
1182
|
it "new-style subscriptions" do
|
@@ -1191,10 +1191,10 @@ describe FoodCritic::Api do
|
|
1191
1191
|
subscribes :restart, "service[nscd]"
|
1192
1192
|
end
|
1193
1193
|
})
|
1194
|
-
expect(api.notifications(api.find_resources(ast, :
|
1195
|
-
{ :
|
1196
|
-
:
|
1197
|
-
:
|
1194
|
+
expect(api.notifications(api.find_resources(ast, type: :template).first)).to eq [
|
1195
|
+
{ type: :subscribes, action: :restart, resource_type: :service,
|
1196
|
+
resource_name: "nscd", timing: :delayed,
|
1197
|
+
style: :new },
|
1198
1198
|
]
|
1199
1199
|
end
|
1200
1200
|
end
|
@@ -1210,12 +1210,12 @@ describe FoodCritic::Api do
|
|
1210
1210
|
end
|
1211
1211
|
})
|
1212
1212
|
expect(api.notifications(ast)).to eq [
|
1213
|
-
{ :
|
1214
|
-
:
|
1215
|
-
:
|
1216
|
-
{ :
|
1217
|
-
:
|
1218
|
-
:
|
1213
|
+
{ type: :notifies, action: :stop, resource_type: :service,
|
1214
|
+
resource_name: "nscd", timing: :delayed,
|
1215
|
+
style: :old },
|
1216
|
+
{ type: :notifies, action: :start, resource_type: :service,
|
1217
|
+
resource_name: "nscd", timing: :delayed,
|
1218
|
+
style: :old },
|
1219
1219
|
]
|
1220
1220
|
end
|
1221
1221
|
it "old-style subscriptions" do
|
@@ -1229,12 +1229,12 @@ describe FoodCritic::Api do
|
|
1229
1229
|
end
|
1230
1230
|
})
|
1231
1231
|
expect(api.notifications(ast)).to eq [
|
1232
|
-
{ :
|
1233
|
-
:
|
1234
|
-
:
|
1235
|
-
{ :
|
1236
|
-
:
|
1237
|
-
:
|
1232
|
+
{ type: :subscribes, action: :stop, resource_type: :service,
|
1233
|
+
resource_name: "nscd", timing: :delayed,
|
1234
|
+
style: :old },
|
1235
|
+
{ type: :subscribes, action: :start, resource_type: :service,
|
1236
|
+
resource_name: "nscd", timing: :delayed,
|
1237
|
+
style: :old },
|
1238
1238
|
]
|
1239
1239
|
end
|
1240
1240
|
it "new-style notifications" do
|
@@ -1248,12 +1248,12 @@ describe FoodCritic::Api do
|
|
1248
1248
|
end
|
1249
1249
|
})
|
1250
1250
|
expect(api.notifications(ast)).to eq [
|
1251
|
-
{ :
|
1252
|
-
:
|
1253
|
-
:
|
1254
|
-
{ :
|
1255
|
-
:
|
1256
|
-
:
|
1251
|
+
{ type: :notifies, action: :stop, resource_type: :service,
|
1252
|
+
resource_name: "nscd", timing: :delayed,
|
1253
|
+
style: :new },
|
1254
|
+
{ type: :notifies, action: :start, resource_type: :service,
|
1255
|
+
resource_name: "nscd", timing: :delayed,
|
1256
|
+
style: :new },
|
1257
1257
|
]
|
1258
1258
|
end
|
1259
1259
|
it "new-style subscriptions" do
|
@@ -1267,12 +1267,12 @@ describe FoodCritic::Api do
|
|
1267
1267
|
end
|
1268
1268
|
})
|
1269
1269
|
expect(api.notifications(ast)).to eq [
|
1270
|
-
{ :
|
1271
|
-
:
|
1272
|
-
:
|
1273
|
-
{ :
|
1274
|
-
:
|
1275
|
-
:
|
1270
|
+
{ type: :subscribes, action: :stop, resource_type: :service,
|
1271
|
+
resource_name: "nscd", timing: :delayed,
|
1272
|
+
style: :new },
|
1273
|
+
{ type: :subscribes, action: :start, resource_type: :service,
|
1274
|
+
resource_name: "nscd", timing: :delayed,
|
1275
|
+
style: :new },
|
1276
1276
|
]
|
1277
1277
|
end
|
1278
1278
|
end
|
@@ -1285,9 +1285,9 @@ describe FoodCritic::Api do
|
|
1285
1285
|
end
|
1286
1286
|
})
|
1287
1287
|
expect(api.notifications(ast)).to eq [
|
1288
|
-
{ :
|
1289
|
-
:
|
1290
|
-
:
|
1288
|
+
{ type: :notifies, action: :run, resource_type: :execute,
|
1289
|
+
resource_name: "foo", timing: :delayed,
|
1290
|
+
style: :old },
|
1291
1291
|
]
|
1292
1292
|
end
|
1293
1293
|
it "old-style subscriptions" do
|
@@ -1298,9 +1298,9 @@ describe FoodCritic::Api do
|
|
1298
1298
|
end
|
1299
1299
|
})
|
1300
1300
|
expect(api.notifications(ast)).to eq [
|
1301
|
-
{ :
|
1302
|
-
:
|
1303
|
-
:
|
1301
|
+
{ type: :subscribes, action: :run, resource_type: :execute,
|
1302
|
+
resource_name: "foo", timing: :delayed,
|
1303
|
+
style: :old },
|
1304
1304
|
]
|
1305
1305
|
end
|
1306
1306
|
it "old-style notifications" do
|
@@ -1311,9 +1311,9 @@ describe FoodCritic::Api do
|
|
1311
1311
|
end
|
1312
1312
|
})
|
1313
1313
|
expect(api.notifications(ast)).to eq [
|
1314
|
-
{ :
|
1315
|
-
:
|
1316
|
-
:
|
1314
|
+
{ type: :notifies, action: :run, resource_type: :execute,
|
1315
|
+
resource_name: "foo", timing: :delayed,
|
1316
|
+
style: :new },
|
1317
1317
|
]
|
1318
1318
|
end
|
1319
1319
|
it "old-style subscriptions" do
|
@@ -1324,9 +1324,9 @@ describe FoodCritic::Api do
|
|
1324
1324
|
end
|
1325
1325
|
})
|
1326
1326
|
expect(api.notifications(ast)).to eq [
|
1327
|
-
{ :
|
1328
|
-
:
|
1329
|
-
:
|
1327
|
+
{ type: :subscribes, action: :run, resource_type: :execute,
|
1328
|
+
resource_name: "foo", timing: :delayed,
|
1329
|
+
style: :new },
|
1330
1330
|
]
|
1331
1331
|
end
|
1332
1332
|
end
|