test-unit 3.2.3 → 3.2.4

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: cc00d33f461d81ecfb9fd2ea0d0968bdf7ed3395
4
- data.tar.gz: 169383ca5327b810e2613ac08b6a89c6cf77f309
3
+ metadata.gz: 560e12d199e303860aa5410d5b4b7f73e4491970
4
+ data.tar.gz: b6dbafc77f21fd1b3f179542c4333eb965393cb4
5
5
  SHA512:
6
- metadata.gz: d4eab8012105cdfe92ea93cda5666b490e4a84d27af3c454726cd9b59769d9cc9c70329f945e02a951bc5c65d5de125ee77e2d1c3559bb4949f80a8b440476ca
7
- data.tar.gz: 26c82141efe00a0992c704102a84a6564085fcfa91217e409c42d5ae672d3637c657aa6a65422cad15acd061b3c6709fb019ad6669413af9189ae473f31cd775
6
+ metadata.gz: f1a8fde930effcca2418506776f8142390502033107f8c1ed239d83d854e6255c28cb846bfcf4e76cbec96948f1a74c0d1e9fc0996ca60a548c16f4b9888f40d
7
+ data.tar.gz: 7fbd95ad36bc11c0cc8efb7610a94f7c0f191a745a5b71723dc4cb5f9711dca4442137c735fd20a8fdb8c38f0afdb4708eca1c95de5c5366ec238bbc375a7f19
data/README.md CHANGED
@@ -34,7 +34,7 @@ writing tests, checking results and automated testing in Ruby.
34
34
 
35
35
  ## How To
36
36
 
37
- * [How To](doc/text/how-to.md) (link for GitHub)
37
+ * [How To](https://github.com/test-unit/test-unit/blob/master/doc/text/how-to.md) (link for GitHub)
38
38
  * {file:doc/text/how-to.md How To} (link for YARD)
39
39
 
40
40
  ## Install
@@ -77,7 +77,7 @@ Exception:
77
77
 
78
78
  ### Images
79
79
 
80
- * Mayu & Co.: kinotan icons: http://cocooooooon.com/kinotan/
80
+ * Mayu & Co.: kinotan icons
81
81
 
82
82
  ## Thanks
83
83
 
@@ -0,0 +1,246 @@
1
+ ## 1. First step of the `test-unit`
2
+
3
+ Let's getting start `test-unit`.
4
+
5
+ This document creates an example gem package called `sample` with the `test-unit` testing framework.
6
+
7
+ ## 2. Install bundler and test-unit.
8
+
9
+ * First, install the `bundler` gem for generating gem template.
10
+ * Second, install the `test-unit` itself.
11
+
12
+ ~~~
13
+ !!!plain
14
+ gem install bundler
15
+ gem install test-unit
16
+ ~~~
17
+
18
+ The `gem list` command output installed packages.
19
+ You will find the following lines.
20
+
21
+ ~~~
22
+ !!!plain
23
+ gem list
24
+ ...
25
+ bundler (1.14.6)
26
+ ...
27
+ test-unit (3.2.3)
28
+ ~~~
29
+
30
+ ## 3. Create gem template.
31
+
32
+ Next, create a gem template using `bundler` command.
33
+ This command generates package skeleton with a testing framework.
34
+ However, this command can't generate test templates for `test-unit`.
35
+
36
+ So, First create gem template with the `minitest` testing framework.
37
+ (It's similar to `unit-test`).
38
+ After that, replace some files for `test-unit`.
39
+
40
+ The `bundle gem -t minitest sample` command will generate the following files.
41
+
42
+ ~~~
43
+ !!!plain
44
+ .
45
+ |-- Gemfile
46
+ |-- README.md
47
+ |-- Rakefile
48
+ |-- bin
49
+ | |-- console
50
+ | `-- setup
51
+ |-- lib
52
+ | |-- sample
53
+ | | `-- version.rb
54
+ | `-- sample.rb
55
+ |-- sample.gemspec # <- Modify
56
+ `-- test
57
+ |-- sample_test.rb # <- Modify
58
+ `-- test_helper.rb # <- Modify
59
+ ~~~
60
+
61
+ ## 4. Edit files for `test-unit`
62
+
63
+ ### 4.1. Edit gemspec
64
+
65
+ Edit `sample.gemspec` like the below.
66
+ Replace `minitest` line to `test-unit`.
67
+
68
+ Before
69
+
70
+ ~~~
71
+ !!!ruby
72
+ spec.add_development_dependency "minitest", "~> 5.0"
73
+ ~~~
74
+
75
+ After
76
+
77
+ ~~~
78
+ !!!ruby
79
+ spec.add_development_dependency "test-unit", "~> 3.2.3"
80
+ ~~~
81
+
82
+ ### 4.2. Edit `test/test_helper.rb`
83
+
84
+ Next, edit the `test/test_helper.rb` file.
85
+
86
+ Before
87
+
88
+ ~~~
89
+ !!!ruby
90
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
91
+ require 'sample'
92
+
93
+ require 'minitest/autorun' # <-- Modify this line.
94
+ ~~~
95
+
96
+ After
97
+
98
+ ~~~
99
+ !!!ruby
100
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
101
+ require 'sample'
102
+
103
+ require 'test/unit' # <-- After modification.
104
+ ~~~
105
+
106
+ ### 4.3 Rakefile (No edit)
107
+
108
+ This file doesn't need to modify.
109
+ The output is the below.
110
+
111
+ ~~~
112
+ !!!ruby
113
+ require "bundler/gem_tasks"
114
+ require "rake/testtask"
115
+
116
+ Rake::TestTask.new(:test) do |t|
117
+ t.libs << "test"
118
+ t.libs << "lib"
119
+ t.test_files = FileList['test/**/*_test.rb']
120
+ end
121
+
122
+ task :default => :test
123
+ ~~~
124
+
125
+ ### 4.4 Edit `test/sample_test.rb`
126
+
127
+ The bundler generate the file `test/sample_test.rb`.
128
+ This file originally templates for `minitest`.
129
+
130
+ Let's modify this file for `test-unit`
131
+
132
+ before
133
+
134
+ ~~~
135
+ !!!ruby
136
+ require 'test_helper'
137
+
138
+ class SampleTest < Minitest::Test # <- Modify here
139
+ def test_that_it_has_a_version_number
140
+ refute_nil ::Sample::VERSION
141
+ end
142
+
143
+ def test_it_does_something_useful
144
+ assert false
145
+ end
146
+ end
147
+ ~~~
148
+
149
+ After
150
+
151
+ ~~~
152
+ !!!ruby
153
+ require 'test_helper'
154
+
155
+ class SampleTest < Test::Unit::TestCase # <- After modification
156
+ def test_that_it_has_a_version_number
157
+ refute_nil ::Sample::VERSION
158
+ end
159
+
160
+ def test_it_does_something_useful
161
+ assert false
162
+ end
163
+ end
164
+ ~~~
165
+
166
+ ## 5. Execute test.
167
+
168
+ The `rake test` command execute test scenarios in the `test` directory.
169
+ Now it tries to two tests. One will success the other one fails.
170
+
171
+ ~~~
172
+ !!!plain
173
+ rake test
174
+ Loaded suite
175
+ /path/to/ruby/lib/ruby/gems/2.3.0/gems/rake-12.0.0/lib/rake/rake_test_loader
176
+ Started
177
+ F
178
+ ================================================================================
179
+ Failure: <false> is not true.
180
+ test_it_does_something_useful(SampleTest)
181
+ /path/to/sample/test/sample_test.rb:9:in `test_it_does_something_useful'
182
+ 6: end
183
+ 7:
184
+ 8: def test_it_does_something_useful
185
+ => 9: assert false
186
+ 10: end
187
+ 11: end
188
+ ================================================================================
189
+ .
190
+
191
+ Finished in 0.011521 seconds.
192
+ --------------------------------------------------------------------------------
193
+ 2 tests, 2 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
194
+ 50% passed
195
+ --------------------------------------------------------------------------------
196
+ 173.60 tests/s, 173.60 assertions/s
197
+ rake aborted!
198
+ Command failed with status (1)
199
+
200
+ Tasks: TOP => test
201
+ (See full trace by running task with --trace)
202
+ ~~~
203
+
204
+ ## 6. Create original tests.
205
+
206
+ Let's create your original tests with the following rules.
207
+
208
+ * Create a test file in the `test` directory.
209
+ * The file needs suffix `xxx_test.rb`.
210
+ * You can put test file into the subdirectory like `test/sub`.
211
+
212
+ Example directory layout.
213
+
214
+ ~~~
215
+ !!!plain
216
+ test
217
+ |-- sample_test.rb
218
+ |-- sub
219
+ | `-- sample2_test.rb
220
+ `-- test_helper.rb
221
+ ~~~
222
+
223
+ Example test file in the sub directory.
224
+
225
+ ~~~
226
+ !!!ruby
227
+ require 'test_helper'
228
+
229
+ module Sub
230
+ class Sample2Test < Test::Unit::TestCase
231
+ def test_that_it_has_a_version_number
232
+ refute_nil ::Sample::VERSION
233
+ end
234
+
235
+ def test_it_does_something_useful
236
+ assert false
237
+ end
238
+ end
239
+ end
240
+ ~~~
241
+
242
+ ## 7. For more inforomation
243
+
244
+ Let's read the official document.
245
+
246
+ * [test-unit](http://test-unit.github.io/index.html)
@@ -1,5 +1,69 @@
1
1
  # News
2
2
 
3
+ ## 3.2.4 - 2017-05-23 {#version-3-2-4}
4
+
5
+ ### Improvements
6
+
7
+ * Updated tests for Ruby 2.4. [GitHUb#136][Patch by Kazuki Tsujimoto]
8
+
9
+ * Supported power\_assert 1.0.0. [GitHub#137][Patch by Kazuki Tsujimoto]
10
+
11
+ * Added the getting started document.
12
+ [GitHub#139][GitHub#141][Patch by Hiroyuki Sato]
13
+
14
+ * Added the document for `attribute`.
15
+ [GitHub#143][Patch by Fumiaki MATSUSHIMA]
16
+
17
+ * Improved a link for GitHub. [GitHub#144][Patch by rochefort]
18
+
19
+ * Updated `.travis.yml`. [GitHub#145][Patch by Jun Aruga]
20
+
21
+ ### Fixes
22
+
23
+ * Fixed a contributor name. [GitHub#131][Patch by Akira Matsuda]
24
+
25
+ * Fixed typos in document. [GitHub#132][Patch by Akira Matsuda]
26
+
27
+ * Fixed typos in document. [GitHub#134][Patch by Yuji Yaginuma]
28
+
29
+ * Fixed a bug that data label with "(" isn't supported.
30
+ [GitHub#135][Reported by Kazuki Tsujimoto]
31
+
32
+ * Fixed assertion message in English.
33
+ [GitHub#133][Reported by Khalil Fazal]
34
+
35
+ * Fixed a typo in typo fix. [GitHub#138][Patch by kami]
36
+
37
+ * Fixed a bug that target location finder may return wrong
38
+ location. [GitHub#146][Patch by Yuki Ito]
39
+
40
+ * Fixed a bug that `--no-show-detail-immediately` raises an error.
41
+ [GitHub#147][Reported by MSP-Greg]
42
+
43
+ ### Thanks
44
+
45
+ * Akira Matsuda
46
+
47
+ * Yuji Yaginuma
48
+
49
+ * Kazuki Tsujimoto
50
+
51
+ * Khalil Fazal
52
+
53
+ * kami
54
+
55
+ * Hiroyuki Sato
56
+
57
+ * Fumiaki MATSUSHIMA
58
+
59
+ * rochefort
60
+
61
+ * Jun Aruga
62
+
63
+ * Yuki Ito
64
+
65
+ * MSP-Greg
66
+
3
67
  ## 3.2.3 - 2016-11-25 {#version-3-2-3}
4
68
 
5
69
  ### Fixes
@@ -16,7 +80,7 @@
16
80
  ### Improvements
17
81
 
18
82
  * Improved Travis CI configuration.
19
- [GitHub#123][Patch by Ryunosuke SEATO]
83
+ [GitHub#123][Patch by Ryunosuke Sato]
20
84
 
21
85
  * Supported Java native exception.
22
86
  [GitHub#126][Reported by Bob Saveland]
@@ -573,7 +637,7 @@ It's a release for minitest compatibility and bug fix.
573
637
 
574
638
  * Allowed use of test for inheritance in ActionController::TestCase.
575
639
  [GitHub#42] [Patch by David Rasch]
576
- * Ensured evaluating at_exist block in top level.
640
+ * Ensured evaluating at_exit block in top level.
577
641
  In IRB context, exit() specifies irb_exit().
578
642
  [test-unit-users-en:00089] [Reported by Daniel Berger]
579
643
  * Fixed a bug that decoration style description is ignored.
@@ -334,7 +334,7 @@ EOT
334
334
  "<#{value}>"
335
335
  end
336
336
  full_message = build_message(message, <<EOT, object, klass_message, object.class)
337
- <?> expected to be instance_of\\?
337
+ <?> was expected to be instance_of\\?
338
338
  ? but was
339
339
  <?>.
340
340
  EOT
@@ -370,7 +370,7 @@ EOT
370
370
  "<#{value}>"
371
371
  end
372
372
  full_message = build_message(message,
373
- "<?> expected to not be instance_of\\?\n" +
373
+ "<?> was expected to not be instance_of\\?\n" +
374
374
  "? but was.",
375
375
  object,
376
376
  klass_message)
@@ -392,7 +392,7 @@ EOT
392
392
  # assert_nil [1, 2].uniq!
393
393
  def assert_nil(object, message="")
394
394
  full_message = build_message(message, <<EOT, object)
395
- <?> expected to be nil.
395
+ <?> was expected to be nil.
396
396
  EOT
397
397
  assert_block(full_message) { object.nil? }
398
398
  end
@@ -421,7 +421,7 @@ EOT
421
421
  "<#{value}>"
422
422
  end
423
423
  full_message = build_message(message,
424
- "<?> expected to be kind_of\\?\n" +
424
+ "<?> was expected to be kind_of\\?\n" +
425
425
  "? but was\n" +
426
426
  "<?>.",
427
427
  object,
@@ -459,7 +459,7 @@ EOT
459
459
  "<#{value}>"
460
460
  end
461
461
  full_message = build_message(message,
462
- "<?> expected to not be kind_of\\?\n" +
462
+ "<?> was expected to not be kind_of\\?\n" +
463
463
  "? but was.",
464
464
  object,
465
465
  klass_message)
@@ -537,7 +537,8 @@ EOT
537
537
  else
538
538
  pattern
539
539
  end
540
- full_message = build_message(message, "<?> expected to be =~\n<?>.",
540
+ full_message = build_message(message,
541
+ "<?> was expected to be =~\n<?>.",
541
542
  pattern, string)
542
543
  assert_block(full_message) { pattern =~ string }
543
544
  end
@@ -553,7 +554,7 @@ EOT
553
554
  def assert_same(expected, actual, message="")
554
555
  full_message = build_message(message, <<EOT, expected, expected.__id__, actual, actual.__id__)
555
556
  <?>
556
- with id <?> expected to be equal\\? to
557
+ with id <?> was expected to be equal\\? to
557
558
  <?>
558
559
  with id <?>.
559
560
  EOT
@@ -572,7 +573,7 @@ EOT
572
573
  full_message = build_message(nil, "<?>\ngiven as the operator for #assert_operator must be a Symbol or #respond_to\\?(:to_str).", operator)
573
574
  assert_block(full_message){operator.kind_of?(Symbol) || operator.respond_to?(:to_str)}
574
575
  full_message = build_message(message, <<EOT, object1, AssertionMessage.literal(operator), object2)
575
- <?> expected to be
576
+ <?> was expected to be
576
577
  ?
577
578
  <?>.
578
579
  EOT
@@ -595,7 +596,7 @@ EOT
595
596
  full_message = build_message(nil, "<?>\ngiven as the operator for #assert_not_operator must be a Symbol or #respond_to\\?(:to_str).", operator)
596
597
  assert_block(full_message){operator.kind_of?(Symbol) || operator.respond_to?(:to_str)}
597
598
  full_message = build_message(message, <<EOT, object1, AssertionMessage.literal(operator), object2)
598
- <?> expected to not be
599
+ <?> was expected to not be
599
600
  ?
600
601
  <?>.
601
602
  EOT
@@ -655,7 +656,7 @@ EOT
655
656
  def assert_not_same(expected, actual, message="")
656
657
  full_message = build_message(message, <<EOT, expected, expected.__id__, actual, actual.__id__)
657
658
  <?>
658
- with id <?> expected to not be equal\\? to
659
+ with id <?> was expected to not be equal\\? to
659
660
  <?>
660
661
  with id <?>.
661
662
  EOT
@@ -673,7 +674,9 @@ EOT
673
674
  # @example
674
675
  # assert_not_equal 'some string', 5
675
676
  def assert_not_equal(expected, actual, message="")
676
- full_message = build_message(message, "<?> expected to be != to\n<?>.", expected, actual)
677
+ full_message = build_message(message,
678
+ "<?> was expected to be != to\n<?>.",
679
+ expected, actual)
677
680
  assert_block(full_message) { expected != actual }
678
681
  end
679
682
 
@@ -688,7 +691,9 @@ EOT
688
691
  # @example
689
692
  # assert_not_nil '1 two 3'.sub!(/two/, '2')
690
693
  def assert_not_nil(object, message="")
691
- full_message = build_message(message, "<?> expected to not be nil.", object)
694
+ full_message = build_message(message,
695
+ "<?> was expected to not be nil.",
696
+ object)
692
697
  assert_block(full_message){!object.nil?}
693
698
  end
694
699
 
@@ -709,7 +714,7 @@ EOT
709
714
  "<REGEXP> in assert_not_match(<REGEXP>, ...) " +
710
715
  "should be a Regexp.")
711
716
  full_message = build_message(message,
712
- "<?> expected to not match\n<?>.",
717
+ "<?> was expected to not match\n<?>.",
713
718
  regexp, string)
714
719
  assert_block(full_message) { regexp !~ string }
715
720
  end
@@ -813,7 +818,7 @@ EOT
813
818
  tag = extractor.extract_tag
814
819
  raise if tag.nil?
815
820
  full_message = build_message(message,
816
- "<?> expected to be thrown but\n" +
821
+ "<?> was expected to be thrown but\n" +
817
822
  "<?> was thrown.",
818
823
  expected_object, tag)
819
824
  flunk(full_message)
@@ -921,12 +926,12 @@ EOT
921
926
  message, options={})
922
927
  if options[:negative_assertion]
923
928
  format = <<-EOT
924
- <?> -/+ <?> expected to not include
929
+ <?> -/+ <?> was expected to not include
925
930
  <?>.
926
931
  EOT
927
932
  else
928
933
  format = <<-EOT
929
- <?> -/+ <?> expected to include
934
+ <?> -/+ <?> was expected to include
930
935
  <?>.
931
936
  EOT
932
937
  end
@@ -1060,12 +1065,12 @@ EOT
1060
1065
 
1061
1066
  if options[:negative_assertion]
1062
1067
  format = <<-EOT
1063
- <?> -/+ (<?> * <?>)[?] expected to not include
1068
+ <?> -/+ (<?> * <?>)[?] was expected to not include
1064
1069
  <?>.
1065
1070
  EOT
1066
1071
  else
1067
1072
  format = <<-EOT
1068
- <?> -/+ (<?> * <?>)[?] expected to include
1073
+ <?> -/+ (<?> * <?>)[?] was expected to include
1069
1074
  <?>.
1070
1075
  EOT
1071
1076
  end
@@ -1130,7 +1135,7 @@ EOT
1130
1135
  "assert_send requires at least a receiver " +
1131
1136
  "and a message name")
1132
1137
  format = <<EOT
1133
- <?> expected to respond to
1138
+ <?> was expected to respond to
1134
1139
  <?(*?)> with a true value but was
1135
1140
  <?>.
1136
1141
  EOT
@@ -1170,7 +1175,7 @@ EOT
1170
1175
  "assert_not_send requires at least a receiver " +
1171
1176
  "and a message name")
1172
1177
  format = <<EOT
1173
- <?> expected to respond to
1178
+ <?> was expected to respond to
1174
1179
  <?(*?)> with not a true value but was
1175
1180
  <?>.
1176
1181
  EOT
@@ -1260,7 +1265,7 @@ EOT
1260
1265
  end
1261
1266
  template = <<-EOT
1262
1267
  <?> #{operator} <?> should be true
1263
- <?> expected #{operator_description}
1268
+ <?> was expected to be #{operator_description}
1264
1269
  <?>.
1265
1270
  EOT
1266
1271
  full_message = build_message(message, template,
@@ -1305,7 +1310,7 @@ EOT
1305
1310
  def assert_raise_message(expected, message=nil)
1306
1311
  _wrap_assertion do
1307
1312
  full_message = build_message(message,
1308
- "<?> exception message expected " +
1313
+ "<?> exception message was expected " +
1309
1314
  "but none was thrown.",
1310
1315
  expected)
1311
1316
  exception = nil
@@ -1475,7 +1480,7 @@ EOT
1475
1480
  def assert_path_exist(path, message=nil)
1476
1481
  _wrap_assertion do
1477
1482
  failure_message = build_message(message,
1478
- "<?> expected to exist",
1483
+ "<?> was expected to exist",
1479
1484
  path)
1480
1485
  assert_block(failure_message) do
1481
1486
  File.exist?(path)
@@ -1493,7 +1498,7 @@ EOT
1493
1498
  def assert_path_not_exist(path, message=nil)
1494
1499
  _wrap_assertion do
1495
1500
  failure_message = build_message(message,
1496
- "<?> expected to not exist",
1501
+ "<?> was expected to not exist",
1497
1502
  path)
1498
1503
  assert_block(failure_message) do
1499
1504
  not File.exist?(path)
@@ -1514,7 +1519,7 @@ EOT
1514
1519
  assert_respond_to(collection, :include?,
1515
1520
  "The collection must respond to :include?.")
1516
1521
  full_message = build_message(message,
1517
- "<?> expected to include\n<?>.",
1522
+ "<?> was expected to include\n<?>.",
1518
1523
  collection,
1519
1524
  object)
1520
1525
  assert_block(full_message) do
@@ -1541,7 +1546,7 @@ EOT
1541
1546
  assert_respond_to(collection, :include?,
1542
1547
  "The collection must respond to :include?.")
1543
1548
  full_message = build_message(message,
1544
- "<?> expected to not include\n<?>.",
1549
+ "<?> was expected to not include\n<?>.",
1545
1550
  collection,
1546
1551
  object)
1547
1552
  assert_block(full_message) do
@@ -1575,7 +1580,7 @@ EOT
1575
1580
  assert_respond_to(object, :empty?,
1576
1581
  "The object must respond to :empty?.")
1577
1582
  full_message = build_message(message,
1578
- "<?> expected to be empty.",
1583
+ "<?> was expected to be empty.",
1579
1584
  object)
1580
1585
  assert_block(full_message) do
1581
1586
  object.empty?
@@ -1598,7 +1603,7 @@ EOT
1598
1603
  assert_respond_to(object, :empty?,
1599
1604
  "The object must respond to :empty?.")
1600
1605
  full_message = build_message(message,
1601
- "<?> expected to not be empty.",
1606
+ "<?> was expected to not be empty.",
1602
1607
  object)
1603
1608
  assert_block(full_message) do
1604
1609
  not object.empty?
@@ -1666,7 +1671,7 @@ EOT
1666
1671
  expected = assert_exception_helper.expected_exceptions
1667
1672
  actual_exception = nil
1668
1673
  full_message = build_message(message,
1669
- "<?> exception expected " +
1674
+ "<?> exception was expected " +
1670
1675
  "but none was thrown.",
1671
1676
  expected)
1672
1677
  assert_block(full_message) do