knapsack_pro 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 91df3d774c26fdede31c284eca7c6f42d131ee06
4
- data.tar.gz: 055e753fa5d44ec2b169f0fc25e58fe82bb83b1b
3
+ metadata.gz: 9ea0d407156f643fed5db989df1a3b7c0d42abf3
4
+ data.tar.gz: 817cccd4845d5910117e651e24e5a47cbeae9965
5
5
  SHA512:
6
- metadata.gz: f940e5476c14416b157571136c8a7df7e5c95144b50f095a6a3e19e854d541f87fabaaec4bdf78defd4a48cea96eaa162026e59aa463e5a9a757227d505b459d
7
- data.tar.gz: 0da62860473be46822d3ba3bbce637c2b98ff620cd0b0fee463dce414c4fa9c0fdce81c8b1ac25c6e91a495daa43115d931f028e3c6d3413d8c603a475d68a3b
6
+ metadata.gz: c437b67fa33dcd7d14bfd63608d1e9dd5181ed75de43f1f11439839c9604af943c4592b67ef84eb2ea96aae08c926b588200f38504f34053de072c7665f92ed4
7
+ data.tar.gz: 3d2fb45f5a0d7ac0ac35cb1100c357f10b09f128c27612b2cfa91b4d0680cd8c662f1779a5af33804a38f9c0e128bf01bb2e58fd312f2df8942d8b0953db45ba
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 0.6.0
6
+
7
+ * Add support for Cucumber 2
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v0.5.0...v0.6.0
10
+
5
11
  ### 0.5.0
6
12
 
7
13
  * Remove active support dependency so knapsack_pro gem can be used with rails 2.
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?__ Please fill the [sign up form](https://docs.google.com/forms/d/1S8b5I-W2wr4_8C0tKu9AiW9y_5vq3SW9j2MMUql-hjE/viewform?c=0&w=1&hl=en).
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 on how many CI nodes you are running tests.
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 are using one of supported CI providers then instead of above steps you should [take a look on this](#supported-ci-providers).
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
- ## Extra configuration for CI server
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
- ### Info about ENV variables
210
+ ### Repository adapter (How to set up 3 of 3)
203
211
 
204
- By default knapsack_pro gem [supports a few CI providers](#supported-ci-providers) so you don't need to set environment variables.
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
- `KNAPSACK_PRO_CI_NODE_TOTAL` - total number CI nodes you have.
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
- `KNAPSACK_PRO_CI_NODE_INDEX` - index of current CI node starts from 0. Second CI node should have `KNAPSACK_PRO_CI_NODE_INDEX=1`.
216
+ `KNAPSACK_PRO_BRANCH` - It's branch name. You run tests on this branch.
210
217
 
211
- #### Repository adapter
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
- ##### When you set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER=git` (optional)
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
- ##### When you NOT set global variable `KNAPSACK_PRO_REPOSITORY_ADAPTER` (default)
228
+ ## Extra configuration for CI server
220
229
 
221
- 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.
230
+ ### Info about ENV variables
222
231
 
223
- `KNAPSACK_PRO_BRANCH` - It's branch name. You run tests on this branch.
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
- `KNAPSACK_PRO_COMMIT_HASH` - Commit hash. You run tests for this commit.
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(scenario_or_outline_table)
7
- if scenario_or_outline_table.respond_to?(:file)
8
- scenario_or_outline_table.file
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.scenario_outline.file
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 |scenario_or_outline_table, block|
16
- KnapsackPro.tracker.current_test_path = KnapsackPro::Adapters::CucumberAdapter.test_path(scenario_or_outline_table)
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
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -13,48 +13,91 @@ describe KnapsackPro::Adapters::CucumberAdapter do
13
13
  end
14
14
 
15
15
  describe '.test_path' do
16
- subject { described_class.test_path(scenario_or_outline_table) }
16
+ context 'when Cucumber version 1' do
17
+ subject { described_class.test_path(scenario_or_outline_table) }
17
18
 
18
- context 'when scenario' do
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
- it { should eql scenario_file }
23
- end
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
- context 'when scenario outline' do
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
- it { should eql scenario_outline_file }
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
- it do
45
- expect(subject).to receive(:Around).and_yield(scenario, block)
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
- expect(::Kernel).to receive(:at_exit).and_yield
53
- expect(KnapsackPro::Presenter).to receive(:global_time).and_return(global_time)
54
- expect(KnapsackPro).to receive(:logger).and_return(logger)
55
- expect(logger).to receive(:info).with(global_time)
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
- subject.bind_time_tracker
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.5.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: 2015-12-03 00:00:00.000000000 Z
11
+ date: 2016-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake