renuo-bin-check 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +33 -0
  3. data/.editorconfig +20 -0
  4. data/.gitignore +9 -0
  5. data/.reek +18 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +26 -0
  8. data/.ruby-version +1 -0
  9. data/.travis.yml +32 -0
  10. data/CHANGELOG.md +36 -0
  11. data/CODE_OF_CONDUCT.md +13 -0
  12. data/CONTRIBUTING.md +41 -0
  13. data/Gemfile +3 -0
  14. data/LICENSE +22 -0
  15. data/README.md +142 -0
  16. data/Rakefile +7 -0
  17. data/bin/check +66 -0
  18. data/bin/setup +61 -0
  19. data/lib/renuo-bin-check.rb +8 -0
  20. data/lib/renuo_bin_check/cacher.rb +46 -0
  21. data/lib/renuo_bin_check/default_scripts/default_rails.rb +160 -0
  22. data/lib/renuo_bin_check/initializer.rb +21 -0
  23. data/lib/renuo_bin_check/master_thread.rb +42 -0
  24. data/lib/renuo_bin_check/printer.rb +15 -0
  25. data/lib/renuo_bin_check/result.rb +10 -0
  26. data/lib/renuo_bin_check/script_config.rb +61 -0
  27. data/lib/renuo_bin_check/servant_thread.rb +43 -0
  28. data/lib/renuo_bin_check/version.rb +4 -0
  29. data/renuo-bin-check.gemspec +35 -0
  30. data/spec/code_climate.rb +0 -0
  31. data/spec/code_climate.travis.rb +4 -0
  32. data/spec/factories/cacher.rb +16 -0
  33. data/spec/factories/result.rb +29 -0
  34. data/spec/factories/script_config.rb +41 -0
  35. data/spec/integration/initializer_spec.rb +209 -0
  36. data/spec/renuo/bin-check/cacher_spec.rb +51 -0
  37. data/spec/renuo/bin-check/initializer_spec.rb +23 -0
  38. data/spec/renuo/bin-check/master_thread_spec.rb +46 -0
  39. data/spec/renuo/bin-check/printer_spec.rb +25 -0
  40. data/spec/renuo/bin-check/result_spec.rb +18 -0
  41. data/spec/renuo/bin-check/script_config_spec.rb +69 -0
  42. data/spec/renuo/bin-check/servant_thread_spec.rb +97 -0
  43. data/spec/spec-files/file1 +1 -0
  44. data/spec/spec-files/file2 +1 -0
  45. data/spec/spec-files/file2_copy +1 -0
  46. data/spec/spec-files/test_script_exit0 +5 -0
  47. data/spec/spec-files/test_script_exit1 +5 -0
  48. data/spec/spec-files/test_script_exit1_no_error_output +3 -0
  49. data/spec/spec-files/test_script_sleep1 +2 -0
  50. data/spec/spec-files/test_script_sleep2 +2 -0
  51. data/spec/spec_helper.rb +35 -0
  52. metadata +288 -0
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+ require './lib/renuo_bin_check/printer'
3
+
4
+ RSpec.describe RenuoBinCheck::Printer do
5
+ let(:printer) { RenuoBinCheck::Printer.new }
6
+ let(:result) { build(:failed_result) }
7
+ let(:results) { [build(:result), build(:result)] }
8
+
9
+ it 'prints the given standard_output' do
10
+ expect { printer.print_standard_output(results) }.to output("I passed\nThis is the second line\n" \
11
+ "I passed\nThis is the second line\n").to_stdout
12
+ end
13
+
14
+ it 'prints the given error-output' do
15
+ expect { printer.print_error_output(result) }.to output("I failed\nThis is the second line\n").to_stderr
16
+ end
17
+
18
+ context 'empty output' do
19
+ let(:result) { build(:failed_result, error_output: '') }
20
+
21
+ it 'prints standard_output if no error-output is available' do
22
+ expect { printer.print_error_output(result) }.to output("I passed\nThis is the second line\n").to_stderr
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+ require './lib/renuo_bin_check/result'
3
+
4
+ RSpec.describe RenuoBinCheck::Result do
5
+ let(:result) { RenuoBinCheck::Result.new('heyaa', 'noooo', 0) }
6
+
7
+ it 'initializes standard_output with given standard_output' do
8
+ expect(result.standard_output).to eq('heyaa')
9
+ end
10
+
11
+ it 'initializes error_output with given error_output' do
12
+ expect(result.error_output).to eq('noooo')
13
+ end
14
+
15
+ it 'initializes exit_code with given output' do
16
+ expect(result.exit_code).to eq(0)
17
+ end
18
+ end
@@ -0,0 +1,69 @@
1
+ require 'spec_helper'
2
+ require './lib/renuo_bin_check/script_config'
3
+
4
+ RSpec.describe RenuoBinCheck::ScriptConfig do
5
+ let(:script) { RenuoBinCheck::ScriptConfig.new }
6
+
7
+ it 'sets command' do
8
+ script.command 'super cool command'
9
+ expect(script.script_command).to eq('super cool command')
10
+ end
11
+
12
+ it 'sets files' do
13
+ script.files(['first file', 'second file'])
14
+ expect(script.script_files).to eq(['first file', 'second file'])
15
+ end
16
+
17
+ it 'sets name and returns it' do
18
+ script.name('nice_script')
19
+ expect(script.script_name).to eq('nice_script')
20
+ end
21
+
22
+ it 'sets reversed_exit' do
23
+ script.reversed_exit(true)
24
+ expect(script.reversed_exit?).to be_truthy
25
+ end
26
+
27
+ it 'sets standard_output' do
28
+ script.success_message('the set up script passed')
29
+ expect(script.script_standard_output).to eq('the set up script passed')
30
+ end
31
+
32
+ it 'sets error-output' do
33
+ script.error_message('the set up script failed')
34
+ expect(script.script_error_output).to eq('the set up script failed')
35
+ end
36
+
37
+ context 'append-mode' do
38
+ it 'sets standard_output' do
39
+ script.success_message('+the set up script passed')
40
+ expect(script.appended_standard_output).to eq('the set up script passed')
41
+ end
42
+
43
+ it 'sets error-output' do
44
+ script.error_message('+the set up script failed')
45
+ expect(script.appended_error_output).to eq('the set up script failed')
46
+ end
47
+ end
48
+
49
+ context 'params not set' do
50
+ it 'returns name that is hashed script_command' do
51
+ script = RenuoBinCheck::ScriptConfig.new
52
+ script.command 'super cool command'
53
+ expect(script.script_name).to eq('b4ba9254f12d6385060ae4a2c32084e2')
54
+ end
55
+
56
+ it 'raises a RuntimeError' do
57
+ script = RenuoBinCheck::ScriptConfig.new
58
+ expect { script.script_command }.to raise_error(RuntimeError, 'There must be a command set for each script you' \
59
+ ' want to run. Find further instruction on how to use this Gem here in the Readme: https://github.com/renuo/renuo-bin-'\
60
+ 'check')
61
+ end
62
+
63
+ it 'returns empty string' do
64
+ script = RenuoBinCheck::ScriptConfig.new
65
+ script.command 'super cool command'
66
+ expect(script.script_files).to be_falsey
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,97 @@
1
+ require 'spec_helper'
2
+ require './lib/renuo_bin_check/servant_thread'
3
+
4
+ RSpec.describe RenuoBinCheck::ServantThread do
5
+ let(:cacher) { build :not_found_cacher }
6
+ let(:result_attributes) { attributes_for :result }
7
+ context 'initializing' do
8
+ let(:script) { build :script }
9
+ it 'initializes the instance variable script with the given ScriptConfig' do
10
+ servant = RenuoBinCheck::ServantThread.new(script)
11
+ expect(servant.script_config).to eq(script)
12
+ end
13
+
14
+ it 'initializes cacher with script_name' do
15
+ expect(script).to receive(:script_name).and_return('nice name')
16
+ RenuoBinCheck::ServantThread.new(script)
17
+ end
18
+ end
19
+
20
+ context 'running successfully' do
21
+ let(:script) { build :passing_script }
22
+ let(:servant) { RenuoBinCheck::ServantThread.new(script) }
23
+
24
+ after(:each) { FileUtils.remove_dir('./tmp/bin-check/exit0') }
25
+
26
+ it 'starts the command defined in ScriptConfig and returns a Result' do
27
+ expect(servant.run).to have_attributes(result_attributes)
28
+ end
29
+ end
30
+
31
+ context 'without file' do
32
+ let(:script) { build :without_files_script }
33
+ let(:servant) { RenuoBinCheck::ServantThread.new(script) }
34
+
35
+ it 'starts the command defined in ScriptConfig and returns a Result' do
36
+ expect(servant.run).to have_attributes(result_attributes)
37
+ end
38
+ end
39
+
40
+ context 'with reversed_exit' do
41
+ let(:script) { build :reversed_exit_script }
42
+ let(:servant) { RenuoBinCheck::ServantThread.new(script) }
43
+ let(:result_attributes) { attributes_for :reversed_exit_result }
44
+
45
+ after(:each) { FileUtils.remove_dir('./tmp/bin-check/exit0') }
46
+
47
+ it 'starts the command defined in ScriptConfig and returns a Result' do
48
+ expect(servant.run).to have_attributes(result_attributes)
49
+ end
50
+ end
51
+
52
+ context 'finding cache' do
53
+ let(:script) { build :cached_script }
54
+ let(:servant) { RenuoBinCheck::ServantThread.new(script) }
55
+
56
+ before(:each) do
57
+ FileUtils.mkdir_p 'tmp/bin-check/script_name/df57ab93c06ded11a01f2de950307019'
58
+ File.write 'tmp/bin-check/script_name/df57ab93c06ded11a01f2de950307019/standard_output',
59
+ "I passed\nThis is the second line\n"
60
+ File.write 'tmp/bin-check/script_name/df57ab93c06ded11a01f2de950307019/error_output',
61
+ "I failed\nThis is the second line\n"
62
+ File.write 'tmp/bin-check/script_name/df57ab93c06ded11a01f2de950307019/exit_code', 0
63
+ end
64
+
65
+ after(:each) { FileUtils.remove_dir('./tmp/bin-check') }
66
+
67
+ it 'gets result from cache' do
68
+ expect(servant.run).to have_attributes(result_attributes)
69
+ end
70
+ end
71
+
72
+ context 'overridden standard_output and error_output' do
73
+ let(:script) { build :with_overridden_output_script }
74
+ let(:servant) { RenuoBinCheck::ServantThread.new(script) }
75
+
76
+ let(:result_attributes) { attributes_for :overridden_output_result }
77
+
78
+ after(:each) { FileUtils.remove_dir('./tmp/bin-check') }
79
+
80
+ it 'uses overridden output' do
81
+ expect(servant.run).to have_attributes(result_attributes)
82
+ end
83
+ end
84
+
85
+ context 'appended standard_output and error_output' do
86
+ let(:script) { build :with_appended_output_script }
87
+ let(:servant) { RenuoBinCheck::ServantThread.new(script) }
88
+
89
+ let(:result_attributes) { attributes_for :appended_output_result }
90
+
91
+ after(:each) { FileUtils.remove_dir('./tmp/bin-check') }
92
+
93
+ it 'uses overridden output' do
94
+ expect(servant.run).to have_attributes(result_attributes)
95
+ end
96
+ end
97
+ end
@@ -0,0 +1 @@
1
+ This is File 1
@@ -0,0 +1 @@
1
+ This is File2
@@ -0,0 +1 @@
1
+ This is File2
@@ -0,0 +1,5 @@
1
+ echo "I passed"
2
+ echo "This is the second line"
3
+ echo "I failed" >&2
4
+ echo "This is the second line" >&2
5
+ exit 0
@@ -0,0 +1,5 @@
1
+ echo "I passed"
2
+ echo "This is the second line"
3
+ echo "I failed" >&2
4
+ echo "This is the second line" >&2
5
+ exit 1
@@ -0,0 +1,3 @@
1
+ echo "I failed"
2
+ echo "This is the second line"
3
+ exit 1
@@ -0,0 +1,2 @@
1
+ sleep 1
2
+ exit 0
@@ -0,0 +1,2 @@
1
+ sleep 2
2
+ 
exit 0
@@ -0,0 +1,35 @@
1
+ require_relative 'code_climate'
2
+ require 'simplecov'
3
+ require 'factory_girl'
4
+ require 'fileutils'
5
+
6
+ SimpleCov.start
7
+ SimpleCov.minimum_coverage 100
8
+
9
+ RSpec.configure do |config|
10
+ config.expect_with :rspec do |expectations|
11
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
12
+ end
13
+
14
+ config.mock_with :rspec do |mocks|
15
+ mocks.verify_partial_doubles = true
16
+ end
17
+
18
+ config.include FactoryGirl::Syntax::Methods
19
+
20
+ config.before(:suite) do
21
+ FactoryGirl.find_definitions
22
+ end
23
+
24
+ config.run_all_when_everything_filtered = true
25
+
26
+ config.disable_monkey_patching!
27
+
28
+ config.default_formatter = 'doc' if config.files_to_run.one?
29
+
30
+ config.profile_examples = 5
31
+
32
+ config.order = :random
33
+
34
+ Kernel.srand config.seed
35
+ end
metadata ADDED
@@ -0,0 +1,288 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: renuo-bin-check
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - Zora Fuchs
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: awesome_print
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '9.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '9.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.5'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.5'
69
+ - !ruby/object:Gem::Dependency
70
+ name: factory_girl
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.7'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-byebug
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '3.3'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '3.3'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.40'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.40'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '10.0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '10.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: reek
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '4.0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '4.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '3.4'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '3.4'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '0.11'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '0.11'
181
+ description: With this gem you can automatically check your code quality (e.g. before
182
+ every commit). You can configure it to run rubocop, reek, rspec and even custom
183
+ scripts. For faster runtime it makes use of cashing and parallel execution.
184
+ email:
185
+ - zora.fuchs@renuo.ch
186
+ executables: []
187
+ extensions: []
188
+ extra_rdoc_files: []
189
+ files:
190
+ - ".codeclimate.yml"
191
+ - ".editorconfig"
192
+ - ".gitignore"
193
+ - ".reek"
194
+ - ".rspec"
195
+ - ".rubocop.yml"
196
+ - ".ruby-version"
197
+ - ".travis.yml"
198
+ - CHANGELOG.md
199
+ - CODE_OF_CONDUCT.md
200
+ - CONTRIBUTING.md
201
+ - Gemfile
202
+ - LICENSE
203
+ - README.md
204
+ - Rakefile
205
+ - bin/check
206
+ - bin/setup
207
+ - lib/renuo-bin-check.rb
208
+ - lib/renuo_bin_check/cacher.rb
209
+ - lib/renuo_bin_check/default_scripts/default_rails.rb
210
+ - lib/renuo_bin_check/initializer.rb
211
+ - lib/renuo_bin_check/master_thread.rb
212
+ - lib/renuo_bin_check/printer.rb
213
+ - lib/renuo_bin_check/result.rb
214
+ - lib/renuo_bin_check/script_config.rb
215
+ - lib/renuo_bin_check/servant_thread.rb
216
+ - lib/renuo_bin_check/version.rb
217
+ - renuo-bin-check.gemspec
218
+ - spec/code_climate.rb
219
+ - spec/code_climate.travis.rb
220
+ - spec/factories/cacher.rb
221
+ - spec/factories/result.rb
222
+ - spec/factories/script_config.rb
223
+ - spec/integration/initializer_spec.rb
224
+ - spec/renuo/bin-check/cacher_spec.rb
225
+ - spec/renuo/bin-check/initializer_spec.rb
226
+ - spec/renuo/bin-check/master_thread_spec.rb
227
+ - spec/renuo/bin-check/printer_spec.rb
228
+ - spec/renuo/bin-check/result_spec.rb
229
+ - spec/renuo/bin-check/script_config_spec.rb
230
+ - spec/renuo/bin-check/servant_thread_spec.rb
231
+ - spec/spec-files/file1
232
+ - spec/spec-files/file2
233
+ - spec/spec-files/file2_copy
234
+ - spec/spec-files/test_script_exit0
235
+ - spec/spec-files/test_script_exit1
236
+ - spec/spec-files/test_script_exit1_no_error_output
237
+ - spec/spec-files/test_script_sleep1
238
+ - spec/spec-files/test_script_sleep2
239
+ - spec/spec_helper.rb
240
+ homepage: https://github.com/renuo/renuo-bin-check
241
+ licenses:
242
+ - MIT
243
+ metadata: {}
244
+ post_install_message:
245
+ rdoc_options: []
246
+ require_paths:
247
+ - lib
248
+ required_ruby_version: !ruby/object:Gem::Requirement
249
+ requirements:
250
+ - - ">="
251
+ - !ruby/object:Gem::Version
252
+ version: '0'
253
+ required_rubygems_version: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - ">="
256
+ - !ruby/object:Gem::Version
257
+ version: '0'
258
+ requirements: []
259
+ rubyforge_project:
260
+ rubygems_version: 2.5.1
261
+ signing_key:
262
+ specification_version: 4
263
+ summary: renuo-bin-check automates running programms to check code quality of a ruby
264
+ application.
265
+ test_files:
266
+ - spec/code_climate.rb
267
+ - spec/code_climate.travis.rb
268
+ - spec/factories/cacher.rb
269
+ - spec/factories/result.rb
270
+ - spec/factories/script_config.rb
271
+ - spec/integration/initializer_spec.rb
272
+ - spec/renuo/bin-check/cacher_spec.rb
273
+ - spec/renuo/bin-check/initializer_spec.rb
274
+ - spec/renuo/bin-check/master_thread_spec.rb
275
+ - spec/renuo/bin-check/printer_spec.rb
276
+ - spec/renuo/bin-check/result_spec.rb
277
+ - spec/renuo/bin-check/script_config_spec.rb
278
+ - spec/renuo/bin-check/servant_thread_spec.rb
279
+ - spec/spec-files/file1
280
+ - spec/spec-files/file2
281
+ - spec/spec-files/file2_copy
282
+ - spec/spec-files/test_script_exit0
283
+ - spec/spec-files/test_script_exit1
284
+ - spec/spec-files/test_script_exit1_no_error_output
285
+ - spec/spec-files/test_script_sleep1
286
+ - spec/spec-files/test_script_sleep2
287
+ - spec/spec_helper.rb
288
+ has_rdoc: