polytrix 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop-todo.yml +14 -5
  3. data/Gemfile +2 -1
  4. data/README.md +139 -177
  5. data/Rakefile +5 -12
  6. data/bin/polytrix +0 -1
  7. data/features/bootstrapping.feature +0 -3
  8. data/features/cloning.feature +0 -3
  9. data/features/show.feature +38 -0
  10. data/features/states.feature +12 -13
  11. data/features/step_definitions/sdk_steps.rb +0 -4
  12. data/lib/polytrix/challenge.rb +135 -53
  13. data/lib/polytrix/challenge_result.rb +0 -2
  14. data/lib/polytrix/challenge_runner.rb +28 -18
  15. data/lib/polytrix/cli.rb +53 -69
  16. data/lib/polytrix/color.rb +2 -2
  17. data/lib/polytrix/command/action.rb +4 -3
  18. data/lib/polytrix/command/list.rb +39 -28
  19. data/lib/polytrix/command/report.rb +9 -86
  20. data/lib/polytrix/command/reports/code2doc.rb +72 -0
  21. data/lib/polytrix/command/reports/dashboard.rb +125 -0
  22. data/lib/polytrix/command/show.rb +148 -0
  23. data/lib/polytrix/command.rb +37 -104
  24. data/lib/polytrix/configuration.rb +14 -18
  25. data/lib/polytrix/{core/hashie.rb → dash.rb} +4 -3
  26. data/lib/polytrix/documentation/code_segmenter.rb +8 -8
  27. data/lib/polytrix/documentation/comment_styles.rb +1 -1
  28. data/lib/polytrix/documentation/helpers/code_helper.rb +9 -0
  29. data/lib/polytrix/documentation_generator.rb +11 -14
  30. data/lib/polytrix/error.rb +104 -97
  31. data/lib/polytrix/executor.rb +33 -0
  32. data/lib/polytrix/{runners → executors}/buff_shellout_executor.rb +1 -1
  33. data/lib/polytrix/executors/linux_challenge_executor.rb +29 -0
  34. data/lib/polytrix/executors/mixlib_shellout_executor.rb +55 -0
  35. data/lib/polytrix/{runners/windows_challenge_runner.rb → executors/windows_challenge_executor.rb} +4 -11
  36. data/lib/polytrix/{core/implementor.rb → implementor.rb} +10 -6
  37. data/lib/polytrix/manifest.rb +2 -31
  38. data/lib/polytrix/{reports → reporters}/hash_reporter.rb +6 -2
  39. data/lib/polytrix/{reports → reporters}/json_reporter.rb +2 -2
  40. data/lib/polytrix/{reports → reporters}/markdown_reporter.rb +7 -2
  41. data/lib/polytrix/{reports → reporters}/yaml_reporter.rb +2 -2
  42. data/lib/polytrix/reporters.rb +27 -0
  43. data/lib/polytrix/result.rb +6 -5
  44. data/lib/polytrix/spies/file_system_spy.rb +15 -0
  45. data/lib/polytrix/spies.rb +61 -0
  46. data/lib/polytrix/state_file.rb +1 -20
  47. data/lib/polytrix/util.rb +157 -62
  48. data/lib/polytrix/validation.rb +41 -2
  49. data/lib/polytrix/validator.rb +9 -4
  50. data/lib/polytrix/version.rb +1 -1
  51. data/lib/polytrix.rb +110 -105
  52. data/polytrix.gemspec +7 -2
  53. data/polytrix.yml +16 -13
  54. data/resources/assets/pygments/autumn.css +58 -0
  55. data/resources/assets/pygments/borland.css +46 -0
  56. data/resources/assets/pygments/bw.css +34 -0
  57. data/resources/assets/pygments/colorful.css +61 -0
  58. data/resources/assets/pygments/default.css +62 -0
  59. data/resources/assets/pygments/emacs.css +61 -0
  60. data/resources/assets/pygments/friendly.css +61 -0
  61. data/resources/assets/pygments/fruity.css +69 -0
  62. data/resources/assets/pygments/github.css +61 -0
  63. data/resources/assets/pygments/manni.css +61 -0
  64. data/resources/assets/pygments/monokai.css +64 -0
  65. data/resources/assets/pygments/murphy.css +61 -0
  66. data/resources/assets/pygments/native.css +69 -0
  67. data/resources/assets/pygments/pastie.css +60 -0
  68. data/resources/assets/pygments/perldoc.css +58 -0
  69. data/resources/assets/pygments/tango.css +69 -0
  70. data/resources/assets/pygments/trac.css +59 -0
  71. data/resources/assets/pygments/vim.css +69 -0
  72. data/resources/assets/pygments/vs.css +33 -0
  73. data/resources/assets/pygments/zenburn.css +1 -0
  74. data/resources/assets/style.css +41 -0
  75. data/resources/templates/dashboard/files/dashboard.html.tt +82 -0
  76. data/resources/templates/dashboard/templates/_test_report.html.tt +87 -0
  77. data/samples/bootstrap.sh +2 -0
  78. data/samples/clone.sh +2 -0
  79. data/samples/code2doc.sh +4 -0
  80. data/samples/docs/samples/code2doc/java/katas-hello_world-java.md +17 -0
  81. data/samples/docs/samples/code2doc/java/katas-quine-java.md +35 -0
  82. data/samples/docs/samples/code2doc/python/katas-hello_world-python.md +5 -0
  83. data/samples/docs/samples/code2doc/python/katas-quine-python.md +6 -0
  84. data/samples/docs/samples/code2doc/ruby/katas-hello_world-ruby.md +11 -0
  85. data/samples/exec.sh +2 -0
  86. data/samples/polytrix.rb +2 -2
  87. data/samples/polytrix.yml +5 -2
  88. data/samples/show.sh +4 -0
  89. data/samples/test.sh +2 -0
  90. data/samples/tests/polytrix/validators.rb +2 -2
  91. data/samples/verify.sh +3 -0
  92. data/scripts/wrapper +4 -7
  93. data/spec/fabricators/challenge_fabricator.rb +2 -9
  94. data/spec/fabricators/implementor_fabricator.rb +0 -8
  95. data/spec/fabricators/manifest_fabricator.rb +2 -9
  96. data/spec/fabricators/validator_fabricator.rb +2 -4
  97. data/spec/polytrix/challenge_runner_spec.rb +20 -0
  98. data/spec/polytrix/documentation/helpers/code_helper_spec.rb +7 -7
  99. data/spec/polytrix/file_finder_spec.rb +5 -5
  100. data/spec/polytrix/manifest_spec.rb +0 -21
  101. data/spec/polytrix/result_spec.rb +14 -14
  102. data/spec/polytrix/validator_registry_spec.rb +4 -4
  103. data/spec/polytrix/validator_spec.rb +9 -9
  104. data/spec/polytrix_spec.rb +1 -25
  105. data/spec/spec_helper.rb +8 -1
  106. metadata +130 -38
  107. data/features/execution.feature +0 -53
  108. data/features/fixtures/spec/polytrix_spec.rb +0 -7
  109. data/lib/polytrix/cli/report.rb +0 -84
  110. data/lib/polytrix/command/rundoc.rb +0 -27
  111. data/lib/polytrix/core/file_system_helper.rb +0 -75
  112. data/lib/polytrix/core/manifest_section.rb +0 -4
  113. data/lib/polytrix/core/string_helpers.rb +0 -15
  114. data/lib/polytrix/documentation/view_helper.rb +0 -21
  115. data/lib/polytrix/rspec/documentation_formatter.rb +0 -66
  116. data/lib/polytrix/rspec/yaml_report.rb +0 -51
  117. data/lib/polytrix/rspec.rb +0 -56
  118. data/lib/polytrix/runners/executor.rb +0 -34
  119. data/lib/polytrix/runners/linux_challenge_runner.rb +0 -23
  120. data/lib/polytrix/runners/middleware/change_directory.rb +0 -20
  121. data/lib/polytrix/runners/middleware/feature_executor.rb +0 -24
  122. data/lib/polytrix/runners/middleware/setup_env_vars.rb +0 -42
  123. data/lib/polytrix/runners/mixlib_shellout_executor.rb +0 -83
  124. data/lib/polytrix/validations.rb +0 -23
  125. data/samples/scripts/wrapper +0 -7
  126. data/spec/polytrix/middleware/feature_executor_spec.rb +0 -48
  127. data/spec/polytrix/validations_spec.rb +0 -16
@@ -6,18 +6,18 @@ module Polytrix
6
6
  let(:global_matcher) { Validator::UNIVERSAL_MATCHER }
7
7
 
8
8
  it 'accepts scope options and callback' do
9
- validator = Validator.new 'dummy', suite: 'java', sample: 'hello world' do |challenge|
9
+ validator = Validator.new 'dummy', suite: 'java', scenario: 'hello world' do |_challenge|
10
10
  # Validate the challenge
11
11
  end
12
12
  expect(validator.suite).to eq('java')
13
13
  end
14
14
 
15
- it 'defaults suite and sample to the universal matcher' do
16
- validator = Validator.new 'dummy' do |challenge|
15
+ it 'defaults suite and scenario to the universal matcher' do
16
+ validator = Validator.new 'dummy' do |_challenge|
17
17
  # Validate
18
18
  end
19
19
  expect(validator.suite).to eq(Validator::UNIVERSAL_MATCHER)
20
- expect(validator.sample).to eq(Validator::UNIVERSAL_MATCHER)
20
+ expect(validator.scenario).to eq(Validator::UNIVERSAL_MATCHER)
21
21
  end
22
22
  end
23
23
 
@@ -40,11 +40,11 @@ module Polytrix
40
40
  end
41
41
 
42
42
  describe '#validate' do
43
- let(:challenge) { Fabricate(:challenge) }
43
+ let(:challenge) { Fabricate(:challenge, result: Result.new) }
44
44
 
45
- xit 'calls the validation callback' do
45
+ it 'calls the validation callback' do
46
46
  called = false
47
- validator = Validator.new 'dummy' do |challenge|
47
+ validator = Validator.new 'dummy' do |_challenge|
48
48
  called = true
49
49
  end
50
50
  expect { validator.validate challenge }.to change { called }.from(false).to(true)
@@ -54,8 +54,8 @@ module Polytrix
54
54
  def validator(*args)
55
55
  scope = {}
56
56
  scope[:suite] = args[0]
57
- scope[:sample] = args[1] if args[1]
58
- Validator.new 'dummy', scope do |challenge|
57
+ scope[:scenario] = args[1] if args[1]
58
+ Validator.new 'dummy', scope do |_challenge|
59
59
  # Dummy validator
60
60
  end
61
61
  end
@@ -1,34 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Polytrix do
4
- describe '.find_implementor' do
5
- before do
6
- Polytrix.configuration.manifest = 'samples/polytrix.yml'
7
- end
8
-
9
- it 'returns nil if no implementor is found for the file' do
10
- tempfile = Tempfile.new(['foo', '.java'])
11
- expect(described_class.find_implementor tempfile.path).to be_nil
12
- end
13
-
14
- it 'finds implementors from by matching basedir to an already loaded implementor' do
15
- Polytrix.manifest.implementors['java'] = Fabricate(:implementor, name: 'java', basedir: 'samples/sdks/java')
16
- # Polytrix.configuration.implementor(
17
- # name: 'java',
18
- # basedir: 'samples/sdks/java'
19
- # )
20
-
21
- sample_file = 'samples/sdks/java/challenges/HelloWorld.java'
22
- implementor = described_class.find_implementor sample_file
23
- expect(implementor).to be_an_instance_of Polytrix::Implementor
24
- expect(implementor.name).to eq('java')
25
- end
26
- end
27
-
28
4
  describe '.validate' do
29
5
  context 'block given' do
30
6
  it 'creates and registers a validator' do
31
- Polytrix.validate 'custom validator', suite: 'test', sample: 'test' do |challenge|
7
+ Polytrix.validate 'custom validator', suite: 'test', scenario: 'test' do |_challenge|
32
8
  # Validate the challenge results
33
9
  end
34
10
  end
data/spec/spec_helper.rb CHANGED
@@ -2,7 +2,6 @@ require 'simplecov'
2
2
  SimpleCov.start
3
3
 
4
4
  require 'polytrix'
5
- require 'polytrix/rspec'
6
5
  require 'fabrication'
7
6
  require 'thor_spy'
8
7
 
@@ -18,3 +17,11 @@ RSpec.configure do |c|
18
17
  end
19
18
  c.expose_current_running_example_as :example
20
19
  end
20
+
21
+ # For Fabricators
22
+ LANGUAGES = %w(java ruby python nodejs c# golang php)
23
+ SCENARIO_NAMES = [
24
+ 'hello world',
25
+ 'quine',
26
+ 'my_kata'
27
+ ]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polytrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Lincoln
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-25 00:00:00.000000000 Z
11
+ date: 2014-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -81,7 +81,7 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0.1'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rspec
84
+ name: rspec-expectations
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
@@ -122,6 +122,62 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0.12'
125
+ - !ruby/object:Gem::Dependency
126
+ name: erubis
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.7'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '2.7'
139
+ - !ruby/object:Gem::Dependency
140
+ name: cause
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.1'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.1'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rouge
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '1.7'
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '1.7'
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: '3.0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: '3.0'
125
181
  - !ruby/object:Gem::Dependency
126
182
  name: bundler
127
183
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +226,28 @@ dependencies:
170
226
  requirements:
171
227
  - - "~>"
172
228
  - !ruby/object:Gem::Version
173
- version: 0.18.0
229
+ version: '0.18'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - "~>"
235
+ - !ruby/object:Gem::Version
236
+ version: '0.18'
237
+ - !ruby/object:Gem::Dependency
238
+ name: rubocop-rspec
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '1.2'
174
244
  type: :development
175
245
  prerelease: false
176
246
  version_requirements: !ruby/object:Gem::Requirement
177
247
  requirements:
178
248
  - - "~>"
179
249
  - !ruby/object:Gem::Version
180
- version: 0.18.0
250
+ version: '1.2'
181
251
  - !ruby/object:Gem::Dependency
182
252
  name: fabrication
183
253
  requirement: !ruby/object:Gem::Requirement
@@ -220,10 +290,9 @@ files:
220
290
  - docs/samples/code2doc/ruby/hello_world.md
221
291
  - features/bootstrapping.feature
222
292
  - features/cloning.feature
223
- - features/execution.feature
224
293
  - features/fixtures/configs/empty.yml
225
294
  - features/fixtures/configs/hello_world.yml
226
- - features/fixtures/spec/polytrix_spec.rb
295
+ - features/show.feature
227
296
  - features/solo.feature
228
297
  - features/states.feature
229
298
  - features/step_definitions/sdk_steps.rb
@@ -234,64 +303,88 @@ files:
234
303
  - lib/polytrix/challenge_runner.rb
235
304
  - lib/polytrix/challenges.rb
236
305
  - lib/polytrix/cli.rb
237
- - lib/polytrix/cli/report.rb
238
306
  - lib/polytrix/color.rb
239
307
  - lib/polytrix/command.rb
240
308
  - lib/polytrix/command/action.rb
241
309
  - lib/polytrix/command/list.rb
242
310
  - lib/polytrix/command/report.rb
243
- - lib/polytrix/command/rundoc.rb
311
+ - lib/polytrix/command/reports/code2doc.rb
312
+ - lib/polytrix/command/reports/dashboard.rb
313
+ - lib/polytrix/command/show.rb
244
314
  - lib/polytrix/command/test.rb
245
315
  - lib/polytrix/configuration.rb
246
- - lib/polytrix/core/file_system_helper.rb
247
- - lib/polytrix/core/hashie.rb
248
- - lib/polytrix/core/implementor.rb
249
- - lib/polytrix/core/manifest_section.rb
250
- - lib/polytrix/core/string_helpers.rb
316
+ - lib/polytrix/dash.rb
251
317
  - lib/polytrix/documentation/code_segmenter.rb
252
318
  - lib/polytrix/documentation/comment_styles.rb
253
319
  - lib/polytrix/documentation/helpers/code_helper.rb
254
- - lib/polytrix/documentation/view_helper.rb
255
320
  - lib/polytrix/documentation_generator.rb
256
321
  - lib/polytrix/error.rb
322
+ - lib/polytrix/executor.rb
323
+ - lib/polytrix/executors/buff_shellout_executor.rb
324
+ - lib/polytrix/executors/linux_challenge_executor.rb
325
+ - lib/polytrix/executors/mixlib_shellout_executor.rb
326
+ - lib/polytrix/executors/windows_challenge_executor.rb
327
+ - lib/polytrix/implementor.rb
257
328
  - lib/polytrix/logger.rb
258
329
  - lib/polytrix/logging.rb
259
330
  - lib/polytrix/manifest.rb
260
- - lib/polytrix/reports/hash_reporter.rb
261
- - lib/polytrix/reports/json_reporter.rb
262
- - lib/polytrix/reports/markdown_reporter.rb
263
- - lib/polytrix/reports/yaml_reporter.rb
331
+ - lib/polytrix/reporters.rb
332
+ - lib/polytrix/reporters/hash_reporter.rb
333
+ - lib/polytrix/reporters/json_reporter.rb
334
+ - lib/polytrix/reporters/markdown_reporter.rb
335
+ - lib/polytrix/reporters/yaml_reporter.rb
264
336
  - lib/polytrix/result.rb
265
- - lib/polytrix/rspec.rb
266
- - lib/polytrix/rspec/documentation_formatter.rb
267
- - lib/polytrix/rspec/yaml_report.rb
268
- - lib/polytrix/runners/buff_shellout_executor.rb
269
- - lib/polytrix/runners/executor.rb
270
- - lib/polytrix/runners/linux_challenge_runner.rb
271
- - lib/polytrix/runners/middleware/change_directory.rb
272
- - lib/polytrix/runners/middleware/feature_executor.rb
273
- - lib/polytrix/runners/middleware/setup_env_vars.rb
274
- - lib/polytrix/runners/mixlib_shellout_executor.rb
275
- - lib/polytrix/runners/windows_challenge_runner.rb
337
+ - lib/polytrix/spies.rb
338
+ - lib/polytrix/spies/file_system_spy.rb
276
339
  - lib/polytrix/state_file.rb
277
340
  - lib/polytrix/util.rb
278
341
  - lib/polytrix/validation.rb
279
- - lib/polytrix/validations.rb
280
342
  - lib/polytrix/validator.rb
281
343
  - lib/polytrix/validator_registry.rb
282
344
  - lib/polytrix/version.rb
283
345
  - polytrix.gemspec
284
346
  - polytrix.rb
285
347
  - polytrix.yml
348
+ - resources/assets/pygments/autumn.css
349
+ - resources/assets/pygments/borland.css
350
+ - resources/assets/pygments/bw.css
351
+ - resources/assets/pygments/colorful.css
352
+ - resources/assets/pygments/default.css
353
+ - resources/assets/pygments/emacs.css
354
+ - resources/assets/pygments/friendly.css
355
+ - resources/assets/pygments/fruity.css
356
+ - resources/assets/pygments/github.css
357
+ - resources/assets/pygments/manni.css
358
+ - resources/assets/pygments/monokai.css
359
+ - resources/assets/pygments/murphy.css
360
+ - resources/assets/pygments/native.css
361
+ - resources/assets/pygments/pastie.css
362
+ - resources/assets/pygments/perldoc.css
363
+ - resources/assets/pygments/tango.css
364
+ - resources/assets/pygments/trac.css
365
+ - resources/assets/pygments/vim.css
366
+ - resources/assets/pygments/vs.css
367
+ - resources/assets/pygments/zenburn.css
368
+ - resources/assets/style.css
286
369
  - resources/code_sample.tt
370
+ - resources/templates/dashboard/files/dashboard.html.tt
371
+ - resources/templates/dashboard/templates/_test_report.html.tt
287
372
  - samples/.gitignore
288
373
  - samples/_markdown.md
374
+ - samples/bootstrap.sh
375
+ - samples/clone.sh
376
+ - samples/code2doc.sh
289
377
  - samples/default_bootstrap.rb
378
+ - samples/docs/samples/code2doc/java/katas-hello_world-java.md
379
+ - samples/docs/samples/code2doc/java/katas-quine-java.md
380
+ - samples/docs/samples/code2doc/python/katas-hello_world-python.md
381
+ - samples/docs/samples/code2doc/python/katas-quine-python.md
382
+ - samples/docs/samples/code2doc/ruby/katas-hello_world-ruby.md
383
+ - samples/exec.sh
290
384
  - samples/polytrix.rb
291
385
  - samples/polytrix.yml
292
386
  - samples/polytrix_cli.sh
293
387
  - samples/scripts/bootstrap
294
- - samples/scripts/wrapper
295
388
  - samples/sdks/java/.gitignore
296
389
  - samples/sdks/java/build.gradle
297
390
  - samples/sdks/java/challenges/HelloWorld.java
@@ -303,7 +396,10 @@ files:
303
396
  - samples/sdks/python/challenges/quine.py
304
397
  - samples/sdks/python/scripts/wrapper
305
398
  - samples/sdks/ruby/challenges/hello_world.rb
399
+ - samples/show.sh
400
+ - samples/test.sh
306
401
  - samples/tests/polytrix/validators.rb
402
+ - samples/verify.sh
307
403
  - scripts/bootstrap
308
404
  - scripts/wrapper
309
405
  - spec/fabricators/challenge_fabricator.rb
@@ -323,9 +419,7 @@ files:
323
419
  - spec/polytrix/file_finder_spec.rb
324
420
  - spec/polytrix/implementor_spec.rb
325
421
  - spec/polytrix/manifest_spec.rb
326
- - spec/polytrix/middleware/feature_executor_spec.rb
327
422
  - spec/polytrix/result_spec.rb
328
- - spec/polytrix/validations_spec.rb
329
423
  - spec/polytrix/validator_registry_spec.rb
330
424
  - spec/polytrix/validator_spec.rb
331
425
  - spec/polytrix_spec.rb
@@ -358,10 +452,9 @@ summary: A polyglot test runner for sample code
358
452
  test_files:
359
453
  - features/bootstrapping.feature
360
454
  - features/cloning.feature
361
- - features/execution.feature
362
455
  - features/fixtures/configs/empty.yml
363
456
  - features/fixtures/configs/hello_world.yml
364
- - features/fixtures/spec/polytrix_spec.rb
457
+ - features/show.feature
365
458
  - features/solo.feature
366
459
  - features/states.feature
367
460
  - features/step_definitions/sdk_steps.rb
@@ -383,11 +476,10 @@ test_files:
383
476
  - spec/polytrix/file_finder_spec.rb
384
477
  - spec/polytrix/implementor_spec.rb
385
478
  - spec/polytrix/manifest_spec.rb
386
- - spec/polytrix/middleware/feature_executor_spec.rb
387
479
  - spec/polytrix/result_spec.rb
388
- - spec/polytrix/validations_spec.rb
389
480
  - spec/polytrix/validator_registry_spec.rb
390
481
  - spec/polytrix/validator_spec.rb
391
482
  - spec/polytrix_spec.rb
392
483
  - spec/spec_helper.rb
393
484
  - spec/thor_spy.rb
485
+ has_rdoc:
@@ -1,53 +0,0 @@
1
- Feature: Running SDKs
2
-
3
- Polytrix uses the [script/bootstrap](http://wynnnetherland.com/linked/2013012801/bootstrapping-consistency) pattern to prepare SDKs for testing. You can hook into any package manager, compiler, build tool, or any other toolchain to prepare to build and run samples.
4
-
5
- Polytrix also sets up tags for the SDKs so you can use the normal rspec `-t` option to select which SDK to run.
6
-
7
- Scenario: Running all SDKs
8
- Given the ruby SDK
9
- And the java SDK
10
- And the python SDK
11
- And the hello_world polytrix config
12
- And the standard rspec setup
13
- When I run `bundle exec rspec`
14
- And the output should contain "3 examples, 0 failures"
15
-
16
- Scenario: Running a single SDK
17
- Given the ruby SDK
18
- And the java SDK
19
- And the python SDK
20
- And the hello_world polytrix config
21
- And the standard rspec setup
22
- When I run `bundle exec rspec -t ruby`
23
- Then the output should contain "Hello, world!"
24
- And the output should contain "1 example, 0 failures"
25
-
26
- Scenario: Custom assertions
27
- Given the ruby SDK
28
- And the java SDK
29
- And the python SDK
30
- And the hello_world polytrix config
31
- And the standard rspec setup
32
- And a file named "spec/custom_spec.rb" with:
33
- """
34
- require 'polytrix/rspec'
35
-
36
- # This is more of an integration test, but makes sure the rspec API is working.
37
- # Expect results to all be pending, because there's no implementors in this proj.
38
-
39
- Polytrix.validate(suite: 'Katas', sample: 'hello world') do |challenge|
40
- # You can make assertions about the process using the Mixlib::ShellOut API
41
- expect(challenge[:result].execution_result.stdout).to include 'Hello, world!'
42
- expect(challenge[:result].execution_result.stderr).to be_empty
43
- expect(challenge[:result].execution_result.exitstatus).to eq(1) # normally this would be 0
44
- end
45
-
46
- Polytrix.validate(suite: 'Katas', sample: 'quine') do |challenge|
47
- expect(challenge[:result].execution_result.stdout).to eq File.read(challenge[:result].source)
48
- end
49
- Polytrix.load_tests
50
-
51
- """
52
- When I run `bundle exec rspec spec/custom_spec.rb`
53
- And the output should match /expected: 1\s+got: 0/
@@ -1,7 +0,0 @@
1
- require 'polytrix/rspec'
2
-
3
- Polytrix.configure do |polytrix|
4
- polytrix.manifest = 'polytrix.yml'
5
- end
6
- Polytrix.bootstrap
7
- Polytrix.load_tests
@@ -1,84 +0,0 @@
1
- module Polytrix
2
- module Reports
3
- # autoload :TextReporter, 'polytrix/cli/reports/text_reporter'
4
- autoload :MarkdownReporter, 'polytrix/cli/reports/markdown_reporter'
5
- # autoload :HTMLReporter, 'polytrix/cli/reports/html_reporter'
6
- autoload :JSONReporter, 'polytrix/cli/reports/json_reporter'
7
- autoload :YAMLReporter, 'polytrix/cli/reports/yaml_reporter'
8
- end
9
- module Command
10
- class Report < Polytrix::CLI::Base
11
- # class_options = super.class_options
12
- class_option :format, desc: 'Output format for the report', default: 'text', enum: %w(text markdown json yaml)
13
-
14
- desc 'report summary', 'Generate a summary report by SDK'
15
- config_options
16
- log_options
17
- def summary
18
- setup
19
- results = load_results
20
- table = [%w(sdk passed failed pending skipped)]
21
- results.each do |sdk, summary|
22
- table << [sdk, summary[:passed], summary[:failed], summary[:pending], summary[:skipped]]
23
- end
24
- reporter.print_table table
25
- end
26
-
27
- desc 'report matrix', 'Generate a feature matrix report'
28
- config_options
29
- log_options
30
- def matrix
31
- setup
32
- sdk_names = Polytrix.implementors.map(&:name)
33
- table = [%w(Product Feature).concat(sdk_names)]
34
-
35
- matrix_data.suites.each do |suite_name, suite_data|
36
- suite_data.samples.each do |scenario_name, scenario_results|
37
-
38
- statuses = sdk_names.map do |sdk|
39
- result = Result.new(scenario_results[sdk])
40
- result.status
41
- end
42
-
43
- table << [suite_name, scenario_name].concat(statuses)
44
- end
45
- end
46
- reporter.print_table table
47
- end
48
-
49
- protected
50
-
51
- def load_results
52
- result_stats = Hash.new do |hash, sdk|
53
- hash[sdk] = { passed: 0, failed: 0, pending: 0, skipped: 0 }
54
- end
55
- matrix_data.suites.reduce(result_stats) do |hash, (suite_name, suite)|
56
- suite.samples.each do |sample, suite_results|
57
- Polytrix.implementors.map(&:name).each do |sdk|
58
- result = Result.new(suite_results[sdk])
59
- result.validations << Validation.new(validated_by: 'polytrix', result: 'skipped')
60
- hash[sdk][result.status.to_sym] += 1
61
- end
62
- end
63
- hash
64
- end
65
- result_stats
66
- end
67
-
68
- def reporter
69
- @reporter ||= case options[:format]
70
- when 'text'
71
- self
72
- when 'markdown'
73
- Polytrix::CLI::Reports::MarkdownReporter.new
74
- when 'json'
75
- Polytrix::CLI::Reports::JSONReporter.new
76
- when 'yaml'
77
- Polytrix::CLI::Reports::YAMLReporter.new
78
- else
79
- fail "Unknown report format #{options[:format]}"
80
- end
81
- end
82
- end
83
- end
84
- end
@@ -1,27 +0,0 @@
1
- module Polytrix
2
- module Command
3
- class RunDoc < Thor::Group
4
- class_option :format,
5
- aliases: '-f',
6
- enum: %w(markdown rst),
7
- default: 'markdown',
8
- desc: 'The documentation input format'
9
-
10
- def rundoc
11
- files = args
12
- # Logging.mdc['command'] = 'rundoc'
13
- if files.empty?
14
- # help('code2doc')
15
- abort 'No FILES were specified, check usage above'
16
- end
17
-
18
- files.each do |file|
19
- target_file_name = File.basename(file, File.extname(file)) + ".#{options[:format]}"
20
- target_file = File.join(options[:target_dir], target_file_name)
21
- say_status 'polytrix:code2doc', "Converting #{file} to #{target_file}"
22
- Polytrix::DocumentationExecutor.new.execute file
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,75 +0,0 @@
1
- module Polytrix
2
- module Core
3
- module FileSystemHelper
4
- include Polytrix::Logging
5
- include Polytrix::StringHelpers
6
- class FileNotFound < StandardError; end
7
-
8
- # Finds a file by loosely matching the file name to a scenario name
9
- def find_file(search_path, scenario_name, ignored_patterns = read_gitignore(search_path))
10
- glob_string = "#{search_path}/**/*#{slugify(scenario_name)}.*"
11
- potential_files = Dir.glob(glob_string, File::FNM_CASEFOLD)
12
- potential_files.concat Dir.glob(glob_string.gsub('_', '-'), File::FNM_CASEFOLD)
13
- potential_files.concat Dir.glob(glob_string.gsub('_', ''), File::FNM_CASEFOLD)
14
-
15
- # Filter out ignored filesFind the first file, not including generated files
16
- files = potential_files.select do |f|
17
- !ignored? ignored_patterns, search_path, f
18
- end
19
-
20
- # Select the shortest path, likely the best match
21
- file = files.min_by(&:length)
22
-
23
- fail FileNotFound, "No file was found for #{scenario_name} within #{search_path}" if file.nil?
24
- Pathname.new file
25
- end
26
-
27
- def recursive_parent_search(path, file_name = nil, &block)
28
- if block_given?
29
- obj = yield path
30
- return obj if obj
31
- elsif file_name
32
- file = File.expand_path(file_name, path)
33
- logger.debug "Checking for #{file}"
34
- found = File.exists? file
35
- else
36
- fail ArgumentError, 'Provide either a file_name to search for, or a block to check directories'
37
- end
38
-
39
- parent_dir = File.dirname(path)
40
- return path if found
41
- return nil if parent_dir == path # we've reached the top
42
- recursive_parent_search(parent_dir, file_name, &block)
43
- end
44
-
45
- private
46
-
47
- def read_gitignore(dir)
48
- gitignore_file = "#{dir}/.gitignore"
49
- File.read(gitignore_file)
50
- rescue
51
- ''
52
- end
53
-
54
- def ignored?(ignored_patterns, base_path, target_file)
55
- # Trying to match the git ignore rules but there's some discrepencies.
56
- ignored_patterns.split.find do |pattern|
57
- # if git ignores a folder, we should ignore all files it contains
58
- pattern = "#{pattern}**" if pattern[-1] == '/'
59
- started_with_slash = pattern.start_with? '/'
60
-
61
- pattern.gsub!(/\A\//, '') # remove leading slashes since we're searching from root
62
- file = relativize(target_file, base_path)
63
- ignored = file.fnmatch? pattern
64
- ignored || (file.fnmatch? "**/#{pattern}" unless started_with_slash)
65
- end
66
- end
67
-
68
- def relativize(file, base_path)
69
- absolute_file = File.absolute_path(file)
70
- absolute_base_path = File.absolute_path(base_path)
71
- Pathname.new(absolute_file).relative_path_from Pathname.new(absolute_base_path)
72
- end
73
- end
74
- end
75
- end
@@ -1,4 +0,0 @@
1
- module Polytrix
2
- class ManifestSection < Polytrix::Dash
3
- end
4
- end
@@ -1,15 +0,0 @@
1
- module Polytrix
2
- module StringHelpers
3
- module ClassMethods
4
- def slugify(*string)
5
- string.join('-').downcase.gsub(' ', '_')
6
- end
7
- end
8
-
9
- def self.included(base)
10
- base.extend(ClassMethods)
11
- end
12
-
13
- include ClassMethods
14
- end
15
- end