knapsack 1.3.0 → 1.3.1

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: 4dd54024c966f2cff5fab7934d6aa1c255297cdc
4
- data.tar.gz: f797b4b30cea8498d98c0dc89af3a41426979e62
3
+ metadata.gz: b3792c60ac290034623012572800ec6f0785dca5
4
+ data.tar.gz: e5a54f8845f9461dabab4b6a5c4a58852c23b624
5
5
  SHA512:
6
- metadata.gz: 9bf63ca1824864e3148af5244ac357055320f22daf1180768b1dc922a058a05265e9d3b3f70c2ea60d4f23e92349dacb2f49cb9cc03f23cf7b633500202c729a
7
- data.tar.gz: 2a88cb3402e1791a3e03c00af64a0872d099945c82f90c6a0ac8894c23a79a40062ea57984b6b2cba1ce57d17d742136d84db48b5b90d7b6786c9c9001e53985
6
+ metadata.gz: d32a7b3290080f0e9fd3d33b8b9be720118773fd64aea1ddcd9f680894cc53cf33ef2b760772984b28698f5de7d554ec3af31fb78f6ea898b20e324b8a2f95cc
7
+ data.tar.gz: f04e7db28903d5aed5a88beed25db026c9fcfc03da9f769bde58c32bc797962073a28e7b61094e1423eadde5515d11f9a9ce2a62ab01a5bbd0bf72073127f491
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 1.3.1
6
+
7
+ * Treat KNAPSACK_GENERATE_REPORT=false as generate_report -> false
8
+
9
+ https://github.com/ArturT/knapsack/pull/22
10
+
11
+ https://github.com/ArturT/knapsack/compare/v1.3.0...v1.3.1
12
+
5
13
  ### 1.3.0
6
14
 
7
15
  * Add knapsack binary
data/README.md CHANGED
@@ -179,6 +179,10 @@ Commit generated report `knapsack_rspec_report.json`, `knapsack_cucumber_report.
179
179
 
180
180
  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.
181
181
 
182
+ `KNAPSACK_GENERATE_REPORT` is truthy when `"true"` or `0`. All other values are falsy, though
183
+ [`"false"`, and `1` are semantically
184
+ preferrable](https://en.wikipedia.org/wiki/True_and_false_(commands)).
185
+
182
186
  #### Adding or removing tests
183
187
 
184
188
  There is no need to regenerate the report every time when you add/remove test file. If you remove a test file then Knapsack will ignore its entry in report. In case when you add a new file and it doesn't already exist in report, the test file will be assigned to one of the CI node.
@@ -11,7 +11,7 @@ module Knapsack
11
11
  end
12
12
 
13
13
  def generate_report
14
- ENV['KNAPSACK_GENERATE_REPORT'] || false
14
+ !!(ENV['KNAPSACK_GENERATE_REPORT'] =~ /\Atrue|0\z/i)
15
15
  end
16
16
  end
17
17
  end
@@ -80,8 +80,6 @@ module Knapsack
80
80
  })
81
81
  end
82
82
 
83
- private
84
-
85
83
  def now_without_mock_time
86
84
  if defined?(Timecop)
87
85
  Time.now_without_mock_time
@@ -1,3 +1,3 @@
1
1
  module Knapsack
2
- VERSION = '1.3.0'
2
+ VERSION = '1.3.1'
3
3
  end
@@ -13,8 +13,35 @@ describe Knapsack::Config::Tracker do
13
13
  subject { described_class.generate_report }
14
14
 
15
15
  context 'when ENV exists' do
16
- before { stub_const("ENV", { 'KNAPSACK_GENERATE_REPORT' => true }) }
17
- it { should be true }
16
+ it 'should be true when KNAPSACK_GENERATE_REPORT=true' do
17
+ with_env 'KNAPSACK_GENERATE_REPORT' => 'true' do
18
+ expect(subject).to eq(true)
19
+ end
20
+ end
21
+
22
+ it 'should be true when KNAPSACK_GENERATE_REPORT=0' do
23
+ with_env 'KNAPSACK_GENERATE_REPORT' => '0' do
24
+ expect(subject).to eq(true)
25
+ end
26
+ end
27
+
28
+ it 'should be false when KNAPSACK_GENERATE_REPORT is ""' do
29
+ with_env 'KNAPSACK_GENERATE_REPORT' => '' do
30
+ expect(subject).to eq(false)
31
+ end
32
+ end
33
+
34
+ it 'should be false when KNAPSACK_GENERATE_REPORT is "false"' do
35
+ with_env 'KNAPSACK_GENERATE_REPORT' => 'false' do
36
+ expect(subject).to eq(false)
37
+ end
38
+ end
39
+
40
+ it 'should be false when KNAPSACK_GENERATE_REPORT is not "true" or "0"' do
41
+ with_env 'KNAPSACK_GENERATE_REPORT' => '1' do
42
+ expect(subject).to eq(false)
43
+ end
44
+ end
18
45
  end
19
46
 
20
47
  context "when ENV doesn't exist" do
@@ -9,12 +9,8 @@ describe Knapsack::Tracker do
9
9
  it_behaves_like 'default trakcer attributes'
10
10
 
11
11
  describe '#config' do
12
- before do
13
- stub_const("ENV", { 'KNAPSACK_GENERATE_REPORT' => generate_report })
14
- end
15
-
16
12
  context 'when passed options' do
17
- let(:generate_report) { true }
13
+ let(:generate_report) { 'true' }
18
14
  let(:opts) do
19
15
  {
20
16
  enable_time_offset_warning: false,
@@ -23,12 +19,14 @@ describe Knapsack::Tracker do
23
19
  end
24
20
 
25
21
  it do
26
- expect(tracker.config(opts)).to eql({
27
- enable_time_offset_warning: false,
28
- time_offset_in_seconds: 30,
29
- generate_report: true,
30
- fake: true
31
- })
22
+ with_env 'KNAPSACK_GENERATE_REPORT' => generate_report do
23
+ expect(tracker.config(opts)).to eql({
24
+ enable_time_offset_warning: false,
25
+ time_offset_in_seconds: 30,
26
+ generate_report: true,
27
+ fake: true
28
+ })
29
+ end
32
30
  end
33
31
  end
34
32
 
@@ -121,13 +119,6 @@ describe Knapsack::Tracker do
121
119
  let(:test_paths) { ['a_spec.rb', 'b_spec.rb'] }
122
120
  let(:delta) { 0.02 }
123
121
 
124
- shared_examples 'test tracker' do
125
- it { expect(tracker.global_time).to be_within(delta).of(0.3) }
126
- it { expect(tracker.test_files_with_time.keys.size).to eql 2 }
127
- it { expect(tracker.test_files_with_time['a_spec.rb']).to be_within(delta).of(0.1) }
128
- it { expect(tracker.test_files_with_time['b_spec.rb']).to be_within(delta).of(0.2) }
129
- end
130
-
131
122
  context 'without Timecop' do
132
123
  before do
133
124
  test_paths.each_with_index do |test_path, index|
@@ -0,0 +1,13 @@
1
+ module EnvHelper
2
+ def with_env(vars)
3
+ original = ENV.to_hash
4
+ vars.each { |k, v| ENV[k] = v }
5
+
6
+ begin
7
+ yield
8
+ ensure
9
+ ENV.replace(original)
10
+ end
11
+ end
12
+ end
13
+ RSpec.configuration.include EnvHelper
File without changes
File without changes
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.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-20 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -202,8 +202,9 @@ files:
202
202
  - spec/knapsack/tracker_spec.rb
203
203
  - spec/knapsack_spec.rb
204
204
  - spec/spec_helper.rb
205
- - spec/support/mocks/cucumber.rb
206
- - spec/support/mocks/minitest.rb
205
+ - spec/support/env_helper.rb
206
+ - spec/support/fakes/cucumber.rb
207
+ - spec/support/fakes/minitest.rb
207
208
  - spec/support/shared_examples/adapter.rb
208
209
  - spec_examples/fast/1_spec.rb
209
210
  - spec_examples/fast/2_spec.rb
@@ -243,7 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
243
244
  version: '0'
244
245
  requirements: []
245
246
  rubyforge_project:
246
- rubygems_version: 2.4.6
247
+ rubygems_version: 2.4.5.1
247
248
  signing_key:
248
249
  specification_version: 4
249
250
  summary: Knapsack splits tests across CI nodes and makes sure that tests will run
@@ -267,6 +268,7 @@ test_files:
267
268
  - spec/knapsack/tracker_spec.rb
268
269
  - spec/knapsack_spec.rb
269
270
  - spec/spec_helper.rb
270
- - spec/support/mocks/cucumber.rb
271
- - spec/support/mocks/minitest.rb
271
+ - spec/support/env_helper.rb
272
+ - spec/support/fakes/cucumber.rb
273
+ - spec/support/fakes/minitest.rb
272
274
  - spec/support/shared_examples/adapter.rb