knapsack_pro 2.2.0 → 2.2.1

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
  SHA256:
3
- metadata.gz: b399cf5cff114341276acbcc1c9c372ff4bfb51ffc05a5ee5b59cf531dc64feb
4
- data.tar.gz: aed0dea9791ab8589c63192e53b3f64c2a071f690553bc0d450be61d20b51b1e
3
+ metadata.gz: da894046fe3bb6c6f7d3042ed03e9181a795d039c53ccd11bb94e40f0435d7c8
4
+ data.tar.gz: 246cc29e1c0d255e2a822847de009f4efe1c5bee09bf2c79453a2fa146e5c241
5
5
  SHA512:
6
- metadata.gz: d44d7d00c68d618d7ec41b764b28a8bcd7e5f2c62329d7246f2ee760f0d956ce7f1ffbbf6e8fae2adedf3cbd62d83a255f0b89a1dff9c8cc216d42cd11a89603
7
- data.tar.gz: 403cbc599ff70473aa07ae92abb73016a942c3ed21a2bbcb376ade1e8d0fe62e1ea64677fd6527c5a2b8822bd65fa7c6139ffb6c0850f273b795303974724bab
6
+ metadata.gz: bed442bb1ea7c2aacd84f8ee7989f03cf8fe1ef4ebe051d07f1b1261e9cee94abd355625c31d682faf9c077e978dd3876c2b6fd18497590dd919692e76640812
7
+ data.tar.gz: 3e3938594bc73b62871689fb649fe6e5b74ce5c4fac8e935f805d2a3030e19f96db5424f8c78d32fd74cbe7922f3385483d2deb91d85c9d2920eaf3085e2d61a
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ### 2.2.1
4
+
5
+ * Improve detection of test file path in test-unit runner for test files with shared examples
6
+
7
+ https://github.com/KnapsackPro/knapsack_pro-ruby/pull/123
8
+
9
+ https://github.com/KnapsackPro/knapsack_pro-ruby/compare/v2.2.0...v2.2.1
10
+
3
11
  ### 2.2.0
4
12
 
5
13
  * Allow defining Queue Mode hooks multiple times (`KnapsackPro::Hooks::Queue.before_queue`, `KnapsackPro::Hooks::Queue.after_subset_queue`, `KnapsackPro::Hooks::Queue.after_queue`)
@@ -5,9 +5,29 @@ module KnapsackPro
5
5
  @@parent_of_test_dir = nil
6
6
 
7
7
  def self.test_path(obj)
8
- first_test = obj.tests.first
9
- method = first_test.method_name
10
- full_test_path = first_test.method(method).source_location.first
8
+ full_test_path = nil
9
+ found_valid_test_file_path = false
10
+
11
+ obj.tests.each do |test_obj|
12
+ method = test_obj.method_name
13
+ full_test_path = test_obj.method(method).source_location.first
14
+ # if we find a test file path that is a valid test file path within test suite directory
15
+ # then break to stop looking further.
16
+ # If we won't find a valid test file path then the last found path will be used as full_test_path
17
+ # For instance if test file contains only shared examples then it's not possible to properly detect test file path
18
+ # so the wrong path can be used like:
19
+ # /Users/artur/.rvm/gems/ruby-2.6.5/gems/shared_should-0.10.0/lib/shared_should/shared_context.rb
20
+ if full_test_path.include?(@@parent_of_test_dir)
21
+ found_valid_test_file_path = true
22
+ break
23
+ end
24
+ end
25
+
26
+ unless found_valid_test_file_path
27
+ KnapsackPro.logger.warn('cannot detect a valid test file path. Probably the test file contains only shared examples. Please add test cases to your test file. Read more at https://github.com/KnapsackPro/knapsack_pro-ruby/pull/123')
28
+ KnapsackPro.logger.warn("See test file for #{obj.inspect}")
29
+ end
30
+
11
31
  parent_of_test_dir_regexp = Regexp.new("^#{@@parent_of_test_dir}")
12
32
  test_path = full_test_path.gsub(parent_of_test_dir_regexp, '.')
13
33
  # test_path will look like ./test/dir/unit_test.rb
@@ -1,3 +1,3 @@
1
1
  module KnapsackPro
2
- VERSION = '2.2.0'
2
+ VERSION = '2.2.1'
3
3
  end
@@ -10,8 +10,7 @@ describe KnapsackPro::Adapters::TestUnitAdapter do
10
10
 
11
11
  before do
12
12
  parent_of_test_dir = File.expand_path('../../../', File.dirname(__FILE__))
13
- parent_of_test_dir_regexp = Regexp.new("^#{parent_of_test_dir}")
14
- described_class.class_variable_set(:@@parent_of_test_dir, parent_of_test_dir_regexp)
13
+ described_class.class_variable_set(:@@parent_of_test_dir, parent_of_test_dir)
15
14
  end
16
15
 
17
16
  context 'when regular test' do
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: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-02 00:00:00.000000000 Z
11
+ date: 2020-09-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake