guard-strainer 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +3 -0
  4. data/CONTRIBUTING.md +29 -0
  5. data/Gemfile +12 -0
  6. data/Guardfile +6 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +51 -0
  9. data/Rakefile +34 -0
  10. data/guard-strainer.gemspec +25 -0
  11. data/lib/guard/strainer.rb +112 -0
  12. data/lib/guard/strainer/runner.rb +48 -0
  13. data/lib/guard/strainer/templates/Guardfile +7 -0
  14. data/lib/guard/strainer/version.rb +5 -0
  15. data/spec/fixtures/cookbooks/git/.gitignore +14 -0
  16. data/spec/fixtures/cookbooks/git/.kitchen.yml +46 -0
  17. data/spec/fixtures/cookbooks/git/Berksfile +8 -0
  18. data/spec/fixtures/cookbooks/git/CHANGELOG.md +76 -0
  19. data/spec/fixtures/cookbooks/git/CONTRIBUTING +29 -0
  20. data/spec/fixtures/cookbooks/git/Gemfile +3 -0
  21. data/spec/fixtures/cookbooks/git/LICENSE +201 -0
  22. data/spec/fixtures/cookbooks/git/README.md +115 -0
  23. data/spec/fixtures/cookbooks/git/TESTING.md +25 -0
  24. data/spec/fixtures/cookbooks/git/attributes/default.rb +40 -0
  25. data/spec/fixtures/cookbooks/git/metadata.rb +35 -0
  26. data/spec/fixtures/cookbooks/git/recipes/default.rb +46 -0
  27. data/spec/fixtures/cookbooks/git/recipes/server.rb +57 -0
  28. data/spec/fixtures/cookbooks/git/recipes/source.rb +49 -0
  29. data/spec/fixtures/cookbooks/git/recipes/windows.rb +32 -0
  30. data/spec/fixtures/cookbooks/git/templates/default/git-xinetd.d.erb +10 -0
  31. data/spec/fixtures/cookbooks/git/templates/default/sv-git-daemon-log-run.erb +2 -0
  32. data/spec/fixtures/cookbooks/git/templates/default/sv-git-daemon-run.erb +3 -0
  33. data/spec/fixtures/cookbooks/sudo/.chef/knife.rb +1 -0
  34. data/spec/fixtures/cookbooks/sudo/.gitignore +14 -0
  35. data/spec/fixtures/cookbooks/sudo/.kitchen.yml +35 -0
  36. data/spec/fixtures/cookbooks/sudo/.rspec +2 -0
  37. data/spec/fixtures/cookbooks/sudo/Berksfile +8 -0
  38. data/spec/fixtures/cookbooks/sudo/CHANGELOG.md +63 -0
  39. data/spec/fixtures/cookbooks/sudo/CONTRIBUTING.md +257 -0
  40. data/spec/fixtures/cookbooks/sudo/Gemfile +12 -0
  41. data/spec/fixtures/cookbooks/sudo/LICENSE +201 -0
  42. data/spec/fixtures/cookbooks/sudo/README.md +229 -0
  43. data/spec/fixtures/cookbooks/sudo/TESTING.md +25 -0
  44. data/spec/fixtures/cookbooks/sudo/attributes/default.rb +25 -0
  45. data/spec/fixtures/cookbooks/sudo/files/default/README +17 -0
  46. data/spec/fixtures/cookbooks/sudo/metadata.rb +46 -0
  47. data/spec/fixtures/cookbooks/sudo/providers/default.rb +135 -0
  48. data/spec/fixtures/cookbooks/sudo/recipes/default.rb +54 -0
  49. data/spec/fixtures/cookbooks/sudo/resources/default.rb +38 -0
  50. data/spec/fixtures/cookbooks/sudo/templates/default/sudoer.erb +6 -0
  51. data/spec/fixtures/cookbooks/sudo/templates/default/sudoers.erb +26 -0
  52. data/spec/fixtures/cookbooks/tmux/.chef/knife.rb +2 -0
  53. data/spec/fixtures/cookbooks/tmux/.gitignore +1 -0
  54. data/spec/fixtures/cookbooks/tmux/.travis.yml +7 -0
  55. data/spec/fixtures/cookbooks/tmux/CHANGELOG.md +39 -0
  56. data/spec/fixtures/cookbooks/tmux/CONTRIBUTING.md +257 -0
  57. data/spec/fixtures/cookbooks/tmux/Gemfile +6 -0
  58. data/spec/fixtures/cookbooks/tmux/LICENSE +201 -0
  59. data/spec/fixtures/cookbooks/tmux/README.md +52 -0
  60. data/spec/fixtures/cookbooks/tmux/Rakefile +34 -0
  61. data/spec/fixtures/cookbooks/tmux/attributes/default.rb +15 -0
  62. data/spec/fixtures/cookbooks/tmux/metadata.rb +7 -0
  63. data/spec/fixtures/cookbooks/tmux/recipes/default.rb +33 -0
  64. data/spec/fixtures/cookbooks/tmux/recipes/package.rb +5 -0
  65. data/spec/fixtures/cookbooks/tmux/recipes/source.rb +45 -0
  66. data/spec/fixtures/cookbooks/tmux/templates/default/tmux.conf.erb +35 -0
  67. data/spec/fixtures/cookbooks/tmux/test/kitchen/Kitchenfile +6 -0
  68. data/spec/guard/strainer/runner_spec.rb +66 -0
  69. data/spec/guard/strainer_spec.rb +114 -0
  70. data/spec/spec_helper.rb +24 -0
  71. metadata +213 -0
@@ -0,0 +1,66 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::Strainer::Runner do
4
+ subject { described_class.new({}) }
5
+
6
+ let(:paths) { ['spec/fixtures/cookbooks/git/recipes/default.rb',
7
+ 'spec/fixtures/cookbooks/sudo/metadata.rb',
8
+ 'spec/fixtures/cookbooks/tmux/metadata.rb'] }
9
+ let(:strainerfile) { File.join(@fixture_path, 'Strainerfile') }
10
+ let(:cookbooks) { [Pathname.new('git'), Pathname.new('sudo'), Pathname.new('tmux')] }
11
+ let(:runner) { mock(::Strainer::Runner) }
12
+
13
+ before do
14
+ ::Guard::Dsl.stub(:options) { {"guardfile_path" => File.join(@fixture_path, 'fixtures')} }
15
+ ::Strainer::Runner.stub(:new => runner)
16
+ runner.stub(:run!)
17
+
18
+ # Do this so the runner is using the correct shell
19
+ ::Thor::Base.shell = ::Strainer::Shell
20
+ end
21
+
22
+ describe '#initialize' do
23
+ it 'creates an empty cabinet' do
24
+ expect(subject.cabinet).to be_empty
25
+ end
26
+ end
27
+
28
+ describe '#run_all!' do
29
+ before do
30
+ @paths = paths
31
+ @paths[0] = 'spec/fixtures/cookbooks/git/metadata.rb'
32
+ @paths.sort!
33
+ end
34
+ it 'should strain all of the cookbooks' do
35
+ subject.should_receive(:run!).with(@paths)
36
+
37
+ subject.run_all!
38
+ end
39
+ end
40
+
41
+ describe '#run!' do
42
+ context 'the first time a given cookbook set is run' do
43
+ before do
44
+ subject.cabinet.clear
45
+ end
46
+
47
+ it 'should create a new Strainer::Runner and store it in the cabinet' do
48
+ ::Strainer::Runner.should_receive(:new).with(cookbooks, {:strainer_file => strainerfile})
49
+
50
+ subject.run!(paths)
51
+ end
52
+ end
53
+
54
+ context 'subsequent times a given cookbook set is run' do
55
+ before do
56
+ subject.cabinet[cookbooks] = runner
57
+ end
58
+
59
+ it 'should retrieve the Strainer::Runner from the cabinet' do
60
+ ::Strainer::Runner.should_not_receive(:new)
61
+
62
+ subject.run!(paths)
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,114 @@
1
+ require 'spec_helper'
2
+
3
+ describe Guard::Strainer do
4
+ let(:default_options) do
5
+ {
6
+ :all_on_pass => true, :all_on_start => true, :fail_fast => true,
7
+ :standalone => false
8
+ }
9
+ end
10
+ subject { described_class.new }
11
+
12
+ let(:runner) { mock(described_class::Runner, :set_rspec_version => nil, :rspec_version => nil) }
13
+ let(:paths) { ['cookbooks/foobar', 'cookbooks/banjo', 'cookbooks/kerbam'] }
14
+
15
+ before do
16
+ described_class::Runner.stub(:new => runner)
17
+ end
18
+
19
+ describe '#initialize' do
20
+ it 'creates a runner' do
21
+ described_class::Runner.should_receive(:new).with(default_options.merge(:foo => :bar))
22
+ described_class.new([], :foo => :bar)
23
+ end
24
+ end
25
+
26
+ describe '#start' do
27
+ it "calls #run_all" do
28
+ subject.should_receive(:run_all)
29
+ subject.start
30
+ end
31
+
32
+ context ':all_on_start option is false' do
33
+ let(:subject) { subject = described_class.new([], :all_on_start => false) }
34
+
35
+ it "doesn't call #run_all" do
36
+ subject.should_not_receive(:run_all)
37
+ subject.start
38
+ end
39
+ end
40
+ end
41
+
42
+ describe '#run_all' do
43
+ it 'strains all cookbooks' do
44
+ runner.should_receive(:run_all!) { true }
45
+
46
+ subject.run_all
47
+ end
48
+
49
+ it 'throws task_has_failed if the strain fails' do
50
+ runner.should_receive(:run_all!) { false }
51
+
52
+ expect { subject.run_all }.to throw_symbol :task_has_failed
53
+ end
54
+ end
55
+
56
+ describe '#run' do
57
+ before do
58
+ runner.stub(:run_all!)
59
+ end
60
+
61
+ it 'strains cookbooks for the given paths' do
62
+ runner.should_receive(:run!).with(paths) { true }
63
+
64
+ subject.run(paths)
65
+ end
66
+
67
+ it 'calls #run_all on success' do
68
+ runner.should_receive(:run!) { true }
69
+
70
+ subject.run(paths)
71
+ end
72
+
73
+ it 'throws task_has_failed if the strain fails' do
74
+ runner.should_receive(:run!).with(paths) { false }
75
+
76
+ expect { subject.run(paths) }.to throw_symbol :task_has_failed
77
+ end
78
+
79
+ context ':all_on_pass option is false' do
80
+ let(:subject) { subject = described_class.new([], :all_on_pass => false) }
81
+
82
+ it 'should not run_all on success' do
83
+ runner.should_receive(:run!) { true }
84
+ subject.should_not_receive(:run_all)
85
+
86
+ subject.run(paths)
87
+ end
88
+ end
89
+ end
90
+
91
+ describe '#run_on_additions' do
92
+ it 'delegates to run' do
93
+ subject.should_receive(:run).with(paths).once
94
+
95
+ subject.run_on_additions(paths)
96
+ end
97
+ end
98
+
99
+ describe '#run_on_modifications' do
100
+ it 'delegates to run' do
101
+ subject.should_receive(:run).with(paths).once
102
+
103
+ subject.run_on_modifications(paths)
104
+ end
105
+ end
106
+
107
+ describe '#run_on_removals' do
108
+ it 'delegates to run' do
109
+ subject.should_receive(:run).with(paths).once
110
+
111
+ subject.run_on_removals(paths)
112
+ end
113
+ end
114
+ end
@@ -0,0 +1,24 @@
1
+ require 'bundler/setup'
2
+ require 'simplecov'
3
+ SimpleCov.start do
4
+ add_filter '/spec/'
5
+ add_filter '.bundle'
6
+ end
7
+
8
+ require 'guard/strainer'
9
+ Guard::UI.options = { :level => :warn }
10
+
11
+ RSpec.configure do |config|
12
+ config.color = true
13
+ config.treat_symbols_as_metadata_keys_with_true_values = true
14
+ config.expect_with :rspec do |c|
15
+ c.syntax = :expect
16
+ end
17
+
18
+ config.before(:each) do
19
+ @fixture_path = Pathname.new(File.expand_path('../fixtures/', __FILE__))
20
+ end
21
+ end
22
+
23
+ # Load custom matchers
24
+ Dir[File.dirname(__FILE__) + "/support/**/*.rb"].each {|f| require f}
metadata ADDED
@@ -0,0 +1,213 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: guard-strainer
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Stafford Brunk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: guard
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: strainer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ description: Watch for changes in your chef-repo or cookbook and automatically run
56
+ Strainer
57
+ email:
58
+ - stafford.brunk@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .travis.yml
65
+ - CONTRIBUTING.md
66
+ - Gemfile
67
+ - Guardfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - guard-strainer.gemspec
72
+ - lib/guard/strainer.rb
73
+ - lib/guard/strainer/runner.rb
74
+ - lib/guard/strainer/templates/Guardfile
75
+ - lib/guard/strainer/version.rb
76
+ - spec/fixtures/cookbooks/git/.gitignore
77
+ - spec/fixtures/cookbooks/git/.kitchen.yml
78
+ - spec/fixtures/cookbooks/git/Berksfile
79
+ - spec/fixtures/cookbooks/git/CHANGELOG.md
80
+ - spec/fixtures/cookbooks/git/CONTRIBUTING
81
+ - spec/fixtures/cookbooks/git/Gemfile
82
+ - spec/fixtures/cookbooks/git/LICENSE
83
+ - spec/fixtures/cookbooks/git/README.md
84
+ - spec/fixtures/cookbooks/git/TESTING.md
85
+ - spec/fixtures/cookbooks/git/attributes/default.rb
86
+ - spec/fixtures/cookbooks/git/metadata.rb
87
+ - spec/fixtures/cookbooks/git/recipes/default.rb
88
+ - spec/fixtures/cookbooks/git/recipes/server.rb
89
+ - spec/fixtures/cookbooks/git/recipes/source.rb
90
+ - spec/fixtures/cookbooks/git/recipes/windows.rb
91
+ - spec/fixtures/cookbooks/git/templates/default/git-xinetd.d.erb
92
+ - spec/fixtures/cookbooks/git/templates/default/sv-git-daemon-log-run.erb
93
+ - spec/fixtures/cookbooks/git/templates/default/sv-git-daemon-run.erb
94
+ - spec/fixtures/cookbooks/sudo/.chef/knife.rb
95
+ - spec/fixtures/cookbooks/sudo/.gitignore
96
+ - spec/fixtures/cookbooks/sudo/.kitchen.yml
97
+ - spec/fixtures/cookbooks/sudo/.rspec
98
+ - spec/fixtures/cookbooks/sudo/Berksfile
99
+ - spec/fixtures/cookbooks/sudo/CHANGELOG.md
100
+ - spec/fixtures/cookbooks/sudo/CONTRIBUTING.md
101
+ - spec/fixtures/cookbooks/sudo/Gemfile
102
+ - spec/fixtures/cookbooks/sudo/LICENSE
103
+ - spec/fixtures/cookbooks/sudo/README.md
104
+ - spec/fixtures/cookbooks/sudo/TESTING.md
105
+ - spec/fixtures/cookbooks/sudo/attributes/default.rb
106
+ - spec/fixtures/cookbooks/sudo/files/default/README
107
+ - spec/fixtures/cookbooks/sudo/metadata.rb
108
+ - spec/fixtures/cookbooks/sudo/providers/default.rb
109
+ - spec/fixtures/cookbooks/sudo/recipes/default.rb
110
+ - spec/fixtures/cookbooks/sudo/resources/default.rb
111
+ - spec/fixtures/cookbooks/sudo/templates/default/sudoer.erb
112
+ - spec/fixtures/cookbooks/sudo/templates/default/sudoers.erb
113
+ - spec/fixtures/cookbooks/tmux/.chef/knife.rb
114
+ - spec/fixtures/cookbooks/tmux/.gitignore
115
+ - spec/fixtures/cookbooks/tmux/.travis.yml
116
+ - spec/fixtures/cookbooks/tmux/CHANGELOG.md
117
+ - spec/fixtures/cookbooks/tmux/CONTRIBUTING.md
118
+ - spec/fixtures/cookbooks/tmux/Gemfile
119
+ - spec/fixtures/cookbooks/tmux/LICENSE
120
+ - spec/fixtures/cookbooks/tmux/README.md
121
+ - spec/fixtures/cookbooks/tmux/Rakefile
122
+ - spec/fixtures/cookbooks/tmux/attributes/default.rb
123
+ - spec/fixtures/cookbooks/tmux/metadata.rb
124
+ - spec/fixtures/cookbooks/tmux/recipes/default.rb
125
+ - spec/fixtures/cookbooks/tmux/recipes/package.rb
126
+ - spec/fixtures/cookbooks/tmux/recipes/source.rb
127
+ - spec/fixtures/cookbooks/tmux/templates/default/tmux.conf.erb
128
+ - spec/fixtures/cookbooks/tmux/test/kitchen/Kitchenfile
129
+ - spec/guard/strainer/runner_spec.rb
130
+ - spec/guard/strainer_spec.rb
131
+ - spec/spec_helper.rb
132
+ homepage: https://github.com/wingrunr21/guard-strainer
133
+ licenses:
134
+ - MIT
135
+ metadata: {}
136
+ post_install_message:
137
+ rdoc_options: []
138
+ require_paths:
139
+ - lib
140
+ required_ruby_version: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - '>='
143
+ - !ruby/object:Gem::Version
144
+ version: '0'
145
+ required_rubygems_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 2.0.3
153
+ signing_key:
154
+ specification_version: 4
155
+ summary: guard-strainer will automatically execute a Strainerfile for a watched chef-repo
156
+ or cookbook when it detects changes
157
+ test_files:
158
+ - spec/fixtures/cookbooks/git/.gitignore
159
+ - spec/fixtures/cookbooks/git/.kitchen.yml
160
+ - spec/fixtures/cookbooks/git/Berksfile
161
+ - spec/fixtures/cookbooks/git/CHANGELOG.md
162
+ - spec/fixtures/cookbooks/git/CONTRIBUTING
163
+ - spec/fixtures/cookbooks/git/Gemfile
164
+ - spec/fixtures/cookbooks/git/LICENSE
165
+ - spec/fixtures/cookbooks/git/README.md
166
+ - spec/fixtures/cookbooks/git/TESTING.md
167
+ - spec/fixtures/cookbooks/git/attributes/default.rb
168
+ - spec/fixtures/cookbooks/git/metadata.rb
169
+ - spec/fixtures/cookbooks/git/recipes/default.rb
170
+ - spec/fixtures/cookbooks/git/recipes/server.rb
171
+ - spec/fixtures/cookbooks/git/recipes/source.rb
172
+ - spec/fixtures/cookbooks/git/recipes/windows.rb
173
+ - spec/fixtures/cookbooks/git/templates/default/git-xinetd.d.erb
174
+ - spec/fixtures/cookbooks/git/templates/default/sv-git-daemon-log-run.erb
175
+ - spec/fixtures/cookbooks/git/templates/default/sv-git-daemon-run.erb
176
+ - spec/fixtures/cookbooks/sudo/.chef/knife.rb
177
+ - spec/fixtures/cookbooks/sudo/.gitignore
178
+ - spec/fixtures/cookbooks/sudo/.kitchen.yml
179
+ - spec/fixtures/cookbooks/sudo/.rspec
180
+ - spec/fixtures/cookbooks/sudo/Berksfile
181
+ - spec/fixtures/cookbooks/sudo/CHANGELOG.md
182
+ - spec/fixtures/cookbooks/sudo/CONTRIBUTING.md
183
+ - spec/fixtures/cookbooks/sudo/Gemfile
184
+ - spec/fixtures/cookbooks/sudo/LICENSE
185
+ - spec/fixtures/cookbooks/sudo/README.md
186
+ - spec/fixtures/cookbooks/sudo/TESTING.md
187
+ - spec/fixtures/cookbooks/sudo/attributes/default.rb
188
+ - spec/fixtures/cookbooks/sudo/files/default/README
189
+ - spec/fixtures/cookbooks/sudo/metadata.rb
190
+ - spec/fixtures/cookbooks/sudo/providers/default.rb
191
+ - spec/fixtures/cookbooks/sudo/recipes/default.rb
192
+ - spec/fixtures/cookbooks/sudo/resources/default.rb
193
+ - spec/fixtures/cookbooks/sudo/templates/default/sudoer.erb
194
+ - spec/fixtures/cookbooks/sudo/templates/default/sudoers.erb
195
+ - spec/fixtures/cookbooks/tmux/.chef/knife.rb
196
+ - spec/fixtures/cookbooks/tmux/.gitignore
197
+ - spec/fixtures/cookbooks/tmux/.travis.yml
198
+ - spec/fixtures/cookbooks/tmux/CHANGELOG.md
199
+ - spec/fixtures/cookbooks/tmux/CONTRIBUTING.md
200
+ - spec/fixtures/cookbooks/tmux/Gemfile
201
+ - spec/fixtures/cookbooks/tmux/LICENSE
202
+ - spec/fixtures/cookbooks/tmux/README.md
203
+ - spec/fixtures/cookbooks/tmux/Rakefile
204
+ - spec/fixtures/cookbooks/tmux/attributes/default.rb
205
+ - spec/fixtures/cookbooks/tmux/metadata.rb
206
+ - spec/fixtures/cookbooks/tmux/recipes/default.rb
207
+ - spec/fixtures/cookbooks/tmux/recipes/package.rb
208
+ - spec/fixtures/cookbooks/tmux/recipes/source.rb
209
+ - spec/fixtures/cookbooks/tmux/templates/default/tmux.conf.erb
210
+ - spec/fixtures/cookbooks/tmux/test/kitchen/Kitchenfile
211
+ - spec/guard/strainer/runner_spec.rb
212
+ - spec/guard/strainer_spec.rb
213
+ - spec/spec_helper.rb