ridley 1.5.1 → 1.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b8eb6ddf42490fbb4276d36e8f6ef66ee111eed
4
- data.tar.gz: 87d75ce26e3c901c88fd0289b072b46d165241d7
3
+ metadata.gz: 357a447b0c4b262058be9489d458e8188f39dbff
4
+ data.tar.gz: bc003d0fb3b0070d5a4967c4a12134e38a790c72
5
5
  SHA512:
6
- metadata.gz: 5d8fac3ec1647f70ac6cb07eeb72fd4e12f984baf12a1244553092146d4ec2842629fbcf4e0d8624b0f14ee0703d7431d3e67b5ae24d93ec299c233820e02cb7
7
- data.tar.gz: 87170710eac228bc3901612687d02b0df49fd575770de79cbb1570ecd8351b107bb93ef254ec5aa086ac7decb415a1bbb754d7447463ef702e01b2660966a988
6
+ metadata.gz: a286321fd9a2146dcadd37f7f1462ae8904603feffb440fe8d32b3e1fe40e35d9f026c7630ade1bcb50e0d8fa9ac2777c1dfd65a370614051fa0f8cd7abec071
7
+ data.tar.gz: 4c490c386eda16cc1e0e46b9bd2e14142cbfdacd0f3330e7d78930a21f8bb4dca55ef08e12b726db30a0347c92243e32cb075e9da3cf97e5a060619564197591
data/.gitignore CHANGED
@@ -18,3 +18,5 @@ tmp
18
18
  *.sw[op]
19
19
  .DS_Store
20
20
  .rspec
21
+ .bin/
22
+ vendor/
@@ -260,7 +260,7 @@ module Ridley::Chef
260
260
  end
261
261
 
262
262
  def syntax_checker
263
- @syntax_checker ||= Cookbook::SyntaxCheck.new(path.to_s)
263
+ @syntax_checker ||= Cookbook::SyntaxCheck.new(path.to_s, chefignore)
264
264
  end
265
265
 
266
266
  # Determine if the given file should be ignored by the chefignore
@@ -82,13 +82,17 @@ module Ridley::Chef
82
82
  #
83
83
  # @param [String] cookbook_path
84
84
  # the (on disk) path to the cookbook
85
- def initialize(cookbook_path)
85
+ # @param [Ridley::Chef::Chefignore] chefignore
86
+ # the instance of R::C::Chefignore to filter out
87
+ def initialize(cookbook_path, chefignore = nil)
86
88
  @cookbook_path = cookbook_path
87
89
  @validated_files = PersistentSet.new
90
+ @chefignore = chefignore
88
91
  end
89
92
 
93
+
90
94
  def ruby_files
91
- Dir[File.join(cookbook_path, '**', '*.rb')]
95
+ Dir[File.join(cookbook_path, '**', '*.rb')].reject { |f| ignored?(f) }
92
96
  end
93
97
 
94
98
  def untested_ruby_files
@@ -96,7 +100,7 @@ module Ridley::Chef
96
100
  end
97
101
 
98
102
  def template_files
99
- Dir[File.join(cookbook_path, '**', '*.erb')]
103
+ Dir[File.join(cookbook_path, '**', '*.erb')].reject { |f| ignored?(f) }
100
104
  end
101
105
 
102
106
  def untested_template_files
@@ -116,6 +120,7 @@ module Ridley::Chef
116
120
  return false unless validate_ruby_file(ruby_file)
117
121
  validated(ruby_file)
118
122
  end
123
+ true
119
124
  end
120
125
 
121
126
  def validate_templates
@@ -123,6 +128,7 @@ module Ridley::Chef
123
128
  return false unless validate_template(template)
124
129
  validated(template)
125
130
  end
131
+ true
126
132
  end
127
133
 
128
134
  def validate_template(erb_file)
@@ -150,6 +156,15 @@ module Ridley::Chef
150
156
 
151
157
  true
152
158
  end
159
+
160
+ private
161
+
162
+ # @return [Ridley::Chef::Chefignore, nil]
163
+ attr_reader :chefignore
164
+
165
+ def ignored?(file)
166
+ !!chefignore && chefignore.ignored?(file)
167
+ end
153
168
  end
154
169
  end
155
170
  end
@@ -1,3 +1,3 @@
1
1
  module Ridley
2
- VERSION = "1.5.1"
2
+ VERSION = "1.5.2"
3
3
  end
@@ -1,3 +1,4 @@
1
1
  README.md
2
2
  Guardfile
3
3
  ignores/*.rb
4
+ ignores/*.erb
@@ -0,0 +1,4 @@
1
+ # I should never see this file
2
+ # It has bad ruby in it...
3
+
4
+ <%= this is not { valid %>
@@ -1 +1,4 @@
1
1
  # I should never see this file
2
+ # It has bad ruby in it...
3
+
4
+ this is not { valid
@@ -0,0 +1,127 @@
1
+ require 'spec_helper'
2
+
3
+ describe Ridley::Chef::Cookbook::SyntaxCheck do
4
+
5
+ let(:cookbook_dir) { fixtures_path.join('example_cookbook')}
6
+ let(:chefignore) { Ridley::Chef::Chefignore.new(cookbook_dir) }
7
+
8
+ let(:syntax_check) do
9
+ described_class.new(fixtures_path, chefignore)
10
+ end
11
+
12
+ subject { syntax_check }
13
+
14
+ before(:each) do
15
+ subject.stub(:chefignore) { chefignore }
16
+ end
17
+
18
+ describe "#ruby_files" do
19
+ it "lists the rb files in a cookbook" do
20
+ expect(subject.ruby_files).to include(cookbook_dir.join("libraries/my_lib.rb").to_s)
21
+ end
22
+
23
+ it "does not list the rb files in a cookbook that are ignored" do
24
+ expect(subject.ruby_files).not_to include(cookbook_dir.join("ignores/magic.rb").to_s)
25
+ end
26
+ end
27
+
28
+ describe "#untested_ruby_files" do
29
+ it "filters out validated rb files" do
30
+ valid_ruby_file = cookbook_dir.join("libraries/my_lib.rb").to_s
31
+ subject.validated(valid_ruby_file)
32
+ expect(subject.untested_ruby_files).not_to include(valid_ruby_file)
33
+ end
34
+ end
35
+
36
+ describe "#template_files" do
37
+ it "lists the erb files in a cookbook" do
38
+ expect(subject.template_files).to include(cookbook_dir.join("templates/default/temp.txt.erb").to_s)
39
+ end
40
+
41
+ it "does not list the erb files in a cookbook that are ignored" do
42
+ expect(subject.template_files).not_to include(cookbook_dir.join("ignores/magic.erb").to_s)
43
+ end
44
+ end
45
+
46
+ describe "#untested_template_files" do
47
+ it "filters out validated erb files" do
48
+ valid_template_file = cookbook_dir.join("templates/default/temp.txt.erb").to_s
49
+ subject.validated(valid_template_file)
50
+ expect(subject.untested_template_files).not_to include(valid_template_file)
51
+ end
52
+ end
53
+
54
+ describe "#validated?" do
55
+ it "checks if a file has already been validated" do
56
+ valid_template_file = cookbook_dir.join("templates/default/temp.txt.erb").to_s
57
+ subject.validated(valid_template_file)
58
+ expect(subject.validated?(valid_template_file)).to be_true
59
+ end
60
+ end
61
+
62
+ describe "#validated" do
63
+ let(:validated_files) { double('validated_files') }
64
+
65
+ before(:each) do
66
+ subject.stub(:validated_files) { validated_files }
67
+ end
68
+
69
+ it "records a file as validated" do
70
+ template_file = cookbook_dir.join("templates/default/temp.txt.erb").to_s
71
+ file_checksum = Ridley::Chef::Digester.checksum_for_file(template_file)
72
+
73
+ expect(validated_files).to receive(:add).with(file_checksum)
74
+ expect(subject.validated(template_file)).to be_nil
75
+ end
76
+ end
77
+
78
+ describe "#validate_ruby_files" do
79
+ it "asks #untested_ruby_files for a list of files and calls #validate_ruby_file on each" do
80
+ subject.stub(:validate_ruby_file).with(anything()).exactly(9).times { true }
81
+ expect(subject.validate_ruby_files).to be_true
82
+ end
83
+
84
+ it "marks the successfully validated ruby files" do
85
+ subject.stub(:validated).with(anything()).exactly(9).times
86
+ expect(subject.validate_ruby_files).to be_true
87
+ end
88
+
89
+ it "returns false if any ruby file fails to validate" do
90
+ subject.stub(:validate_ruby_file).with(/\.rb$/) { false }
91
+ expect(subject.validate_ruby_files).to be_false
92
+ end
93
+ end
94
+
95
+ describe "#validate_templates" do
96
+ it "asks #untested_template_files for a list of erb files and calls #validate_template on each" do
97
+ subject.stub(:validate_template).with(anything()).exactly(9).times { true }
98
+ expect(subject.validate_templates).to be_true
99
+ end
100
+
101
+ it "marks the successfully validated erb files" do
102
+ subject.stub(:validated).with(anything()).exactly(9).times
103
+ expect(subject.validate_templates).to be_true
104
+ end
105
+
106
+ it "returns false if any erb file fails to validate" do
107
+ subject.stub(:validate_template).with(/\.erb$/) { false }
108
+ expect(subject.validate_templates).to be_false
109
+ end
110
+ end
111
+
112
+ describe "#validate_template" do
113
+ it "asks #shell_out to check the files syntax"
114
+ end
115
+
116
+ describe "#validate_ruby_file" do
117
+ it "asks #shell_out to check the files syntax"
118
+ end
119
+
120
+ describe "without a chefignore" do
121
+ let(:chefignore) { nil }
122
+
123
+ it "the file listing still works" do
124
+ expect(subject.ruby_files).to include(cookbook_dir.join("libraries/my_lib.rb").to_s)
125
+ end
126
+ end
127
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ridley
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jamie Winsor
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-08 00:00:00.000000000 Z
12
+ date: 2013-08-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -387,6 +387,7 @@ files:
387
387
  - spec/fixtures/example_cookbook/definitions/bad_def.rb
388
388
  - spec/fixtures/example_cookbook/files/default/file.h
389
389
  - spec/fixtures/example_cookbook/files/ubuntu/file.h
390
+ - spec/fixtures/example_cookbook/ignores/magic.erb
390
391
  - spec/fixtures/example_cookbook/ignores/magic.rb
391
392
  - spec/fixtures/example_cookbook/ignores/ok.txt
392
393
  - spec/fixtures/example_cookbook/libraries/my_lib.rb
@@ -409,6 +410,7 @@ files:
409
410
  - spec/unit/ridley/bootstrap_context/windows_spec.rb
410
411
  - spec/unit/ridley/bootstrap_context_spec.rb
411
412
  - spec/unit/ridley/chef/chefignore_spec.rb
413
+ - spec/unit/ridley/chef/cookbook/syntax_check_spec.rb
412
414
  - spec/unit/ridley/chef/cookbook_spec.rb
413
415
  - spec/unit/ridley/chef/digester_spec.rb
414
416
  - spec/unit/ridley/chef_object_spec.rb
@@ -486,6 +488,7 @@ test_files:
486
488
  - spec/fixtures/example_cookbook/definitions/bad_def.rb
487
489
  - spec/fixtures/example_cookbook/files/default/file.h
488
490
  - spec/fixtures/example_cookbook/files/ubuntu/file.h
491
+ - spec/fixtures/example_cookbook/ignores/magic.erb
489
492
  - spec/fixtures/example_cookbook/ignores/magic.rb
490
493
  - spec/fixtures/example_cookbook/ignores/ok.txt
491
494
  - spec/fixtures/example_cookbook/libraries/my_lib.rb
@@ -508,6 +511,7 @@ test_files:
508
511
  - spec/unit/ridley/bootstrap_context/windows_spec.rb
509
512
  - spec/unit/ridley/bootstrap_context_spec.rb
510
513
  - spec/unit/ridley/chef/chefignore_spec.rb
514
+ - spec/unit/ridley/chef/cookbook/syntax_check_spec.rb
511
515
  - spec/unit/ridley/chef/cookbook_spec.rb
512
516
  - spec/unit/ridley/chef/digester_spec.rb
513
517
  - spec/unit/ridley/chef_object_spec.rb