foodcritic-rackspace-rules 1.0.2 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  module Foodcritic
2
2
  module Rackspace
3
3
  module Rules
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
6
6
  end
7
7
  end
@@ -1,4 +1,4 @@
1
- require 'pp'
1
+ require 'yaml' # included in ruby
2
2
 
3
3
  rule 'RACK001', 'Missing "# Copyright" declaration' do
4
4
  tags %w(style rackspace)
@@ -15,7 +15,7 @@ rule 'RACK001', 'Missing "# Copyright" declaration' do
15
15
  # need to scan comments for this rule
16
16
  lines = File.readlines(recipe)
17
17
  next if lines.collect do |line|
18
- line.include?('# Copyright')
18
+ line.include?('# Copyright')
19
19
  end.compact.flatten.include? true
20
20
 
21
21
  matches << {
@@ -72,7 +72,7 @@ rule 'RACK003', 'Cookbook is missing a standard file' do
72
72
  tags %w(style rackspace)
73
73
 
74
74
  expected_files = %w(README.md metadata.rb LICENSE Gemfile Berksfile Rakefile Thorfile Guardfile .kitchen.yml .rubocop.yml )
75
-
75
+
76
76
  cookbook do |path|
77
77
  matches = []
78
78
  expected_files.each do |f|
@@ -88,3 +88,38 @@ rule 'RACK003', 'Cookbook is missing a standard file' do
88
88
  matches
89
89
  end # cookbook
90
90
  end # rule
91
+
92
+ rule 'RACK004', 'Cookbook is missing a default test suite' do
93
+ tags %w(style rackspace)
94
+
95
+ search_files = %w( .kitchen.yml .kitchen.local.yml )
96
+ default_suite_found = false
97
+
98
+ cookbook do |path|
99
+ matches = []
100
+
101
+ search_files.each do |f|
102
+ next unless File.exist?("#{path}/#{f}")
103
+
104
+ kitchen_config = YAML.load_file("#{path}/#{f}")
105
+
106
+ next if !kitchen_config.has_key?('suites')
107
+
108
+ kitchen_config['suites'].each do |test_suite|
109
+ next unless test_suite.has_key?('name')
110
+ default_suite_found = true if test_suite['name'] == 'default'
111
+ end
112
+ end
113
+
114
+ if !default_suite_found
115
+ matches << {
116
+ :filename => ".kitchen.local.yml",
117
+ :matched => 'missing default test suite',
118
+ :line => 0,
119
+ :column => 0
120
+ }
121
+ end
122
+
123
+ matches
124
+ end # cookbook
125
+ end # rule
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foodcritic-rackspace-rules
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-07-07 00:00:00.000000000 Z
12
+ date: 2014-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler