knapsack 1.11.1 → 1.12.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: 9707d40522261fe0ed81e7e607b6fb46ed220703
4
- data.tar.gz: 6ffe1d23a0ab0e1b373989d9042469799fe339f9
3
+ metadata.gz: 2b142dc2475ee898b18ffea634b8f5619853685f
4
+ data.tar.gz: fe681da00799d3027ebcc1fafb4a2c3d9f118f1a
5
5
  SHA512:
6
- metadata.gz: 74bb98c429c28db932d514d8090042a55767834949fc1a219d69334a9582474f4a5e195020a03b8ada025815d62ab5cf7e74081a2dd8344d734e3ab43ec30354
7
- data.tar.gz: 2c640c9d958f91fab219f040b1a87b9e27664b999b23742b701c342b565d72abf7b4a0dcf86e22313e351ff35eae847916155702d5230bea00ffd94e66576083
6
+ metadata.gz: 6da196cf8d1436d5111ba796311d25d828c518b1d38ff8730c28bc9ce3901a5b3dedc1b1fb2180f7517fbb648503de97f001858baa627ef46577b641fb9edeb3
7
+ data.tar.gz: 40341a7b90caf3537994ec8f08748ba04dafa57b7f4fca6829c2dc7d498c9d84d975a42dc7d39cd462c09861c0a7240c651f3ab60073e8e0cd16095e56b1b0fe
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 1.12.0
6
+
7
+ * Add support for Minitest::SharedExamples
8
+
9
+ https://github.com/ArturT/knapsack/pull/46
10
+
11
+ https://github.com/ArturT/knapsack/compare/v1.11.1...v1.12.0
12
+
5
13
  ### 1.11.1
6
14
 
7
15
  * Require spinach in spec helper so tests will pass but don't require it in spinach adapter because it breaks for users who don't use spinach and they don't want to add it to their Gemfile
data/README.md CHANGED
@@ -75,6 +75,7 @@ Presentations about gem:
75
75
  - [What does "leftover specs" mean?](#what-does-leftover-specs-mean)
76
76
  - [How can I run tests from multiple directories?](#how-can-i-run-tests-from-multiple-directories)
77
77
  - [How to update existing knapsack report for a few test files?](#how-to-update-existing-knapsack-report-for-a-few-test-files)
78
+ - [How to run tests for particular CI node in your development environment](#how-to-run-tests-for-particular-ci-node-in-your-development-environment)
78
79
  - [Gem tests](#gem-tests)
79
80
  - [Spec](#spec)
80
81
  - [Spec examples](#spec-examples)
@@ -197,6 +198,8 @@ Generate time execution report for your test files. Run below command on one of
197
198
 
198
199
  # Step for Minitest
199
200
  $ KNAPSACK_GENERATE_REPORT=true bundle exec rake test
201
+ # If you use rails 5 then run this instead:
202
+ $ KNAPSACK_GENERATE_REPORT=true bundle exec rake knapsack:minitest
200
203
 
201
204
  # Step for Spinach
202
205
  $ KNAPSACK_GENERATE_REPORT=true bundle exec spinach
@@ -618,6 +621,17 @@ The test file pattern config option supports any glob pattern handled by [`Dir.g
618
621
 
619
622
  You may want to look at monkey patch in [this issue](https://github.com/ArturT/knapsack/issues/34). Take into account that there are some cons of this approach.
620
623
 
624
+ ### How to run tests for particular CI node in your development environment
625
+
626
+ In your development environment you can debug tests that were run on the particular CI node.
627
+ For instance to run subset of tests for the first CI node with specified seed you can do.
628
+
629
+ CI_NODE_TOTAL=2 \
630
+ CI_NODE_INDEX=0 \
631
+ bundle exec rake "knapsack:rspec[--seed 123]"
632
+
633
+ Above example is for RSpec. You can use respectively rake task name and token environment variable when you want to run tests for minitest, cucumber or spinach.
634
+
621
635
  ## Gem tests
622
636
 
623
637
  ### Spec
@@ -1,5 +1,6 @@
1
1
  {
2
- "test_examples/fast/unit_test.rb": 1.6192498207092285,
3
- "test_examples/slow/slow_test.rb": 2.515178918838501,
4
- "test_examples/fast/spec_test.rb": 0.0001010894775390625
2
+ "test_examples/slow/slow_test.rb": 2.5080618858337402,
3
+ "test_examples/fast/spec_test.rb": 0.00015115737915039062,
4
+ "test_examples/fast/shared_examples_test.rb": 0.616192102432251,
5
+ "test_examples/fast/unit_test.rb": 1.6202473640441895
5
6
  }
@@ -52,7 +52,12 @@ module Knapsack
52
52
  def self.test_path(obj)
53
53
  # Pick the first public method in the class itself, that starts with "test_"
54
54
  test_method_name = obj.public_methods(false).select{|m| m =~ /^test_/ }.first
55
- method_object = obj.method(test_method_name)
55
+ if test_method_name.nil?
56
+ # case for shared examples
57
+ method_object = obj.method(obj.location.sub(/.*?test_/, 'test_'))
58
+ else
59
+ method_object = obj.method(test_method_name)
60
+ end
56
61
  full_test_path = method_object.source_location.first
57
62
  parent_of_test_dir_regexp = Regexp.new("^#{@@parent_of_test_dir}")
58
63
  test_path = full_test_path.gsub(parent_of_test_dir_regexp, '.')
@@ -1,3 +1,3 @@
1
1
  module Knapsack
2
- VERSION = '1.11.1'
2
+ VERSION = '1.12.0'
3
3
  end
@@ -102,18 +102,6 @@ describe Knapsack::Adapters::MinitestAdapter do
102
102
  end
103
103
 
104
104
  describe '.test_path' do
105
- class FakeUserTest
106
- def test_user_age; end
107
-
108
- # method provided by Minitest
109
- # it returns test method name
110
- def name
111
- :test_user_age
112
- end
113
- end
114
-
115
- let(:obj) { FakeUserTest.new }
116
-
117
105
  subject { described_class.test_path(obj) }
118
106
 
119
107
  before do
@@ -122,6 +110,38 @@ describe Knapsack::Adapters::MinitestAdapter do
122
110
  described_class.class_variable_set(:@@parent_of_test_dir, parent_of_test_dir_regexp)
123
111
  end
124
112
 
125
- it { should eq './spec/knapsack/adapters/minitest_adapter_spec.rb' }
113
+ context 'when regular test' do
114
+ class FakeUserTest
115
+ def test_user_age; end
116
+
117
+ # method provided by Minitest
118
+ # it returns test method name
119
+ def name
120
+ :test_user_age
121
+ end
122
+ end
123
+
124
+ let(:obj) { FakeUserTest.new }
125
+
126
+ it { should eq './spec/knapsack/adapters/minitest_adapter_spec.rb' }
127
+ end
128
+
129
+ context 'when shared examples test' do
130
+ module FakeSharedExamples
131
+ def test_from_shared_example; end
132
+ end
133
+
134
+ class FakeSharedExamplesUserTest
135
+ include FakeSharedExamples
136
+
137
+ def location
138
+ "test that use FakeSharedExamples#test_from_shared_example"
139
+ end
140
+ end
141
+
142
+ let(:obj) { FakeSharedExamplesUserTest.new }
143
+
144
+ it { should eq './spec/knapsack/adapters/minitest_adapter_spec.rb' }
145
+ end
126
146
  end
127
147
  end
@@ -13,11 +13,10 @@ describe Knapsack::Adapters::SpinachAdapter do
13
13
 
14
14
  describe '#bind_time_tracker' do
15
15
  let(:tracker) { instance_double(Knapsack::Tracker) }
16
- let(:test_path) { 'spec/a_spec.rb' }
17
16
  let(:global_time) { 'Global time: 01m 05s' }
18
- let(:example_group) { double }
17
+ let(:test_path) { 'features/a.feature' }
19
18
  let(:scenario_data) do
20
- double(feature: double(filename: 'a_spec.rb'))
19
+ double(feature: double(filename: test_path))
21
20
  end
22
21
 
23
22
  it do
@@ -74,11 +73,11 @@ describe Knapsack::Adapters::SpinachAdapter do
74
73
 
75
74
  describe '.test_path' do
76
75
  let(:scenario_data) do
77
- double(feature: double(filename: 'a_spec.rb'))
76
+ double(feature: double(filename: 'a.feature'))
78
77
  end
79
78
 
80
79
  subject { described_class.test_path(scenario_data) }
81
80
 
82
- it { should eql 'a_spec.rb' }
81
+ it { should eql 'a.feature' }
83
82
  end
84
83
  end
@@ -0,0 +1,30 @@
1
+ require 'test_helper'
2
+ require 'minitest/spec'
3
+
4
+ class Minitest::SharedExamples < Module
5
+ include Minitest::Spec::DSL
6
+ end
7
+
8
+ SharedExampleSpec = Minitest::SharedExamples.new do
9
+ def setup
10
+ sleep 0.1
11
+ end
12
+
13
+ def test_mal
14
+ sleep 0.1
15
+ assert_equal 4, 2 * 2
16
+ end
17
+
18
+ def test_no_way
19
+ sleep 0.2
20
+ refute_match(/^no/i, 'yes')
21
+ end
22
+
23
+ def test_that_will_be_skipped
24
+ skip 'test this later'
25
+ end
26
+ end
27
+
28
+ describe "test that use SharedExamples" do
29
+ include SharedExampleSpec
30
+ end
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.11.1
4
+ version: 1.12.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-03 00:00:00.000000000 Z
11
+ date: 2016-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -259,6 +259,7 @@ files:
259
259
  - spinach_examples/steps/test_how_spinach_works_for_first_test.rb
260
260
  - spinach_examples/steps/test_how_spinach_works_for_second_test.rb
261
261
  - spinach_examples/support/env.rb
262
+ - test_examples/fast/shared_examples_test.rb
262
263
  - test_examples/fast/spec_test.rb
263
264
  - test_examples/fast/unit_test.rb
264
265
  - test_examples/slow/slow_test.rb