knapsack 1.10.0 → 1.11.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 04c056b1aca1e07b752f190165b9bf7d8b3d20c8
4
- data.tar.gz: 4f6546493271a2edcfab8735e672b7966197b21e
3
+ metadata.gz: 586b4f20bd1e8eeaa8cecd582028c38bbda68798
4
+ data.tar.gz: ba890d94aeb726731268b2138c81106c8d1dd21b
5
5
  SHA512:
6
- metadata.gz: 263a43a683b096a68c6a0f3bc3c88c63893383d46069c0753b75e6dca22907aaae3789a2cc19f86d29fc5a4a7007019b18014630930e348c12f77132fe3569d8
7
- data.tar.gz: be3932dfa2720b181319501886dcdeef30f73add44616d445ab856faff125cf76bfee03cac6f2694430f3ca9931e0b9c56c55e8b52df791a721daf58bbd1fbf8
6
+ metadata.gz: 0d826026f771d18064f2fc0c4fd48f41b0193d015f1c655bee098c8e887665271245ef1293140347a49ebb93b1b34868ed05f1c1ff5342374eb6dd8bc8c80d1f
7
+ data.tar.gz: f92c71f48e7a86142903714034d2e1e6a08412592159e544159d89b01bc3841008d173d2fe461ab6597961533d2c8e9ec246f163b7cec046dc86d65075c1784c
@@ -53,6 +53,7 @@ script:
53
53
  - bin/print_header.sh "Run specs from multiple directories with manually specified test_dir"
54
54
  - KNAPSACK_TEST_DIR=spec_examples KNAPSACK_TEST_FILE_PATTERN="{spec_examples,spec_engine_examples}/**{,/*/**}/*_spec.rb" bundle exec rake knapsack:rspec
55
55
 
56
+
56
57
  - bin/print_header.sh "------------------------------------------------------"
57
58
 
58
59
 
@@ -82,5 +83,32 @@ script:
82
83
  - bin/print_header.sh "Run tests when test file was removed and still exists in knapsack report json"
83
84
  - rm test_examples/fast/unit_test.rb
84
85
  - KNAPSACK_TEST_FILE_PATTERN="test_examples/**{,/*/**}/*_test.rb" bundle exec rake knapsack:minitest
86
+
87
+
88
+ - bin/print_header.sh "------------------------------------------------------"
89
+
90
+
91
+ # Tests for example spinach test suite
92
+ - bin/print_header.sh "Generate knapsack report"
93
+ - KNAPSACK_GENERATE_REPORT=true bundle exec spinach -f spinach_examples
94
+
95
+ - bin/print_header.sh "Run tests with enabled time offset warning"
96
+ - bundle exec spinach -f spinach_examples
97
+
98
+ - bin/print_header.sh "Run rake task for the first CI node"
99
+ - CI_NODE_TOTAL=2 CI_NODE_INDEX=0 KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
100
+ - bin/print_header.sh "Run rake task for the second CI node"
101
+ - CI_NODE_TOTAL=2 CI_NODE_INDEX=1 KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
102
+
103
+ - bin/print_header.sh "Run tests with custom knapsack logger"
104
+ - CUSTOM_LOGGER=true KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
105
+
106
+ - bin/print_header.sh "Run tests for custom knapsack report path"
107
+ - cp knapsack_spinach_report.json knapsack_custom_spinach_report.json
108
+ - KNAPSACK_REPORT_PATH="knapsack_custom_spinach_report.json" KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
109
+
110
+ - bin/print_header.sh "Run tests when test file was removed and still exists in knapsack report json"
111
+ - rm spinach_examples/scenario1.feature
112
+ - KNAPSACK_TEST_FILE_PATTERN="spinach_examples/**{,/*/**}/*.feature" bundle exec rake "knapsack:spinach[-f spinach_examples]"
85
113
  notifications:
86
114
  email: false
@@ -2,6 +2,14 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 1.11.0
6
+
7
+ * Add support for Spinach
8
+
9
+ https://github.com/ArturT/knapsack/pull/41
10
+
11
+ https://github.com/ArturT/knapsack/compare/v1.10.0...v1.11.0
12
+
5
13
  ### 1.10.0
6
14
 
7
15
  * Log the time offset warning at INFO if time not exceeded
data/README.md CHANGED
@@ -42,6 +42,7 @@ Presentations about gem:
42
42
  - [Step for RSpec](#step-for-rspec)
43
43
  - [Step for Cucumber](#step-for-cucumber)
44
44
  - [Step for Minitest](#step-for-minitest)
45
+ - [Step for Spinach](#step-for-spinach)
45
46
  - [Custom configuration](#custom-configuration)
46
47
  - [Common step](#common-step)
47
48
  - [Adding or removing tests](#adding-or-removing-tests)
@@ -51,6 +52,7 @@ Presentations about gem:
51
52
  - [Passing arguments to rspec](#passing-arguments-to-rspec)
52
53
  - [Passing arguments to cucumber](#passing-arguments-to-cucumber)
53
54
  - [Passing arguments to minitest](#passing-arguments-to-minitest)
55
+ - [Passing arguments to spinach](#passing-arguments-to-spinach)
54
56
  - [Knapsack binary](#knapsack-binary)
55
57
  - [Info for CircleCI users](#info-for-circleci-users)
56
58
  - [Step 1](#step-1)
@@ -150,9 +152,21 @@ knapsack_adapter = Knapsack::Adapters::MinitestAdapter.bind
150
152
  knapsack_adapter.set_test_helper_path(__FILE__)
151
153
  ```
152
154
 
155
+ ### Step for Spinach
156
+
157
+ Create file `features/support/env.rb` and add there:
158
+
159
+ ```ruby
160
+ require 'knapsack'
161
+
162
+ # CUSTOM_CONFIG_GOES_HERE
163
+
164
+ Knapsack::Adapters::SpinachAdapter.bind
165
+ ```
166
+
153
167
  ### Custom configuration
154
168
 
155
- You can change default Knapsack configuration for RSpec, Cucumber or Minitest tests. Here are examples what you can do. Put below configuration instead of `CUSTOM_CONFIG_GOES_HERE`.
169
+ You can change default Knapsack configuration for RSpec, Cucumber, Minitest or Spinach tests. Here are examples what you can do. Put below configuration instead of `CUSTOM_CONFIG_GOES_HERE`.
156
170
 
157
171
  ```ruby
158
172
  Knapsack.tracker.config({
@@ -184,7 +198,10 @@ Generate time execution report for your test files. Run below command on one of
184
198
  # Step for Minitest
185
199
  $ KNAPSACK_GENERATE_REPORT=true bundle exec rake test
186
200
 
187
- Commit generated report `knapsack_rspec_report.json`, `knapsack_cucumber_report.json` or `knapsack_minitest_report.json` into your repository.
201
+ # Step for Spinach
202
+ $ KNAPSACK_GENERATE_REPORT=true bundle exec spinach
203
+
204
+ Commit generated report `knapsack_rspec_report.json`, `knapsack_cucumber_report.json`, `knapsack_minitest_report.json` or `knapsack_spinach_report.json` into your repository.
188
205
 
189
206
  This report should be updated only after you add a lot of new slow tests or you change existing ones which causes a big time execution difference between CI nodes. Either way, you will get time offset warning at the end of the rspec/cucumber/minitest results which reminds you when it’s a good time to regenerate the knapsack report.
190
207
 
@@ -211,6 +228,9 @@ On your CI server run this command for the first CI node. Update `CI_NODE_INDEX`
211
228
  # Step for Minitest
212
229
  $ CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:minitest
213
230
 
231
+ # Step for Spinach
232
+ $ CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:spinach
233
+
214
234
  You can add `KNAPSACK_TEST_FILE_PATTERN` if your tests are not in default directory. For instance:
215
235
 
216
236
  # Step for RSpec
@@ -222,6 +242,9 @@ You can add `KNAPSACK_TEST_FILE_PATTERN` if your tests are not in default direct
222
242
  # Step for Minitest
223
243
  $ KNAPSACK_TEST_FILE_PATTERN="directory_with_tests/**{,/*/**}/*_spec.rb" CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:minitest
224
244
 
245
+ # Step for Spinach
246
+ $ KNAPSACK_TEST_FILE_PATTERN="directory_with_features/**/*.feature" CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:spinach
247
+
225
248
  You can set `KNAPSACK_REPORT_PATH` if your knapsack report was saved in non default location. Example:
226
249
 
227
250
  # Step for RSpec
@@ -233,6 +256,9 @@ You can set `KNAPSACK_REPORT_PATH` if your knapsack report was saved in non defa
233
256
  # Step for Minitest
234
257
  $ KNAPSACK_REPORT_PATH="knapsack_custom_report.json" CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:minitest
235
258
 
259
+ # Step for Spinach
260
+ $ KNAPSACK_REPORT_PATH="knapsack_custom_report.json" CI_NODE_TOTAL=2 CI_NODE_INDEX=0 bundle exec rake knapsack:spinach
261
+
236
262
  ### Info about ENV variables
237
263
 
238
264
  `CI_NODE_TOTAL` - total number CI nodes you have.
@@ -269,6 +295,12 @@ For instance to run verbose tests:
269
295
 
270
296
  $ bundle exec rake "knapsack:minitest[--verbose]"
271
297
 
298
+ #### Passing arguments to spinach
299
+
300
+ Add arguments to knapsack spinach task like this:
301
+
302
+ $ bundle exec rake "knapsack:spinach[--name feature]"
303
+
272
304
  ### Knapsack binary
273
305
 
274
306
  You can install knapsack globally and use binary. For instance:
@@ -276,6 +308,7 @@ You can install knapsack globally and use binary. For instance:
276
308
  $ knapsack rspec "--tag custom_tag_name --profile"
277
309
  $ knapsack cucumber
278
310
  $ knapsack minitest "--verbose --pride"
311
+ $ knapsack spinach "-f spinach_examples"
279
312
 
280
313
  [Here](https://github.com/ArturT/knapsack/pull/21) you will find example when it might be useful.
281
314
 
@@ -300,9 +333,12 @@ test:
300
333
 
301
334
  # Step for Minitest
302
335
  - KNAPSACK_GENERATE_REPORT=true bundle exec rake test
336
+
337
+ # Step for Spinach
338
+ - KNAPSACK_GENERATE_REPORT=true bundle exec spinach
303
339
  ```
304
340
 
305
- After tests pass on your CircleCI machine your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json` or `knapsack_minitest_report.json` file and commit.
341
+ After tests pass on your CircleCI machine your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json`, `knapsack_minitest_report.json` or `knapsack_spinach_report.json` file and commit.
306
342
 
307
343
  #### Step 2
308
344
 
@@ -322,6 +358,10 @@ test:
322
358
  # Step for Minitest
323
359
  - bundle exec rake knapsack:minitest:
324
360
  parallel: true # Caution: there are 8 spaces indentation!
361
+
362
+ # Step for Spinach
363
+ - bundle exec rake knapsack:spinach:
364
+ parallel: true # Caution: there are 8 spaces indentation!
325
365
  ```
326
366
 
327
367
  Now everything should works. You will get warning at the end of rspec/cucumber/minitest results if time execution will take too much.
@@ -342,9 +382,12 @@ script:
342
382
 
343
383
  # Step for Minitest
344
384
  - "KNAPSACK_GENERATE_REPORT=true bundle exec rake test"
385
+
386
+ # Step for Spinach
387
+ - "KNAPSACK_GENERATE_REPORT=true bundle exec spinach"
345
388
  ```
346
389
 
347
- After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json` or `knapsack_minitest_report.json` file and commit.
390
+ After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json`, `knapsack_minitest_report.json` or `knapsack_spinach_report.json` file and commit.
348
391
 
349
392
  #### Step 2
350
393
 
@@ -361,6 +404,9 @@ script:
361
404
  # Step for Minitest
362
405
  - "bundle exec rake knapsack:minitest"
363
406
 
407
+ # Step for Spinach
408
+ - "bundle exec rake knapsack:spinach"
409
+
364
410
  env:
365
411
  - CI_NODE_TOTAL=2 CI_NODE_INDEX=0
366
412
  - CI_NODE_TOTAL=2 CI_NODE_INDEX=1
@@ -379,6 +425,9 @@ script:
379
425
  # Step for Minitest
380
426
  - "bundle exec rake knapsack:minitest"
381
427
 
428
+ # Step for Spinach
429
+ - "bundle exec rake knapsack:spinach"
430
+
382
431
  env:
383
432
  global:
384
433
  - RAILS_ENV=test
@@ -411,7 +460,10 @@ For the first time run all tests at once with enabled report generator. Set up y
411
460
  # Step for Minitest
412
461
  KNAPSACK_GENERATE_REPORT=true bundle exec rake test
413
462
 
414
- After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/test results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json` or `knapsack_minitest_report.json` file and commit.
463
+ # Step for Spinach
464
+ KNAPSACK_GENERATE_REPORT=true bundle exec spinach
465
+
466
+ After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/test results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json`, `knapsack_minitest_report.json` or `knapsack_spinach_report.json` file and commit.
415
467
 
416
468
  #### Step 2
417
469
 
@@ -424,6 +476,8 @@ Knapsack supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_CURR
424
476
  bundle exec rake knapsack:cucumber
425
477
  ## Step for Minitest
426
478
  bundle exec rake knapsack:minitest
479
+ ## Step for Spinach
480
+ bundle exec rake knapsack:spinach
427
481
 
428
482
  # Thread 2
429
483
  ## Step for RSpec
@@ -432,6 +486,8 @@ Knapsack supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_CURR
432
486
  bundle exec rake knapsack:cucumber
433
487
  ## Step for Minitest
434
488
  bundle exec rake knapsack:minitest
489
+ ## Step for Spinach
490
+ bundle exec rake knapsack:spinach
435
491
 
436
492
  Tests will be split across threads.
437
493
 
@@ -450,7 +506,10 @@ For the first time run all tests at once with enabled report generator. Run the
450
506
  # Step for Minitest
451
507
  KNAPSACK_GENERATE_REPORT=true bundle exec rake test
452
508
 
453
- After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json` or `knapsack_minitest_report.json` file and commit.
509
+ # Step for Spinach
510
+ KNAPSACK_GENERATE_REPORT=true bundle exec spinach
511
+
512
+ After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json`, `knapsack_minitest_report.json` or `knapsack_spinach_report.json` file and commit.
454
513
 
455
514
  #### Step 2
456
515
 
@@ -465,6 +524,9 @@ Knapsack supports buildkite ENVs `BUILDKITE_PARALLEL_JOB_COUNT` and `BUILDKITE_P
465
524
  # Step for Minitest
466
525
  bundle exec rake knapsack:minitest
467
526
 
527
+ # Step for Spinach
528
+ bundle exec rake knapsack:spinach
529
+
468
530
  ### Info for snap-ci.com users
469
531
 
470
532
  #### Step 1
@@ -480,7 +542,10 @@ For the first time run all tests at once with enabled report generator. Run the
480
542
  # Step for Minitest
481
543
  KNAPSACK_GENERATE_REPORT=true bundle exec rake test
482
544
 
483
- After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json` or `knapsack_minitest_report.json` file and commit.
545
+ # Step for Spinach
546
+ KNAPSACK_GENERATE_REPORT=true bundle exec spinach
547
+
548
+ After tests pass your should copy knapsack json report which is rendered at the end of rspec/cucumber/minitest results. Save it into your repository as `knapsack_rspec_report.json`, `knapsack_cucumber_report.json`, `knapsack_minitest_report.json` or `knapsack_spinach_report.json` file and commit.
484
549
 
485
550
  #### Step 2
486
551
 
@@ -495,6 +560,9 @@ Knapsack supports snap-ci.com ENVs `SNAP_WORKER_TOTAL` and `SNAP_WORKER_INDEX`.
495
560
  # Step for Minitest
496
561
  bundle exec rake knapsack:minitest
497
562
 
563
+ # Step for Spinach
564
+ bundle exec rake knapsack:spinach
565
+
498
566
  ## FAQ
499
567
 
500
568
  ### What time offset warning means?
@@ -582,7 +650,8 @@ Specs in `spec_examples/leftover` take more than 3 seconds. This should cause a
582
650
  2. Create your feature branch (`git checkout -b my-new-feature`)
583
651
  3. Commit your changes (`git commit -am 'Add some feature'`)
584
652
  4. Push to the branch (`git push origin my-new-feature`)
585
- 5. Create a new Pull Request
653
+ 5. You can create example tests in related repository with example of [rails application and knapsack gem usage](https://github.com/KnapsackPro/rails-app-with-knapsack).
654
+ 6. Create a new Pull Request
586
655
 
587
656
  ## Acknowledgements
588
657
 
@@ -9,6 +9,7 @@ MAP = {
9
9
  'rspec' => Knapsack::Runners::RSpecRunner,
10
10
  'cucumber' => Knapsack::Runners::CucumberRunner,
11
11
  'minitest' => Knapsack::Runners::MinitestRunner,
12
+ 'spinach' => Knapsack::Runners::SpinachRunner,
12
13
  }
13
14
 
14
15
  runner_class = MAP[runner]
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_development_dependency 'rspec', '~> 3.0', '>= 2.0.0'
26
26
  spec.add_development_dependency 'rspec-its', '~> 1.2'
27
27
  spec.add_development_dependency 'cucumber', '>= 0'
28
+ spec.add_development_dependency 'spinach', '>= 0.8'
28
29
  spec.add_development_dependency 'minitest', '>= 5.0.0'
29
30
  spec.add_development_dependency 'codeclimate-test-reporter', '~> 0'
30
31
  spec.add_development_dependency 'pry', '~> 0'
@@ -0,0 +1,4 @@
1
+ {
2
+ "spinach_examples/scenario1.feature": 0.0017168521881103516,
3
+ "spinach_examples/scenario2.feature": 0.002157926559448242
4
+ }
@@ -18,9 +18,11 @@ require_relative 'knapsack/adapters/base_adapter'
18
18
  require_relative 'knapsack/adapters/rspec_adapter'
19
19
  require_relative 'knapsack/adapters/cucumber_adapter'
20
20
  require_relative 'knapsack/adapters/minitest_adapter'
21
+ require_relative 'knapsack/adapters/spinach_adapter'
21
22
  require_relative 'knapsack/runners/rspec_runner'
22
23
  require_relative 'knapsack/runners/cucumber_runner'
23
24
  require_relative 'knapsack/runners/minitest_runner'
25
+ require_relative 'knapsack/runners/spinach_runner'
24
26
 
25
27
  module Knapsack
26
28
  class << self
@@ -0,0 +1,45 @@
1
+ require 'spinach'
2
+
3
+ module Knapsack
4
+ module Adapters
5
+ class SpinachAdapter < BaseAdapter
6
+ TEST_DIR_PATTERN = 'features/**{,/*/**}/*.feature'
7
+ REPORT_PATH = 'knapsack_spinach_report.json'
8
+
9
+ def bind_time_tracker
10
+ Spinach.hooks.before_scenario do |scenario_data, step_definitions|
11
+ Knapsack.tracker.test_path = SpinachAdapter.test_path(scenario_data)
12
+ Knapsack.tracker.start_timer
13
+ end
14
+
15
+ Spinach.hooks.after_scenario do
16
+ Knapsack.tracker.stop_timer
17
+ end
18
+
19
+ Spinach.hooks.after_run do
20
+ Knapsack.logger.info(Presenter.global_time)
21
+ end
22
+ end
23
+
24
+ def bind_report_generator
25
+ Spinach.hooks.after_run do
26
+ Knapsack.report.save
27
+ Knapsack.logger.info(Presenter.report_details)
28
+ end
29
+ end
30
+
31
+ def bind_time_offset_warning
32
+ Spinach.hooks.after_run do
33
+ Knapsack.logger.log(
34
+ Presenter.time_offset_log_level,
35
+ Presenter.time_offset_warning
36
+ )
37
+ end
38
+ end
39
+
40
+ def self.test_path(scenario)
41
+ scenario.feature.filename
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,22 @@
1
+ module Knapsack
2
+ module Runners
3
+ class SpinachRunner
4
+ def self.run(args)
5
+ allocator = Knapsack::AllocatorBuilder.new(Knapsack::Adapters::SpinachAdapter).allocator
6
+
7
+ Knapsack.logger.info
8
+ Knapsack.logger.info 'Report features:'
9
+ Knapsack.logger.info allocator.report_node_tests
10
+ Knapsack.logger.info
11
+ Knapsack.logger.info 'Leftover features:'
12
+ Knapsack.logger.info allocator.leftover_node_tests
13
+ Knapsack.logger.info
14
+
15
+ cmd = %Q[bundle exec spinach #{args} -- #{allocator.stringify_node_tests}]
16
+
17
+ system(cmd)
18
+ exit($?.exitstatus) unless $?.exitstatus.zero?
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Knapsack
2
- VERSION = '1.10.0'
2
+ VERSION = '1.11.0'
3
3
  end
@@ -0,0 +1,7 @@
1
+ require 'knapsack'
2
+
3
+ namespace :knapsack do
4
+ task :spinach, [:spinach_args] do |_, args|
5
+ Knapsack::Runners::SpinachRunner.run(args[:spinach_args])
6
+ end
7
+ end
@@ -0,0 +1,84 @@
1
+ describe Knapsack::Adapters::SpinachAdapter do
2
+ context do
3
+ it_behaves_like 'adapter'
4
+ end
5
+
6
+ describe 'bind methods' do
7
+ let(:config) { double }
8
+ let(:logger) { instance_double(Knapsack::Logger) }
9
+
10
+ before do
11
+ expect(Knapsack).to receive(:logger).and_return(logger)
12
+ end
13
+
14
+ describe '#bind_time_tracker' do
15
+ let(:tracker) { instance_double(Knapsack::Tracker) }
16
+ let(:test_path) { 'spec/a_spec.rb' }
17
+ let(:global_time) { 'Global time: 01m 05s' }
18
+ let(:example_group) { double }
19
+ let(:scenario_data) do
20
+ double(feature: double(filename: 'a_spec.rb'))
21
+ end
22
+
23
+ it do
24
+ allow(Knapsack).to receive(:tracker).and_return(tracker)
25
+
26
+ expect(Spinach.hooks).to receive(:before_scenario).and_yield(scenario_data, nil)
27
+ expect(described_class).to receive(:test_path).with(scenario_data).and_return(test_path)
28
+ expect(tracker).to receive(:test_path=).with(test_path)
29
+ expect(tracker).to receive(:start_timer)
30
+
31
+ expect(Spinach.hooks).to receive(:after_scenario).and_yield
32
+ expect(tracker).to receive(:stop_timer)
33
+
34
+ expect(Spinach.hooks).to receive(:after_run).and_yield
35
+ expect(Knapsack::Presenter).to receive(:global_time).and_return(global_time)
36
+ expect(logger).to receive(:info).with(global_time)
37
+
38
+ subject.bind_time_tracker
39
+ end
40
+ end
41
+
42
+ describe '#bind_report_generator' do
43
+ let(:report) { instance_double(Knapsack::Report) }
44
+ let(:report_details) { 'Report details' }
45
+
46
+ it do
47
+ expect(Spinach.hooks).to receive(:after_run).and_yield
48
+
49
+ expect(Knapsack).to receive(:report).and_return(report)
50
+ expect(report).to receive(:save)
51
+
52
+ expect(Knapsack::Presenter).to receive(:report_details).and_return(report_details)
53
+ expect(logger).to receive(:info).with(report_details)
54
+
55
+ subject.bind_report_generator
56
+ end
57
+ end
58
+
59
+ describe '#bind_time_offset_warning' do
60
+ let(:time_offset_warning) { 'Time offset warning' }
61
+ let(:log_level) { :info }
62
+
63
+ it do
64
+ expect(Spinach.hooks).to receive(:after_run).and_yield
65
+
66
+ expect(Knapsack::Presenter).to receive(:time_offset_warning).and_return(time_offset_warning)
67
+ expect(Knapsack::Presenter).to receive(:time_offset_log_level).and_return(log_level)
68
+ expect(logger).to receive(:log).with(log_level, time_offset_warning)
69
+
70
+ subject.bind_time_offset_warning
71
+ end
72
+ end
73
+ end
74
+
75
+ describe '.test_path' do
76
+ let(:scenario_data) do
77
+ double(feature: double(filename: 'a_spec.rb'))
78
+ end
79
+
80
+ subject { described_class.test_path(scenario_data) }
81
+
82
+ it { should eql 'a_spec.rb' }
83
+ end
84
+ end
@@ -2,11 +2,13 @@ describe Knapsack::TaskLoader do
2
2
  describe '#load_tasks' do
3
3
  let(:rspec_rake_task_path) { "#{Knapsack.root}/lib/tasks/knapsack_rspec.rake" }
4
4
  let(:cucumber_rake_task_path) { "#{Knapsack.root}/lib/tasks/knapsack_cucumber.rake" }
5
+ let(:spinach_rake_task_path) { "#{Knapsack.root}/lib/tasks/knapsack_spinach.rake" }
5
6
  let(:minitest_rake_task_path) { "#{Knapsack.root}/lib/tasks/knapsack_minitest.rake" }
6
7
 
7
8
  it do
8
9
  expect(subject).to receive(:import).with(rspec_rake_task_path)
9
10
  expect(subject).to receive(:import).with(cucumber_rake_task_path)
11
+ expect(subject).to receive(:import).with(spinach_rake_task_path)
10
12
  expect(subject).to receive(:import).with(minitest_rake_task_path)
11
13
  subject.load_tasks
12
14
  end
@@ -0,0 +1,6 @@
1
+ Feature: Test how spinach works for first test
2
+ Scenario: Format greeting
3
+ Given I have an empty array
4
+ And I append my first name and my last name to it
5
+ When I pass it to my super-duper method
6
+ Then the output should contain a formal greeting
@@ -0,0 +1,6 @@
1
+ Feature: Test how spinach works for second test
2
+ Scenario: Informal greeting
3
+ Given I have an empty array
4
+ And I append only my first name to it
5
+ When I pass it to my super-duper method
6
+ Then the output should contain a casual greeting
@@ -0,0 +1,13 @@
1
+ class Spinach::Features::TestHowSpinachWorksForFirstTest < Spinach::FeatureSteps
2
+ step 'I have an empty array' do
3
+ end
4
+
5
+ step 'I append my first name and my last name to it' do
6
+ end
7
+
8
+ step 'I pass it to my super-duper method' do
9
+ end
10
+
11
+ step 'the output should contain a formal greeting' do
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class Spinach::Features::TestHowSpinachWorksForSecondTest < Spinach::FeatureSteps
2
+ step 'I have an empty array' do
3
+ end
4
+
5
+ step 'I append only my first name to it' do
6
+ end
7
+
8
+ step 'I pass it to my super-duper method' do
9
+ end
10
+
11
+ step 'the output should contain a casual greeting' do
12
+ end
13
+ end
@@ -0,0 +1,4 @@
1
+ require 'rspec'
2
+ require 'knapsack'
3
+
4
+ Knapsack::Adapters::SpinachAdapter.bind
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.0
4
+ version: 1.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-01 00:00:00.000000000 Z
11
+ date: 2016-06-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - ">="
101
101
  - !ruby/object:Gem::Version
102
102
  version: '0'
103
+ - !ruby/object:Gem::Dependency
104
+ name: spinach
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0.8'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0.8'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: minitest
105
119
  requirement: !ruby/object:Gem::Requirement
@@ -174,11 +188,13 @@ files:
174
188
  - knapsack.gemspec
175
189
  - knapsack_minitest_report.json
176
190
  - knapsack_rspec_report.json
191
+ - knapsack_spinach_report.json
177
192
  - lib/knapsack.rb
178
193
  - lib/knapsack/adapters/base_adapter.rb
179
194
  - lib/knapsack/adapters/cucumber_adapter.rb
180
195
  - lib/knapsack/adapters/minitest_adapter.rb
181
196
  - lib/knapsack/adapters/rspec_adapter.rb
197
+ - lib/knapsack/adapters/spinach_adapter.rb
182
198
  - lib/knapsack/allocator.rb
183
199
  - lib/knapsack/allocator_builder.rb
184
200
  - lib/knapsack/config/env.rb
@@ -192,16 +208,19 @@ files:
192
208
  - lib/knapsack/runners/cucumber_runner.rb
193
209
  - lib/knapsack/runners/minitest_runner.rb
194
210
  - lib/knapsack/runners/rspec_runner.rb
211
+ - lib/knapsack/runners/spinach_runner.rb
195
212
  - lib/knapsack/task_loader.rb
196
213
  - lib/knapsack/tracker.rb
197
214
  - lib/knapsack/version.rb
198
215
  - lib/tasks/knapsack_cucumber.rake
199
216
  - lib/tasks/knapsack_minitest.rake
200
217
  - lib/tasks/knapsack_rspec.rake
218
+ - lib/tasks/knapsack_spinach.rake
201
219
  - spec/knapsack/adapters/base_adapter_spec.rb
202
220
  - spec/knapsack/adapters/cucumber_adapter_spec.rb
203
221
  - spec/knapsack/adapters/minitest_adapter_spec.rb
204
222
  - spec/knapsack/adapters/rspec_adapter_spec.rb
223
+ - spec/knapsack/adapters/spinach_adapter_spec.rb
205
224
  - spec/knapsack/allocator_builder_spec.rb
206
225
  - spec/knapsack/allocator_spec.rb
207
226
  - spec/knapsack/config/env_spec.rb
@@ -235,6 +254,11 @@ files:
235
254
  - spec_examples/slow/c_spec.rb
236
255
  - spec_examples/spec_helper.rb
237
256
  - spec_examples/support/shared_examples/common_example.rb
257
+ - spinach_examples/scenario1.feature
258
+ - spinach_examples/scenario2.feature
259
+ - spinach_examples/steps/test_how_spinach_works_for_first_test.rb
260
+ - spinach_examples/steps/test_how_spinach_works_for_second_test.rb
261
+ - spinach_examples/support/env.rb
238
262
  - test_examples/fast/spec_test.rb
239
263
  - test_examples/fast/unit_test.rb
240
264
  - test_examples/slow/slow_test.rb
@@ -269,6 +293,7 @@ test_files:
269
293
  - spec/knapsack/adapters/cucumber_adapter_spec.rb
270
294
  - spec/knapsack/adapters/minitest_adapter_spec.rb
271
295
  - spec/knapsack/adapters/rspec_adapter_spec.rb
296
+ - spec/knapsack/adapters/spinach_adapter_spec.rb
272
297
  - spec/knapsack/allocator_builder_spec.rb
273
298
  - spec/knapsack/allocator_spec.rb
274
299
  - spec/knapsack/config/env_spec.rb