test-unit 3.1.0 → 3.1.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: f0f3d6b7558b8c2dd32e218231b2b826791440da
4
- data.tar.gz: 07aabaaba099bf99ad12491d9b747fa121f9ecf3
3
+ metadata.gz: 9aab3e867096b99241299d05bac77a6219b889c9
4
+ data.tar.gz: d37423596384fbe1101e39631bd78460c0f474bd
5
5
  SHA512:
6
- metadata.gz: 2f810e4cb4ac200999a8afe12c91557855fefb446ac3f2fb6cffe17e973efb02f4840a4ae6cbf01996a21cc0f64e93c3288c895398f9fdb37e76cdadf25ead0a
7
- data.tar.gz: 36725fd11eb881311aa7f8bd67e6a00ff3de6784448ecaa2cdaa5b7041df4045fbf52262fc1aa879e70cef58f9f94cff56fa1d9eb66067108ba3657fb884a1a9
6
+ metadata.gz: dfb885607b6ee435b859c3dfe65b9e4fde45322707139d8005b9b61357c8917e3ca4b2ede42ed9d279877380473bfb99063b712769535aee536ee6f54e810c7f
7
+ data.tar.gz: bae2d82bc3c5ba69d70f26ecc977574f5c9d017ddc1d88002939496ce1a6426e9799d50e7d9dbad645187e392447b0626776c761470f97112e1a54070ac6472b
@@ -1,5 +1,19 @@
1
1
  # News
2
2
 
3
+ ## 3.1.1 - 2015-05-29 {#version-3-1-1}
4
+
5
+ It's a bug fix release.
6
+
7
+ ### Fixes
8
+
9
+ * Fixed a bug that `--location` detects tests not only in sub test
10
+ case but also parent test case.
11
+ [GitHub#105][Reported by wanabe]
12
+
13
+ ### Thanks
14
+
15
+ * wanabe
16
+
3
17
  ## 3.1.0 - 2015-05-28 {#version-3-1-0}
4
18
 
5
19
  It's a bug fix release.
@@ -360,17 +360,16 @@ module Test
360
360
  query_line = query[:line]
361
361
  query_method_name = query[:method_name]
362
362
 
363
- available_locations = method_locations
364
- if query_path
365
- available_locations = available_locations.find_all do |location|
366
- location[:path].end_with?(query_path)
367
- end
368
- end
363
+ available_locations = target_method_locations(query_path)
369
364
  if query_line
370
- available_location = available_locations.reverse.find do |location|
365
+ available_locations = available_locations.sort_by do |location|
366
+ -location[:line]
367
+ end
368
+ available_location = available_locations.find do |location|
371
369
  query_line >= location[:line]
372
370
  end
373
371
  return false if available_location.nil?
372
+ return false if available_location[:test_case] != self
374
373
  available_locations = [available_location]
375
374
  end
376
375
  if query_method_name
@@ -391,6 +390,25 @@ module Test
391
390
  def method_locations
392
391
  @@method_locations[self] ||= []
393
392
  end
393
+
394
+ # @private
395
+ def target_method_locations(path)
396
+ if path.nil?
397
+ self_location = method_locations.first
398
+ path = self_location[:path] if self_location
399
+ end
400
+ return [] if path.nil?
401
+
402
+ target_locations = []
403
+ @@method_locations.each do |test_case, locations|
404
+ locations.each do |location|
405
+ if location[:path].end_with?(path)
406
+ target_locations << location.merge(:test_case => test_case)
407
+ end
408
+ end
409
+ end
410
+ target_locations
411
+ end
394
412
  end
395
413
 
396
414
  attr_reader :method_name
@@ -1,5 +1,5 @@
1
1
  module Test
2
2
  module Unit
3
- VERSION = '3.1.0'
3
+ VERSION = '3.1.1'
4
4
  end
5
5
  end
@@ -660,6 +660,28 @@ module Test
660
660
  end
661
661
  assert_true(test_case.test_defined?(:line => line_after))
662
662
  end
663
+
664
+ def test_child
665
+ child_test_case = nil
666
+ line_child = nil
667
+ parent_test_case = Class.new(TestCase) do
668
+ test "parent" do
669
+ end
670
+
671
+ child_test_case = Class.new(self) do
672
+ line_child = __LINE__; test "child" do
673
+ end
674
+ end
675
+ end
676
+ assert_equal([
677
+ false,
678
+ true,
679
+ ],
680
+ [
681
+ parent_test_case.test_defined?(:line => line_child),
682
+ child_test_case.test_defined?(:line => line_child),
683
+ ])
684
+ end
663
685
  end
664
686
 
665
687
  class TestMethodStyle < self
@@ -691,6 +713,28 @@ module Test
691
713
  end
692
714
  assert_true(test_case.test_defined?(:line => line_after))
693
715
  end
716
+
717
+ def test_child
718
+ child_test_case = nil
719
+ line_child = nil
720
+ parent_test_case = Class.new(TestCase) do
721
+ test "parent" do
722
+ end
723
+
724
+ child_test_case = Class.new(self) do
725
+ line_child = __LINE__; test "child" do
726
+ end
727
+ end
728
+ end
729
+ assert_equal([
730
+ false,
731
+ true,
732
+ ],
733
+ [
734
+ parent_test_case.test_defined?(:line => line_child),
735
+ child_test_case.test_defined?(:line => line_child),
736
+ ])
737
+ end
694
738
  end
695
739
  end
696
740
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: test-unit
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouhei Sutou
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-05-28 00:00:00.000000000 Z
12
+ date: 2015-05-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: power_assert