knapsack_pro 0.5.0 → 0.6.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 +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +35 -23
- data/lib/knapsack_pro/adapters/cucumber_adapter.rb +12 -6
- data/lib/knapsack_pro/version.rb +1 -1
- data/spec/knapsack_pro/adapters/cucumber_adapter_spec.rb +67 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ea0d407156f643fed5db989df1a3b7c0d42abf3
|
4
|
+
data.tar.gz: 817cccd4845d5910117e651e24e5a47cbeae9965
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c437b67fa33dcd7d14bfd63608d1e9dd5181ed75de43f1f11439839c9604af943c4592b67ef84eb2ea96aae08c926b588200f38504f34053de072c7665f92ed4
|
7
|
+
data.tar.gz: 3d2fb45f5a0d7ac0ac35cb1100c357f10b09f128c27612b2cfa91b4d0680cd8c662f1779a5af33804a38f9c0e128bf01bb2e58fd312f2df8942d8b0953db45ba
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -14,13 +14,13 @@ The knapsack_pro gem supports:
|
|
14
14
|
* [Minitest](http://docs.seattlerb.org/minitest/)
|
15
15
|
* [Turnip](https://github.com/jnicklas/turnip)
|
16
16
|
|
17
|
-
__Would you like to try knapsack_pro gem?__
|
17
|
+
__Would you like to try knapsack_pro gem?__ You can [get API token here](http://knapsackpro.com).
|
18
18
|
|
19
19
|
# How knapsack_pro works?
|
20
20
|
|
21
21
|
## Basics
|
22
22
|
|
23
|
-
Basically it will track your branches, commits and
|
23
|
+
Basically it will track your branches, commits and for how many CI nodes you are running tests.
|
24
24
|
Collected data about test time execution will be send to API where test suite split is done.
|
25
25
|
Next time when you will run tests you will get proper test files for each CI node in order to achieve comparable time execution on each CI node.
|
26
26
|
|
@@ -47,19 +47,19 @@ For instance when you will run tests with rake knapsack_pro:rspec then:
|
|
47
47
|
- [Update gem](#update-gem)
|
48
48
|
- [Installation](#installation)
|
49
49
|
- [How to set up](#how-to-set-up)
|
50
|
-
- [Usage](#usage)
|
50
|
+
- [Usage (How to set up 1 of 3)](#usage-how-to-set-up-1-of-3)
|
51
51
|
- [Step for RSpec](#step-for-rspec)
|
52
52
|
- [Step for Cucumber](#step-for-cucumber)
|
53
53
|
- [Step for Minitest](#step-for-minitest)
|
54
54
|
- [Custom configuration](#custom-configuration)
|
55
|
-
- [Setup your CI server](#setup-your-ci-server)
|
55
|
+
- [Setup your CI server (How to set up 2 of 3)](#setup-your-ci-server-how-to-set-up-2-of-3)
|
56
56
|
- [Set API key token](#set-api-key-token)
|
57
57
|
- [Set knapsack_pro command to execute tests](#set-knapsack_pro-command-to-execute-tests)
|
58
|
+
- [Repository adapter (How to set up 3 of 3)](#repository-adapter-how-to-set-up-3-of-3)
|
59
|
+
- [When you NOT set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER` (default)](#when-you-not-set-global-variable-knapsack_pro_repository_adapter-default)
|
60
|
+
- [When you set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER=git` (required when CI provider is not supported)](#when-you-set-global-variable-knapsack_pro_repository_adaptergit-required-when-ci-provider-is-not-supported)
|
58
61
|
- [Extra configuration for CI server](#extra-configuration-for-ci-server)
|
59
62
|
- [Info about ENV variables](#info-about-env-variables)
|
60
|
-
- [Repository adapter](#repository-adapter)
|
61
|
-
- [When you set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER=git` (optional)](#when-you-set-global-variable-knapsack_pro_repository_adaptergit-optional)
|
62
|
-
- [When you NOT set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER` (default)](#when-you-not-set-global-variable-knapsack_pro_repository_adapter-default)
|
63
63
|
- [Environment variables for debugging gem](#environment-variables-for-debugging-gem)
|
64
64
|
- [Passing arguments to rake task](#passing-arguments-to-rake-task)
|
65
65
|
- [Passing arguments to rspec](#passing-arguments-to-rspec)
|
@@ -103,11 +103,19 @@ Add this line at the bottom of `Rakefile` if your project has it:
|
|
103
103
|
KnapsackPro.load_tasks if defined?(KnapsackPro)
|
104
104
|
```
|
105
105
|
|
106
|
+
If you are using [VCR gem](https://github.com/vcr/vcr) then add Knapsack Pro API subdomain to [ignore hosts](https://www.relishapp.com/vcr/vcr/v/2-9-3/docs/configuration/ignore-request):
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
VCR.configure do |config|
|
110
|
+
config.ignore_hosts 'localhost', '127.0.0.1', '0.0.0.0', 'api.knapsackpro.com'
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
106
114
|
## How to set up
|
107
115
|
|
108
|
-
### Usage
|
116
|
+
### Usage (How to set up 1 of 3)
|
109
117
|
|
110
|
-
You can find here example of rails app with already configured knapsack_pro.
|
118
|
+
__Tip:__ You can find here example of rails app with already configured knapsack_pro.
|
111
119
|
|
112
120
|
https://github.com/KnapsackPro/rails-app-with-knapsack_pro
|
113
121
|
|
@@ -159,7 +167,7 @@ KnapsackPro.logger = Logger.new(STDOUT)
|
|
159
167
|
KnapsackPro.logger.level = Logger::INFO
|
160
168
|
```
|
161
169
|
|
162
|
-
### Setup your CI server
|
170
|
+
### Setup your CI server (How to set up 2 of 3)
|
163
171
|
|
164
172
|
#### Set API key token
|
165
173
|
|
@@ -195,34 +203,38 @@ You can add `KNAPSACK_PRO_TEST_FILE_PATTERN` if your tests are not in default di
|
|
195
203
|
# Step for Minitest
|
196
204
|
$ 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
|
197
205
|
|
198
|
-
__Tip:__ If you
|
206
|
+
__Tip:__ If you use one of supported CI providers then instead of above steps you should [take a look on this](#supported-ci-providers).
|
199
207
|
|
200
|
-
|
208
|
+
__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).
|
201
209
|
|
202
|
-
###
|
210
|
+
### Repository adapter (How to set up 3 of 3)
|
203
211
|
|
204
|
-
|
205
|
-
In case when you use other CI provider for instance [Jenkins](https://jenkins-ci.org) etc then you need to provide configuration via below environment variables.
|
212
|
+
#### When you NOT set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER` (default)
|
206
213
|
|
207
|
-
`
|
214
|
+
By default `KNAPSACK_PRO_REPOSITORY_ADAPTER` variable has no value so knapsack_pro will try to get info about branch name and commit hash from [supported CI](#supported-ci-providers) (CI providers have branch, commit, project directory stored as environment variables). In case when you use other CI provider like Jenkins then please set below variables on your own.
|
208
215
|
|
209
|
-
`
|
216
|
+
`KNAPSACK_PRO_BRANCH` - It's branch name. You run tests on this branch.
|
210
217
|
|
211
|
-
|
218
|
+
`KNAPSACK_PRO_COMMIT_HASH` - Commit hash. You run tests for this commit.
|
219
|
+
|
220
|
+
You can also use git as repository adapter to determine branch and commit hash, please see below section.
|
212
221
|
|
213
|
-
|
222
|
+
#### When you set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER=git` (required when CI provider is not supported)
|
214
223
|
|
215
224
|
`KNAPSACK_PRO_REPOSITORY_ADAPTER` - When it has value `git` then your local version of git on CI server will be used to get info about branch name and commit hash. You need to set also `KNAPSACK_PRO_PROJECT_DIR` with project directory path.
|
216
225
|
|
217
226
|
`KNAPSACK_PRO_PROJECT_DIR` - Path to the project on CI node for instance `/home/ubuntu/my-app-repository`. It should be main directory of your repository.
|
218
227
|
|
219
|
-
|
228
|
+
## Extra configuration for CI server
|
220
229
|
|
221
|
-
|
230
|
+
### Info about ENV variables
|
222
231
|
|
223
|
-
|
232
|
+
By default knapsack_pro gem [supports a few CI providers](#supported-ci-providers) so you don't need to set some environment variables.
|
233
|
+
In case when you use other CI provider for instance [Jenkins](https://jenkins-ci.org) etc then you need to provide configuration via below environment variables.
|
224
234
|
|
225
|
-
`
|
235
|
+
`KNAPSACK_PRO_CI_NODE_TOTAL` - total number CI nodes you have.
|
236
|
+
|
237
|
+
`KNAPSACK_PRO_CI_NODE_INDEX` - index of current CI node starts from 0. Second CI node should have `KNAPSACK_PRO_CI_NODE_INDEX=1`.
|
226
238
|
|
227
239
|
#### Environment variables for debugging gem
|
228
240
|
|
@@ -3,17 +3,23 @@ module KnapsackPro
|
|
3
3
|
class CucumberAdapter < BaseAdapter
|
4
4
|
TEST_DIR_PATTERN = 'features/**{,/*/**}/*.feature'
|
5
5
|
|
6
|
-
def self.test_path(
|
7
|
-
if
|
8
|
-
|
6
|
+
def self.test_path(object)
|
7
|
+
if Cucumber::VERSION.to_i >= 2
|
8
|
+
test_case = object
|
9
|
+
test_case.location.file
|
9
10
|
else
|
10
|
-
scenario_or_outline_table
|
11
|
+
scenario_or_outline_table = object
|
12
|
+
if scenario_or_outline_table.respond_to?(:file)
|
13
|
+
scenario_or_outline_table.file
|
14
|
+
else
|
15
|
+
scenario_or_outline_table.scenario_outline.file
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
13
19
|
|
14
20
|
def bind_time_tracker
|
15
|
-
Around do |
|
16
|
-
KnapsackPro.tracker.current_test_path = KnapsackPro::Adapters::CucumberAdapter.test_path(
|
21
|
+
Around do |object, block|
|
22
|
+
KnapsackPro.tracker.current_test_path = KnapsackPro::Adapters::CucumberAdapter.test_path(object)
|
17
23
|
KnapsackPro.tracker.start_timer
|
18
24
|
block.call
|
19
25
|
KnapsackPro.tracker.stop_timer
|
data/lib/knapsack_pro/version.rb
CHANGED
@@ -13,48 +13,91 @@ describe KnapsackPro::Adapters::CucumberAdapter do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
describe '.test_path' do
|
16
|
-
|
16
|
+
context 'when Cucumber version 1' do
|
17
|
+
subject { described_class.test_path(scenario_or_outline_table) }
|
17
18
|
|
18
|
-
|
19
|
-
let(:scenario_file) { 'features/scenario.feature' }
|
20
|
-
let(:scenario_or_outline_table) { double(file: scenario_file) }
|
19
|
+
before { stub_const('Cucumber::VERSION', '1') }
|
21
20
|
|
22
|
-
|
23
|
-
|
21
|
+
context 'when scenario' do
|
22
|
+
let(:scenario_file) { 'features/scenario.feature' }
|
23
|
+
let(:scenario_or_outline_table) { double(file: scenario_file) }
|
24
24
|
|
25
|
-
|
26
|
-
let(:scenario_outline_file) { 'features/scenario_outline.feature' }
|
27
|
-
let(:scenario_or_outline_table) do
|
28
|
-
double(scenario_outline: double(file: scenario_outline_file))
|
25
|
+
it { should eql scenario_file }
|
29
26
|
end
|
30
27
|
|
31
|
-
|
28
|
+
context 'when scenario outline' do
|
29
|
+
let(:scenario_outline_file) { 'features/scenario_outline.feature' }
|
30
|
+
let(:scenario_or_outline_table) do
|
31
|
+
double(scenario_outline: double(file: scenario_outline_file))
|
32
|
+
end
|
33
|
+
|
34
|
+
it { should eql scenario_outline_file }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when Cucumber version 2' do
|
39
|
+
let(:file) { 'features/a.feature' }
|
40
|
+
let(:test_case) { double(location: double(file: file)) } # Cucumber 2
|
41
|
+
|
42
|
+
subject { described_class.test_path(test_case) }
|
43
|
+
|
44
|
+
before { stub_const('Cucumber::VERSION', '2') }
|
45
|
+
|
46
|
+
it { should eql file }
|
32
47
|
end
|
33
48
|
end
|
34
49
|
|
35
50
|
describe 'bind methods' do
|
36
51
|
describe '#bind_time_tracker' do
|
37
52
|
let(:file) { 'features/a.feature' }
|
38
|
-
let(:scenario) { double(file: file) }
|
39
53
|
let(:block) { double }
|
40
54
|
let(:tracker) { instance_double(KnapsackPro::Tracker) }
|
41
55
|
let(:logger) { instance_double(Logger) }
|
42
56
|
let(:global_time) { 'Global time: 01m 05s' }
|
43
57
|
|
44
|
-
|
45
|
-
|
46
|
-
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
47
|
-
expect(tracker).to receive(:current_test_path=).with(file)
|
48
|
-
expect(tracker).to receive(:start_timer)
|
49
|
-
expect(block).to receive(:call)
|
50
|
-
expect(tracker).to receive(:stop_timer)
|
58
|
+
context 'when Cucumber version 1' do
|
59
|
+
let(:scenario) { double(file: file) }
|
51
60
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
61
|
+
before { stub_const('Cucumber::VERSION', '1.3.20') }
|
62
|
+
|
63
|
+
it do
|
64
|
+
expect(subject).to receive(:Around).and_yield(scenario, block)
|
65
|
+
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
66
|
+
expect(tracker).to receive(:current_test_path=).with(file)
|
67
|
+
expect(tracker).to receive(:start_timer)
|
68
|
+
expect(block).to receive(:call)
|
69
|
+
expect(tracker).to receive(:stop_timer)
|
70
|
+
|
71
|
+
expect(::Kernel).to receive(:at_exit).and_yield
|
72
|
+
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
73
|
+
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
74
|
+
expect(logger).to receive(:info).with(global_time)
|
75
|
+
|
76
|
+
subject.bind_time_tracker
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when Cucumber version 2' do
|
81
|
+
let(:test_case) { double(location: double(file: file)) }
|
82
|
+
|
83
|
+
# complex version name to ensure we can catch that too
|
84
|
+
before { stub_const('Cucumber::VERSION', '2.0.0.rc.5') }
|
85
|
+
|
86
|
+
it do
|
87
|
+
expect(subject).to receive(:Around).and_yield(test_case, block)
|
88
|
+
allow(KnapsackPro).to receive(:tracker).and_return(tracker)
|
89
|
+
expect(tracker).to receive(:current_test_path=).with(file)
|
90
|
+
expect(tracker).to receive(:start_timer)
|
91
|
+
expect(block).to receive(:call)
|
92
|
+
expect(tracker).to receive(:stop_timer)
|
93
|
+
|
94
|
+
expect(::Kernel).to receive(:at_exit).and_yield
|
95
|
+
expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
|
96
|
+
expect(KnapsackPro).to receive(:logger).and_return(logger)
|
97
|
+
expect(logger).to receive(:info).with(global_time)
|
56
98
|
|
57
|
-
|
99
|
+
subject.bind_time_tracker
|
100
|
+
end
|
58
101
|
end
|
59
102
|
end
|
60
103
|
|
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.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|