knapsack_pro 0.7.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +53 -4
- data/bin/knapsack_pro +1 -0
- data/knapsack_pro.gemspec +1 -0
- data/lib/knapsack_pro.rb +2 -0
- data/lib/knapsack_pro/adapters/cucumber_adapter.rb +0 -1
- data/lib/knapsack_pro/adapters/spinach_adapter.rb +32 -0
- data/lib/knapsack_pro/config/env.rb +4 -0
- data/lib/knapsack_pro/runners/spinach_runner.rb +16 -0
- data/lib/knapsack_pro/version.rb +1 -1
- data/lib/tasks/spinach.rake +7 -0
- data/spec/knapsack_pro/adapters/spinach_adapter_spec.rb +61 -0
- data/spec/knapsack_pro/config/env_spec.rb +14 -0
- data/spec/knapsack_pro/runners/spinach_runner_spec.rb +47 -0
- data/spec/spec_helper.rb +1 -0
- metadata +23 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e7ac5f587d9dee9b22c6116419c96a243828b98
|
4
|
+
data.tar.gz: 16e1ccbecb5e73b84b1bb111defcc9190cff3143
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ab59ea41723296d57208c2f4cc32da736590805743c2fda37bde18deef583321d0d54c82b277b64f6504693b792084749097bcff206fc136f5bb61ea3ee484f
|
7
|
+
data.tar.gz: 122664dc5334650f701fd06aeb11142873addb6e3f962278d382d926267a4eefcb774ff3b16dda1f0ed322c86ff792d8f0903d28b199860b7ed598db121ad837
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
2
2
|
|
3
3
|
* TODO
|
4
4
|
|
5
|
+
### 0.8.0
|
6
|
+
|
7
|
+
* Add Spinach support
|
8
|
+
|
9
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/pull/11
|
10
|
+
|
11
|
+
https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.7.2...v0.8.0
|
12
|
+
|
5
13
|
### 0.7.2
|
6
14
|
|
7
15
|
* Preserve cucumber latest error message with exit code to fix problem with false positive cucumber failed tests
|
data/README.md
CHANGED
@@ -12,6 +12,7 @@ The knapsack_pro gem supports:
|
|
12
12
|
* [RSpec](http://rspec.info)
|
13
13
|
* [Cucumber](https://cucumber.io)
|
14
14
|
* [Minitest](http://docs.seattlerb.org/minitest/)
|
15
|
+
* [Spinach](https://github.com/codegram/spinach)
|
15
16
|
* [Turnip](https://github.com/jnicklas/turnip)
|
16
17
|
|
17
18
|
__Would you like to try knapsack_pro gem?__ You can [get API token here](http://knapsackpro.com).
|
@@ -51,6 +52,7 @@ For instance when you will run tests with rake knapsack_pro:rspec then:
|
|
51
52
|
- [Step for RSpec](#step-for-rspec)
|
52
53
|
- [Step for Cucumber](#step-for-cucumber)
|
53
54
|
- [Step for Minitest](#step-for-minitest)
|
55
|
+
- [Step for Spinach](#step-for-spinach)
|
54
56
|
- [Custom configuration](#custom-configuration)
|
55
57
|
- [Setup your CI server (How to set up 2 of 3)](#setup-your-ci-server-how-to-set-up-2-of-3)
|
56
58
|
- [Set API key token](#set-api-key-token)
|
@@ -65,6 +67,7 @@ For instance when you will run tests with rake knapsack_pro:rspec then:
|
|
65
67
|
- [Passing arguments to rspec](#passing-arguments-to-rspec)
|
66
68
|
- [Passing arguments to cucumber](#passing-arguments-to-cucumber)
|
67
69
|
- [Passing arguments to minitest](#passing-arguments-to-minitest)
|
70
|
+
- [Passing arguments to spinach](#passing-arguments-to-spinach)
|
68
71
|
- [Knapsack Pro binary](#knapsack-pro-binary)
|
69
72
|
- [Supported CI providers](#supported-ci-providers)
|
70
73
|
- [Info for CircleCI users](#info-for-circleci-users)
|
@@ -160,9 +163,21 @@ knapsack_pro_adapter = KnapsackPro::Adapters::MinitestAdapter.bind
|
|
160
163
|
knapsack_pro_adapter.set_test_helper_path(__FILE__)
|
161
164
|
```
|
162
165
|
|
166
|
+
#### Step for Spinach
|
167
|
+
|
168
|
+
Create file `features/support/knapsack_pro.rb` and add there:
|
169
|
+
|
170
|
+
```ruby
|
171
|
+
require 'knapsack_pro'
|
172
|
+
|
173
|
+
# CUSTOM_CONFIG_GOES_HERE
|
174
|
+
|
175
|
+
KnapsackPro::Adapters::CucumberAdapter.bind
|
176
|
+
```
|
177
|
+
|
163
178
|
#### Custom configuration
|
164
179
|
|
165
|
-
You can change default Knapsack Pro configuration for RSpec, Cucumber or
|
180
|
+
You can change default Knapsack Pro configuration for RSpec, Cucumber, Minitest or Spinach tests. Here are examples what you can do. Put below configuration instead of `CUSTOM_CONFIG_GOES_HERE`.
|
166
181
|
|
167
182
|
```ruby
|
168
183
|
# you can use your own logger
|
@@ -180,6 +195,7 @@ Set one or a few tokens depend on how many test suites you run on CI server.
|
|
180
195
|
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` - as value set token for rspec test suite. Token can be generated when you sign in to [knapsackpro.com](http://www.knapsackpro.com).
|
181
196
|
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER` - token for cucumber test suite.
|
182
197
|
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST` - token for minitest test suite.
|
198
|
+
* `KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH` - token for minitest test suite.
|
183
199
|
|
184
200
|
__Tip:__ In case you have for instance multiple rspec test suites then prepend each of knapsack_pro command which executes tests with `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` variable.
|
185
201
|
|
@@ -196,6 +212,9 @@ On your CI server run this command for the first CI node. Update `KNAPSACK_PRO_C
|
|
196
212
|
# Step for Minitest
|
197
213
|
$ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:minitest
|
198
214
|
|
215
|
+
# Step for Spinach
|
216
|
+
$ KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:spinach
|
217
|
+
|
199
218
|
You can add `KNAPSACK_PRO_TEST_FILE_PATTERN` if your tests are not in default directory. For instance:
|
200
219
|
|
201
220
|
# Step for RSpec
|
@@ -207,6 +226,9 @@ You can add `KNAPSACK_PRO_TEST_FILE_PATTERN` if your tests are not in default di
|
|
207
226
|
# Step for Minitest
|
208
227
|
$ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_tests/**{,/*/**}/*_test.rb" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:minitest
|
209
228
|
|
229
|
+
# Step for Spinach
|
230
|
+
$ KNAPSACK_PRO_TEST_FILE_PATTERN="directory_with_features/**{,/*/**}/*.feature" KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 bundle exec rake knapsack_pro:spinach
|
231
|
+
|
210
232
|
__Tip:__ If you use one of supported CI providers then instead of above steps you should [take a look on this](#supported-ci-providers).
|
211
233
|
|
212
234
|
__Tip 2:__ If you use one of unsupported CI providers ([here is list of supported CI providers](#supported-ci-providers)) then you should [set KNAPSACK_PRO_REPOSITORY_ADAPTER=git](#when-you-set-global-variable-knapsack_pro_repository_adaptergit-required-when-ci-provider-is-not-supported).
|
@@ -274,6 +296,12 @@ For instance to run verbose tests:
|
|
274
296
|
|
275
297
|
$ bundle exec rake "knapsack_pro:minitest[--verbose]"
|
276
298
|
|
299
|
+
#### Passing arguments to spinach
|
300
|
+
|
301
|
+
Add arguments to knapsack_pro spinach task like this:
|
302
|
+
|
303
|
+
$ bundle exec rake "knapsack_pro:spinach[--arg_name value]"
|
304
|
+
|
277
305
|
### Knapsack Pro binary
|
278
306
|
|
279
307
|
You can install knapsack_pro globally and use binary. For instance:
|
@@ -281,6 +309,7 @@ You can install knapsack_pro globally and use binary. For instance:
|
|
281
309
|
$ knapsack_pro rspec "--tag custom_tag_name --profile"
|
282
310
|
$ knapsack_pro cucumber "--name feature"
|
283
311
|
$ knapsack_pro minitest "--verbose --pride"
|
312
|
+
$ knapsack_pro spinach "--arg_name value"
|
284
313
|
|
285
314
|
This is optional way of using knapsack_pro when you don't want to add it to `Gemfile`.
|
286
315
|
|
@@ -299,6 +328,7 @@ machine:
|
|
299
328
|
# KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC: rspec-token
|
300
329
|
# KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER: cucumber-token
|
301
330
|
# KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST: minitest-token
|
331
|
+
# KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH: spinach-token
|
302
332
|
test:
|
303
333
|
override:
|
304
334
|
# Step for RSpec
|
@@ -312,6 +342,10 @@ test:
|
|
312
342
|
# Step for Minitest
|
313
343
|
- bundle exec rake knapsack_pro:minitest:
|
314
344
|
parallel: true # Caution: there are 8 spaces indentation!
|
345
|
+
|
346
|
+
# Step for Spinach
|
347
|
+
- bundle exec rake knapsack_pro:spinach:
|
348
|
+
parallel: true # Caution: there are 8 spaces indentation!
|
315
349
|
```
|
316
350
|
|
317
351
|
Please remember to add additional containers for your project in CircleCI settings.
|
@@ -331,12 +365,16 @@ script:
|
|
331
365
|
# Step for Minitest
|
332
366
|
- "bundle exec rake knapsack_pro:minitest"
|
333
367
|
|
368
|
+
# Step for Spinach
|
369
|
+
- "bundle exec rake knapsack_pro:spinach"
|
370
|
+
|
334
371
|
env:
|
335
372
|
global:
|
336
373
|
# tokens should be set in travis settings in web interface to avoid expose tokens in build logs
|
337
374
|
- KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token
|
338
375
|
- KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token
|
339
376
|
- KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token
|
377
|
+
- KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
|
340
378
|
|
341
379
|
- KNAPSACK_PRO_CI_NODE_TOTAL=2
|
342
380
|
matrix:
|
@@ -346,8 +384,8 @@ env:
|
|
346
384
|
|
347
385
|
Such configuration will generate matrix with 2 following ENV rows:
|
348
386
|
|
349
|
-
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token
|
350
|
-
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token
|
387
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=0 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
|
388
|
+
KNAPSACK_PRO_CI_NODE_TOTAL=2 KNAPSACK_PRO_CI_NODE_INDEX=1 KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC=rspec-token KNAPSACK_PRO_TEST_SUITE_TOKEN_CUCUMBER=cucumber-token KNAPSACK_PRO_TEST_SUITE_TOKEN_MINITEST=minitest-token KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH=spinach-token
|
351
389
|
|
352
390
|
More info about global and matrix ENV configuration in [travis docs](http://docs.travis-ci.com/user/build-configuration/#Environment-variables).
|
353
391
|
|
@@ -362,6 +400,8 @@ Knapsack Pro supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_
|
|
362
400
|
bundle exec rake knapsack_pro:cucumber
|
363
401
|
## Step for Minitest
|
364
402
|
bundle exec rake knapsack_pro:minitest
|
403
|
+
## Step for Spinach
|
404
|
+
bundle exec rake knapsack_pro:spinach
|
365
405
|
|
366
406
|
# Thread 2
|
367
407
|
## Step for RSpec
|
@@ -370,6 +410,8 @@ Knapsack Pro supports semaphoreapp ENVs `SEMAPHORE_THREAD_COUNT` and `SEMAPHORE_
|
|
370
410
|
bundle exec rake knapsack_pro:cucumber
|
371
411
|
## Step for Minitest
|
372
412
|
bundle exec rake knapsack_pro:minitest
|
413
|
+
## Step for Spinach
|
414
|
+
bundle exec rake knapsack_pro:spinach
|
373
415
|
|
374
416
|
Tests will be split across threads.
|
375
417
|
|
@@ -388,6 +430,9 @@ Knapsack Pro supports buildkite ENVs `BUILDKITE_PARALLEL_JOB_COUNT` and `BUILDKI
|
|
388
430
|
# Step for Minitest
|
389
431
|
bundle exec rake knapsack_pro:minitest
|
390
432
|
|
433
|
+
# Step for Spinach
|
434
|
+
bundle exec rake knapsack_pro:spinach
|
435
|
+
|
391
436
|
Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
|
392
437
|
|
393
438
|
#### Info for snap-ci.com users
|
@@ -403,6 +448,9 @@ Knapsack Pro supports snap-ci.com ENVs `SNAP_WORKER_TOTAL` and `SNAP_WORKER_INDE
|
|
403
448
|
# Step for Minitest
|
404
449
|
bundle exec rake knapsack_pro:minitest
|
405
450
|
|
451
|
+
# Step for Spinach
|
452
|
+
bundle exec rake knapsack_pro:spinach
|
453
|
+
|
406
454
|
Please remember to set up token like `KNAPSACK_PRO_TEST_SUITE_TOKEN_RSPEC` as global environment.
|
407
455
|
|
408
456
|
## Gem tests
|
@@ -419,4 +467,5 @@ To run specs for Knapsack Pro gem type:
|
|
419
467
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
420
468
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
421
469
|
4. Push to the branch (`git push origin my-new-feature`)
|
422
|
-
5.
|
470
|
+
5. You can create example tests in related repository with example of [rails application and knapsack_pro gem usage](https://github.com/KnapsackPro/rails-app-with-knapsack_pro).
|
471
|
+
6. Create a new Pull Request
|
data/bin/knapsack_pro
CHANGED
data/knapsack_pro.gemspec
CHANGED
@@ -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'
|
data/lib/knapsack_pro.rb
CHANGED
@@ -38,10 +38,12 @@ require_relative 'knapsack_pro/adapters/base_adapter'
|
|
38
38
|
require_relative 'knapsack_pro/adapters/rspec_adapter'
|
39
39
|
require_relative 'knapsack_pro/adapters/cucumber_adapter'
|
40
40
|
require_relative 'knapsack_pro/adapters/minitest_adapter'
|
41
|
+
require_relative 'knapsack_pro/adapters/spinach_adapter'
|
41
42
|
require_relative 'knapsack_pro/runners/base_runner'
|
42
43
|
require_relative 'knapsack_pro/runners/rspec_runner'
|
43
44
|
require_relative 'knapsack_pro/runners/cucumber_runner'
|
44
45
|
require_relative 'knapsack_pro/runners/minitest_runner'
|
46
|
+
require_relative 'knapsack_pro/runners/spinach_runner'
|
45
47
|
|
46
48
|
module KnapsackPro
|
47
49
|
class << self
|
@@ -46,7 +46,6 @@ module KnapsackPro
|
|
46
46
|
# $! is latest error message
|
47
47
|
latest_error = (latest_error || $!)
|
48
48
|
exit_status = latest_error.status if latest_error.is_a?(SystemExit)
|
49
|
-
#require 'pry'; binding.pry
|
50
49
|
# saving report makes API call which changes exit status
|
51
50
|
# from cucumber so we need to preserve cucumber exit status
|
52
51
|
KnapsackPro::Report.save
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module KnapsackPro
|
2
|
+
module Adapters
|
3
|
+
class SpinachAdapter < BaseAdapter
|
4
|
+
TEST_DIR_PATTERN = 'features/**{,/*/**}/*.feature'
|
5
|
+
|
6
|
+
def self.test_path(scenario)
|
7
|
+
scenario.feature.filename
|
8
|
+
end
|
9
|
+
|
10
|
+
def bind_time_tracker
|
11
|
+
::Spinach.hooks.before_scenario do |scenario_data, step_definitions|
|
12
|
+
KnapsackPro.tracker.current_test_path = KnapsackPro::Adapters::SpinachAdapter.test_path(scenario_data)
|
13
|
+
KnapsackPro.tracker.start_timer
|
14
|
+
end
|
15
|
+
|
16
|
+
::Spinach.hooks.after_scenario do
|
17
|
+
KnapsackPro.tracker.stop_timer
|
18
|
+
end
|
19
|
+
|
20
|
+
::Spinach.hooks.after_run do
|
21
|
+
KnapsackPro.logger.info(KnapsackPro::Presenter.global_time)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def bind_save_report(latest_error = nil)
|
26
|
+
::Spinach.hooks.after_run do
|
27
|
+
KnapsackPro::Report.save
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module KnapsackPro
|
2
|
+
module Runners
|
3
|
+
class SpinachRunner < BaseRunner
|
4
|
+
def self.run(args)
|
5
|
+
ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN'] = KnapsackPro::Config::Env.test_suite_token_spinach
|
6
|
+
|
7
|
+
runner = new(KnapsackPro::Adapters::SpinachAdapter)
|
8
|
+
|
9
|
+
cmd = %Q[KNAPSACK_PRO_RECORDING_ENABLED=true KNAPSACK_PRO_TEST_SUITE_TOKEN=#{ENV['KNAPSACK_PRO_TEST_SUITE_TOKEN']} bundle exec spinach #{args} -- #{runner.stringify_test_file_paths}]
|
10
|
+
|
11
|
+
Kernel.system(cmd)
|
12
|
+
Kernel.exit($?.exitstatus) unless $?.exitstatus.zero?
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -0,0 +1,61 @@
|
|
1
|
+
describe KnapsackPro::Adapters::SpinachAdapter do
|
2
|
+
it do
|
3
|
+
expect(described_class::TEST_DIR_PATTERN).to eq 'features/**{,/*/**}/*.feature'
|
4
|
+
end
|
5
|
+
|
6
|
+
context do
|
7
|
+
it_behaves_like 'adapter'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe '.test_path' do
|
11
|
+
let(:scenario_data) do
|
12
|
+
double(feature: double(filename: 'a.feature'))
|
13
|
+
end
|
14
|
+
|
15
|
+
subject { described_class.test_path(scenario_data) }
|
16
|
+
|
17
|
+
it { should eql 'a.feature' }
|
18
|
+
end
|
19
|
+
|
20
|
+
describe 'bind methods' do
|
21
|
+
describe '#bind_time_tracker' do
|
22
|
+
let(:block) { double }
|
23
|
+
let(:tracker) { instance_double(KnapsackPro::Tracker) }
|
24
|
+
let(:logger) { instance_double(Logger) }
|
25
|
+
let(:global_time) { 'Global time: 01m 05s' }
|
26
|
+
let(:test_path) { 'features/a.feature' }
|
27
|
+
let(:scenario_data) do
|
28
|
+
double(feature: double(filename: test_path))
|
29
|
+
end
|
30
|
+
|
31
|
+
it do
|
32
|
+
expect(Spinach.hooks).to receive(:before_scenario).and_yield(scenario_data, nil)
|
33
|
+
|
34
|
+
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
35
|
+
expect(described_class).to receive(:test_path).with(scenario_data).and_return(test_path)
|
36
|
+
expect(tracker).to receive(:current_test_path=).with(test_path)
|
37
|
+
expect(tracker).to receive(:start_timer)
|
38
|
+
|
39
|
+
expect(Spinach.hooks).to receive(:after_scenario).and_yield
|
40
|
+
expect(tracker).to receive(:stop_timer)
|
41
|
+
|
42
|
+
expect(Spinach.hooks).to receive(:after_run).and_yield
|
43
|
+
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
44
|
+
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
45
|
+
expect(logger).to receive(:info).with(global_time)
|
46
|
+
|
47
|
+
subject.bind_time_tracker
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
describe '#bind_save_report' do
|
52
|
+
it do
|
53
|
+
expect(Spinach.hooks).to receive(:after_run).and_yield
|
54
|
+
|
55
|
+
expect(KnapsackPro::Report).to receive(:save)
|
56
|
+
|
57
|
+
subject.bind_save_report
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -277,6 +277,20 @@ describe KnapsackPro::Config::Env do
|
|
277
277
|
end
|
278
278
|
end
|
279
279
|
|
280
|
+
describe '.test_suite_token_spinach' do
|
281
|
+
subject { described_class.test_suite_token_spinach }
|
282
|
+
|
283
|
+
context 'when ENV exists' do
|
284
|
+
let(:test_suite_token_spinach) { 'spinach-token' }
|
285
|
+
before { stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH' => test_suite_token_spinach }) }
|
286
|
+
it { should eq test_suite_token_spinach }
|
287
|
+
end
|
288
|
+
|
289
|
+
context "when ENV doesn't exist" do
|
290
|
+
it { should be_nil }
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
280
294
|
describe '.mode' do
|
281
295
|
subject { described_class.mode }
|
282
296
|
|
@@ -0,0 +1,47 @@
|
|
1
|
+
describe KnapsackPro::Runners::SpinachRunner do
|
2
|
+
subject { described_class.new(KnapsackPro::Adapters::SpinachAdapter) }
|
3
|
+
|
4
|
+
it { should be_kind_of KnapsackPro::Runners::BaseRunner }
|
5
|
+
|
6
|
+
describe '.run' do
|
7
|
+
let(:args) { '--custom-arg' }
|
8
|
+
|
9
|
+
after { described_class.run(args) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
stub_const("ENV", { 'KNAPSACK_PRO_TEST_SUITE_TOKEN_SPINACH' => 'spinach-token' })
|
13
|
+
|
14
|
+
stringify_test_file_paths = 'features/a.feature features/b.feature'
|
15
|
+
runner = instance_double(described_class,
|
16
|
+
stringify_test_file_paths: stringify_test_file_paths)
|
17
|
+
expect(described_class).to receive(:new)
|
18
|
+
.with(KnapsackPro::Adapters::SpinachAdapter).and_return(runner)
|
19
|
+
|
20
|
+
expect(Kernel).to receive(:system).with('KNAPSACK_PRO_RECORDING_ENABLED=true KNAPSACK_PRO_TEST_SUITE_TOKEN=spinach-token bundle exec spinach --custom-arg -- features/a.feature features/b.feature')
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when command exit with success code' do
|
24
|
+
let(:exitstatus) { 0 }
|
25
|
+
|
26
|
+
before do
|
27
|
+
expect($?).to receive(:exitstatus).and_return(exitstatus)
|
28
|
+
end
|
29
|
+
|
30
|
+
it do
|
31
|
+
expect(Kernel).not_to receive(:exit)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'when command exit without success code' do
|
36
|
+
let(:exitstatus) { 1 }
|
37
|
+
|
38
|
+
before do
|
39
|
+
expect($?).to receive(:exitstatus).twice.and_return(exitstatus)
|
40
|
+
end
|
41
|
+
|
42
|
+
it do
|
43
|
+
expect(Kernel).to receive(:exit).with(exitstatus)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack_pro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.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-
|
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
|
@@ -194,6 +208,7 @@ files:
|
|
194
208
|
- lib/knapsack_pro/adapters/cucumber_adapter.rb
|
195
209
|
- lib/knapsack_pro/adapters/minitest_adapter.rb
|
196
210
|
- lib/knapsack_pro/adapters/rspec_adapter.rb
|
211
|
+
- lib/knapsack_pro/adapters/spinach_adapter.rb
|
197
212
|
- lib/knapsack_pro/allocator.rb
|
198
213
|
- lib/knapsack_pro/allocator_builder.rb
|
199
214
|
- lib/knapsack_pro/client/api/action.rb
|
@@ -219,6 +234,7 @@ files:
|
|
219
234
|
- lib/knapsack_pro/runners/cucumber_runner.rb
|
220
235
|
- lib/knapsack_pro/runners/minitest_runner.rb
|
221
236
|
- lib/knapsack_pro/runners/rspec_runner.rb
|
237
|
+
- lib/knapsack_pro/runners/spinach_runner.rb
|
222
238
|
- lib/knapsack_pro/task_loader.rb
|
223
239
|
- lib/knapsack_pro/test_file_cleaner.rb
|
224
240
|
- lib/knapsack_pro/test_file_finder.rb
|
@@ -230,6 +246,7 @@ files:
|
|
230
246
|
- lib/tasks/cucumber.rake
|
231
247
|
- lib/tasks/minitest.rake
|
232
248
|
- lib/tasks/rspec.rake
|
249
|
+
- lib/tasks/spinach.rake
|
233
250
|
- spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/invalid_test_suite_token.yml
|
234
251
|
- spec/fixtures/vcr_cassettes/api/v1/build_distributions/subset/success.yml
|
235
252
|
- spec/fixtures/vcr_cassettes/api/v1/build_subsets/create/invalid_test_suite_token.yml
|
@@ -240,6 +257,7 @@ files:
|
|
240
257
|
- spec/knapsack_pro/adapters/cucumber_adapter_spec.rb
|
241
258
|
- spec/knapsack_pro/adapters/minitest_adapter_spec.rb
|
242
259
|
- spec/knapsack_pro/adapters/rspec_adapter_spec.rb
|
260
|
+
- spec/knapsack_pro/adapters/spinach_adapter_spec.rb
|
243
261
|
- spec/knapsack_pro/allocator_builder_spec.rb
|
244
262
|
- spec/knapsack_pro/allocator_spec.rb
|
245
263
|
- spec/knapsack_pro/client/api/action_spec.rb
|
@@ -265,6 +283,7 @@ files:
|
|
265
283
|
- spec/knapsack_pro/runners/cucumber_runner_spec.rb
|
266
284
|
- spec/knapsack_pro/runners/minitest_runner_spec.rb
|
267
285
|
- spec/knapsack_pro/runners/rspec_runner_spec.rb
|
286
|
+
- spec/knapsack_pro/runners/spinach_runner_spec.rb
|
268
287
|
- spec/knapsack_pro/task_loader_spec.rb
|
269
288
|
- spec/knapsack_pro/test_file_cleaner_spec.rb
|
270
289
|
- spec/knapsack_pro/test_file_finder_spec.rb
|
@@ -320,6 +339,7 @@ test_files:
|
|
320
339
|
- spec/knapsack_pro/adapters/cucumber_adapter_spec.rb
|
321
340
|
- spec/knapsack_pro/adapters/minitest_adapter_spec.rb
|
322
341
|
- spec/knapsack_pro/adapters/rspec_adapter_spec.rb
|
342
|
+
- spec/knapsack_pro/adapters/spinach_adapter_spec.rb
|
323
343
|
- spec/knapsack_pro/allocator_builder_spec.rb
|
324
344
|
- spec/knapsack_pro/allocator_spec.rb
|
325
345
|
- spec/knapsack_pro/client/api/action_spec.rb
|
@@ -345,6 +365,7 @@ test_files:
|
|
345
365
|
- spec/knapsack_pro/runners/cucumber_runner_spec.rb
|
346
366
|
- spec/knapsack_pro/runners/minitest_runner_spec.rb
|
347
367
|
- spec/knapsack_pro/runners/rspec_runner_spec.rb
|
368
|
+
- spec/knapsack_pro/runners/spinach_runner_spec.rb
|
348
369
|
- spec/knapsack_pro/task_loader_spec.rb
|
349
370
|
- spec/knapsack_pro/test_file_cleaner_spec.rb
|
350
371
|
- spec/knapsack_pro/test_file_finder_spec.rb
|