minitest 5.27.0 → 6.0.0.a1

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.
@@ -200,11 +200,16 @@ describe Minitest::Spec do
200
200
  must_raise
201
201
  must_respond_to
202
202
  must_throw
203
- must_verify
204
203
  path_must_exist]
205
204
 
206
205
  bad = %w[not raise throw send output be_silent verify]
207
206
 
207
+ if methods.include? "must_infect" then # from test_minitest_mock.rb
208
+ expected_musts += %w[must_infect must_infect_without_flipping]
209
+ expected_musts.sort!
210
+ bad << "infect"
211
+ end
212
+
208
213
  expected_wonts = expected_musts.map { |m| m.sub("must", "wont") }.sort
209
214
  expected_wonts.reject! { |m| m =~ /wont_#{Regexp.union(*bad)}/ }
210
215
 
@@ -225,6 +230,8 @@ describe Minitest::Spec do
225
230
  end
226
231
 
227
232
  it "needs to verify binary messages" do
233
+ @assertion_count += 3
234
+
228
235
  assert_success _(42).wont_be(:<, 24)
229
236
 
230
237
  assert_triggered "Expected 24 to not be < 42." do
@@ -268,15 +275,9 @@ describe Minitest::Spec do
268
275
  end
269
276
  end
270
277
 
271
- it "needs to warn on equality with nil" do
272
- @assertion_count = 3
273
- @assertion_count += 2 unless error_on_warn? # 2 extra assertions
274
-
275
- exp = /.*?test_minitest_\w+.rb:\d+: warning: DEPRECATED: Use assert_nil if expecting nil. This will fail in Minitest 6./
276
-
277
- assert_deprecation exp do
278
- assert_success _(nil).must_equal(nil)
279
- end
278
+ it "needs to fail on equality with nil" do
279
+ @assertion_count -= 2
280
+ expect { _(nil).must_equal(nil) }.must_raise Minitest::Assertion
280
281
  end
281
282
 
282
283
  it "needs to verify floats outside a delta" do
@@ -288,12 +289,11 @@ describe Minitest::Spec do
288
289
  _(6 * 7.0).wont_be_close_to 42
289
290
  end
290
291
 
291
- x = "1.0e-05"
292
- assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
292
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 1.0e-05." do
293
293
  _(6 * 7.0).wont_be_close_to 42, 0.00001
294
294
  end
295
295
 
296
- assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= #{x}." do
296
+ assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= 1.0e-05." do
297
297
  _(6 * 7.0).wont_be_close_to 42, 0.00001, "msg"
298
298
  end
299
299
  end
@@ -303,17 +303,15 @@ describe Minitest::Spec do
303
303
 
304
304
  assert_success _(24).wont_be_within_epsilon(42)
305
305
 
306
- x = "0.042"
307
- assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
306
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.042." do
308
307
  _(6 * 7.0).wont_be_within_epsilon 42
309
308
  end
310
309
 
311
- x = "0.00042"
312
- assert_triggered "Expected |42 - 42.0| (0.0) to not be <= #{x}." do
310
+ assert_triggered "Expected |42 - 42.0| (0.0) to not be <= 0.00042." do
313
311
  _(6 * 7.0).wont_be_within_epsilon 42, 0.00001
314
312
  end
315
313
 
316
- assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= #{x}." do
314
+ assert_triggered "msg.\nExpected |42 - 42.0| (0.0) to not be <= 0.00042." do
317
315
  _(6 * 7.0).wont_be_within_epsilon 42, 0.00001, "msg"
318
316
  end
319
317
  end
@@ -327,12 +325,11 @@ describe Minitest::Spec do
327
325
  _(1.0 / 100).must_be_close_to 0.0
328
326
  end
329
327
 
330
- x = "1.0e-06"
331
- assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
328
+ assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= 1.0e-06." do
332
329
  _(1.0 / 1000).must_be_close_to 0.0, 0.000001
333
330
  end
334
331
 
335
- assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= #{x}." do
332
+ assert_triggered "msg.\nExpected |0.0 - 0.001| (0.001) to be <= 1.0e-06." do
336
333
  _(1.0 / 1000).must_be_close_to 0.0, 0.000001, "msg"
337
334
  end
338
335
  end
@@ -554,67 +551,6 @@ describe Minitest::Spec do
554
551
  it "can use expect in a thread" do
555
552
  Thread.new { _(1 + 1).must_equal 2 }.join
556
553
  end
557
-
558
- it "can NOT use must_equal in a thread. It must use expect in a thread" do
559
- skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
560
-
561
- assert_raises RuntimeError, Minitest::UnexpectedWarning do
562
- capture_io do
563
- Thread.new { (1 + 1).must_equal 2 }.join
564
- end
565
- end
566
- end
567
-
568
- it "fails gracefully when expectation used outside of `it`" do
569
- skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
570
-
571
- @assertion_count += 2 # assert_match is compound
572
-
573
- e = assert_raises RuntimeError, Minitest::UnexpectedWarning do
574
- capture_io do
575
- Thread.new { # forces ctx to be nil
576
- describe "woot" do
577
- (1 + 1).must_equal 2
578
- end
579
- }.join
580
- end
581
- end
582
-
583
- exp = "Calling #must_equal outside of test."
584
- exp = "DEPRECATED: global use of must_equal from" if error_on_warn?
585
-
586
- assert_match exp, e.message
587
- end
588
-
589
- it "deprecates expectation used without _" do
590
- skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
591
-
592
- @assertion_count += 1
593
- @assertion_count += 2 unless error_on_warn?
594
-
595
- exp = /DEPRECATED: global use of must_equal from/
596
-
597
- assert_deprecation exp do
598
- (1 + 1).must_equal 2
599
- end
600
- end
601
-
602
- # https://github.com/seattlerb/minitest/issues/837
603
- # https://github.com/rails/rails/pull/39304
604
- it "deprecates expectation used without _ with empty backtrace_filter" do
605
- skip "N/A" if ENV["MT_NO_EXPECTATIONS"]
606
-
607
- @assertion_count += 1
608
- @assertion_count += 2 unless error_on_warn?
609
-
610
- exp = /DEPRECATED: global use of must_equal from/
611
-
612
- with_empty_backtrace_filter do
613
- assert_deprecation exp do
614
- (1 + 1).must_equal 2
615
- end
616
- end
617
- end
618
554
  end
619
555
 
620
556
  it "needs to verify throw" do
@@ -655,7 +591,7 @@ describe Minitest::Spec do
655
591
  end
656
592
 
657
593
  it "needs to verify using any (negative) predicate" do
658
- @assertion_count -= 1 # doesn"t take a message
594
+ @assertion_count += 1
659
595
 
660
596
  assert_success _("blah").wont_be(:empty?)
661
597
 
@@ -665,7 +601,7 @@ describe Minitest::Spec do
665
601
  end
666
602
 
667
603
  it "needs to verify using any binary operator" do
668
- @assertion_count -= 1 # no msg
604
+ @assertion_count += 1
669
605
 
670
606
  assert_success _(41).must_be(:<, 42)
671
607
 
@@ -675,7 +611,7 @@ describe Minitest::Spec do
675
611
  end
676
612
 
677
613
  it "needs to verify using any predicate" do
678
- @assertion_count -= 1 # no msg
614
+ @assertion_count += 1
679
615
 
680
616
  assert_success _("").must_be(:empty?)
681
617
 
@@ -1124,36 +1060,36 @@ class ValueMonadTest < Minitest::Test
1124
1060
  end
1125
1061
 
1126
1062
  describe Minitest::Spec, :infect_an_assertion do
1127
- class << self
1128
- attr_accessor :infect_mock
1063
+ attr_accessor :infect_mock
1064
+
1065
+ before do
1066
+ mock = Object.new
1067
+ mock.singleton_class.attr_accessor :a, :k
1068
+ def mock.assert_infects *args, **kwargs
1069
+ self.a, self.k = args, kwargs
1070
+ end
1071
+
1072
+ self.infect_mock = mock
1129
1073
  end
1130
1074
 
1131
1075
  def assert_infects exp, act, msg = nil, foo: nil, bar: nil
1132
- self.class.infect_mock.assert_infects exp, act, msg, foo: foo, bar: bar
1076
+ self.infect_mock.assert_infects exp, act, msg, foo: foo, bar: bar
1133
1077
  end
1134
1078
 
1135
- infect_an_assertion :assert_infects, :must_infect
1136
- infect_an_assertion :assert_infects, :must_infect_without_flipping, :dont_flip
1079
+ Minitest::Expectations.infect_an_assertion :assert_infects, :must_infect
1080
+ Minitest::Expectations.infect_an_assertion :assert_infects, :must_infect_without_flipping, :dont_flip
1137
1081
 
1138
1082
  it "infects assertions with kwargs" do
1139
- mock = Minitest::Mock.new
1140
- mock.expect :assert_infects, true, [:exp, :act, nil], foo: :foo, bar: :bar
1141
-
1142
- self.class.infect_mock = mock
1143
-
1144
1083
  _(:act).must_infect :exp, foo: :foo, bar: :bar
1145
1084
 
1146
- assert_mock mock
1085
+ assert_equal [:exp, :act, nil], infect_mock.a
1086
+ assert_equal({foo: :foo, bar: :bar}, infect_mock.k)
1147
1087
  end
1148
1088
 
1149
1089
  it "infects assertions with kwargs (dont_flip)" do
1150
- mock = Minitest::Mock.new
1151
- mock.expect :assert_infects, true, [:act, :exp, nil], foo: :foo, bar: :bar
1152
-
1153
- self.class.infect_mock = mock
1154
-
1155
1090
  _(:act).must_infect_without_flipping :exp, foo: :foo, bar: :bar
1156
1091
 
1157
- assert_mock mock
1092
+ assert_equal [:act, :exp, nil], infect_mock.a
1093
+ assert_equal({foo: :foo, bar: :bar}, infect_mock.k)
1158
1094
  end
1159
1095
  end
@@ -342,6 +342,20 @@ class TestMinitestRunner < MetaMetaMetaTestCase
342
342
  assert_instance_of Integer, Minitest.seed
343
343
  end
344
344
 
345
+ def test_filter_runnable_methods
346
+ cls = Class.new Minitest::Runnable
347
+ def cls.runnable_methods
348
+ %w[ x y z ]
349
+ end
350
+
351
+ assert_equal %w[x y z], cls.filter_runnable_methods
352
+ assert_equal %w[x y], cls.filter_runnable_methods(exclude: "z")
353
+ assert_equal %w[x], cls.filter_runnable_methods(include: "x")
354
+
355
+ assert_empty cls.filter_runnable_methods(exclude: "/./")
356
+ assert_empty cls.filter_runnable_methods(include: "x", exclude: "x")
357
+ end
358
+
345
359
  def test_run_failing_filtered
346
360
  setup_basic_tu
347
361
 
@@ -566,7 +580,7 @@ class TestMinitestRunner < MetaMetaMetaTestCase
566
580
 
567
581
  def test_run_with_other_runner
568
582
  @tu = Class.new FakeNamedTest do
569
- def self.run reporter, options = {}
583
+ def self.run_suite reporter, options = {}
570
584
  @reporter = reporter
571
585
  before_my_suite
572
586
  super
@@ -795,40 +809,6 @@ class BetterError < RuntimeError # like better_error w/o infecting RuntimeError
795
809
  end
796
810
 
797
811
  class TestMinitestRunnable < Minitest::Test
798
- def setup_marshal klass
799
- tc = klass.new "whatever"
800
- tc.assertions = 42
801
- tc.failures << "a failure"
802
-
803
- yield tc if block_given?
804
-
805
- def tc.setup
806
- @blah = "blah"
807
- end
808
- tc.setup
809
-
810
- @tc = Minitest::Result.from tc
811
- end
812
-
813
- def assert_marshal expected_ivars
814
- new_tc = Marshal.load Marshal.dump @tc
815
-
816
- ivars = new_tc.instance_variables.map(&:to_s).sort
817
- ivars.delete "@gc_stats" # only needed if running w/ minitest-gcstats
818
- assert_equal expected_ivars, ivars
819
- assert_equal "whatever", new_tc.name
820
- assert_equal 42, new_tc.assertions
821
- assert_equal ["a failure"], new_tc.failures
822
-
823
- yield new_tc if block_given?
824
- end
825
-
826
- def test_marshal
827
- setup_marshal Minitest::Runnable
828
-
829
- assert_marshal %w[@NAME @assertions @failures @klass @source_location @time]
830
- end
831
-
832
812
  def test_spec_marshal
833
813
  klass = describe("whatever") { it("passes") { assert true } }
834
814
  rm = klass.runnable_methods.first
@@ -988,18 +968,6 @@ class TestMinitestRunnable < Minitest::Test
988
968
  end
989
969
  end
990
970
 
991
- class TestMinitestTest < TestMinitestRunnable
992
- def test_dup
993
- setup_marshal Minitest::Test do |tc|
994
- tc.time = 3.14
995
- end
996
-
997
- assert_marshal %w[@NAME @assertions @failures @klass @source_location @time] do |new_tc|
998
- assert_in_epsilon 3.14, new_tc.time
999
- end
1000
- end
1001
- end
1002
-
1003
971
  class TestMinitestUnitTestCase < Minitest::Test
1004
972
  # do not call parallelize_me! - teardown accesses @tc._assertions
1005
973
  # which is not threadsafe. Nearly every method in here is an
@@ -1017,7 +985,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1017
985
 
1018
986
  def teardown
1019
987
  assert_equal(@assertion_count, @tc.assertions,
1020
- "expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}") if @tc.passed?
988
+ message { "expected #{@assertion_count} assertions to be fired during the test, not #{@tc.assertions}" }) if @tc.passed?
1021
989
  end
1022
990
 
1023
991
  def non_verbose
@@ -1054,7 +1022,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1054
1022
  @assertion_count = 0
1055
1023
 
1056
1024
  sample_test_case = Class.new FakeNamedTest do
1057
- def self.test_order; :sorted end
1025
+ def self.run_order; :sorted end
1058
1026
  def test_test3; assert "does not matter" end
1059
1027
  def test_test2; assert "does not matter" end
1060
1028
  def test_test1; assert "does not matter" end
@@ -1064,14 +1032,14 @@ class TestMinitestUnitTestCase < Minitest::Test
1064
1032
  assert_equal expected, sample_test_case.runnable_methods
1065
1033
  end
1066
1034
 
1067
- def test_i_suck_and_my_tests_are_order_dependent_bang_sets_test_order_alpha
1035
+ def test_i_suck_and_my_tests_are_order_dependent_bang_sets_run_order_alpha
1068
1036
  @assertion_count = 0
1069
1037
 
1070
1038
  shitty_test_case = Class.new FakeNamedTest
1071
1039
 
1072
1040
  shitty_test_case.i_suck_and_my_tests_are_order_dependent!
1073
1041
 
1074
- assert_equal :alpha, shitty_test_case.test_order
1042
+ assert_equal :alpha, shitty_test_case.run_order
1075
1043
  end
1076
1044
 
1077
1045
  def test_i_suck_and_my_tests_are_order_dependent_bang_does_not_warn
@@ -1079,7 +1047,7 @@ class TestMinitestUnitTestCase < Minitest::Test
1079
1047
 
1080
1048
  shitty_test_case = Class.new FakeNamedTest
1081
1049
 
1082
- def shitty_test_case.test_order; :lol end
1050
+ def shitty_test_case.run_order; :lol end
1083
1051
 
1084
1052
  assert_silent do
1085
1053
  shitty_test_case.i_suck_and_my_tests_are_order_dependent!
@@ -1124,24 +1092,6 @@ class TestMinitestGuard < Minitest::Test
1124
1092
  assert self.jruby? "java"
1125
1093
  end
1126
1094
 
1127
- def test_rubinius_eh
1128
- assert_deprecation do
1129
- assert self.class.rubinius? "rbx"
1130
- end
1131
- assert_deprecation do
1132
- assert self.rubinius? "rbx"
1133
- end
1134
- end
1135
-
1136
- def test_maglev_eh
1137
- assert_deprecation do
1138
- assert self.class.maglev? "maglev"
1139
- end
1140
- assert_deprecation do
1141
- assert self.maglev? "maglev"
1142
- end
1143
- end
1144
-
1145
1095
  def test_osx_eh
1146
1096
  assert self.class.osx? "darwin"
1147
1097
  assert self.osx? "darwin"
@@ -1166,35 +1116,6 @@ class TestMinitestUnitRecording < MetaMetaMetaTestCase
1166
1116
  assert_equal expected, recorded
1167
1117
  end
1168
1118
 
1169
- def test_run_with_bogus_reporter
1170
- # https://github.com/seattlerb/minitest/issues/659
1171
- # TODO: remove test for minitest 6
1172
- @tu = Class.new FakeNamedTest do
1173
- def test_method
1174
- assert true
1175
- end
1176
- end
1177
-
1178
- bogus_reporter = Class.new do # doesn't subclass AbstractReporter
1179
- def start; @success = false; end
1180
- # def prerecord klass, name; end # doesn't define full API
1181
- def record _result; @success = true; end
1182
- def report; end
1183
- def passed?; end
1184
- def results; end
1185
- def success?; @success; end
1186
- end.new
1187
-
1188
- self.reporter = Minitest::CompositeReporter.new
1189
- reporter << bogus_reporter
1190
-
1191
- Minitest::Runnable.runnables.delete @tu
1192
-
1193
- @tu.run reporter, {}
1194
-
1195
- assert_predicate bogus_reporter, :success?
1196
- end
1197
-
1198
1119
  def test_record_passing
1199
1120
  assert_run_record do
1200
1121
  def test_method
@@ -0,0 +1,229 @@
1
+ require "minitest/autorun"
2
+ require "minitest/path_expander"
3
+
4
+ class TestPathExpander < Minitest::Test
5
+ attr_accessor :args
6
+ attr_accessor :expander
7
+
8
+ MT_VPE = Minitest::VendoredPathExpander
9
+
10
+ def setup
11
+ super
12
+
13
+ self.args = []
14
+
15
+ self.expander = MT_VPE.new args, "*.rb"
16
+
17
+ @pe_tmp_path = "test/pe_tmp"
18
+ @pe_tst_path = "test/pe_tmp/test"
19
+
20
+ @orig_pwd = Dir.pwd
21
+ FileUtils.mkdir_p @pe_tst_path
22
+ FileUtils.touch ["#{@pe_tst_path}/test_path_expander.rb", "#{@pe_tst_path}/test_bad.rb"]
23
+ Dir.chdir @pe_tmp_path
24
+ end
25
+
26
+ def teardown
27
+ super
28
+
29
+ Dir.chdir @orig_pwd
30
+
31
+ FileUtils.rm_rf @pe_tmp_path
32
+ end
33
+
34
+ def assert_filter_files exp, filter, files = %w[test/dog_and_cat.rb]
35
+ ignore = StringIO.new filter
36
+ act = expander.filter_files files, ignore
37
+ assert_equal exp, act
38
+ end
39
+
40
+ def assert_filter_files_absolute_paths exp, filter, files = [File.join(Dir.pwd, 'test/dog_and_cat.rb')]
41
+ assert_filter_files exp, filter, files
42
+ end
43
+
44
+ def assert_process_args exp_files, exp_args, *args
45
+ expander.args.concat args
46
+
47
+ assert_equal [exp_files.sort, exp_args], expander.process_args
48
+ end
49
+
50
+ def test_expand_dirs_to_files
51
+ exp = %w[test/test_bad.rb test/test_path_expander.rb]
52
+
53
+ assert_equal exp, expander.expand_dirs_to_files("test")
54
+ assert_equal %w[Rakefile], expander.expand_dirs_to_files("Rakefile")
55
+ end
56
+
57
+ def test_expand_dirs_to_files__sorting
58
+ exp = %w[test/test_bad.rb test/test_path_expander.rb]
59
+ input = %w[test/test_path_expander.rb test/test_bad.rb]
60
+
61
+ assert_equal exp, expander.expand_dirs_to_files(*input)
62
+ assert_equal %w[Rakefile], expander.expand_dirs_to_files("Rakefile")
63
+ end
64
+
65
+ def test_expand_dirs_to_files__leading_dot
66
+ exp = %w[test/test_bad.rb test/test_path_expander.rb]
67
+
68
+ assert_equal exp, expander.expand_dirs_to_files("./test")
69
+ end
70
+
71
+ def test_filter_files_dir
72
+ assert_filter_files [], "test/"
73
+ assert_filter_files_absolute_paths [], "test/"
74
+ end
75
+
76
+ def test_filter_files_files
77
+ example = %w[test/file.rb test/sub/file.rb top/test/perf.rb]
78
+ example_absolute_paths = example.map { |e| File.join(Dir.pwd, e) }
79
+
80
+ assert_filter_files [], "test/*.rb"
81
+
82
+ assert_filter_files example[1..-1], "test/*.rb", example
83
+
84
+ assert_filter_files_absolute_paths [], "test/*.rb"
85
+
86
+ assert_filter_files_absolute_paths example_absolute_paths[1..-1], "test/*.rb", example_absolute_paths
87
+ end
88
+
89
+ def test_filter_files_glob
90
+ assert_filter_files [], "test*"
91
+ assert_filter_files [], "test*", ["test/lib/woot.rb"]
92
+ assert_filter_files [], "*.rb"
93
+ assert_filter_files [], "*dog*.rb"
94
+
95
+ assert_filter_files_absolute_paths [], "test*"
96
+ assert_filter_files_absolute_paths [], "test*", [File.join(Dir.pwd, "test/lib/woot.rb")]
97
+ assert_filter_files_absolute_paths [], "*.rb"
98
+ assert_filter_files_absolute_paths [], "*dog*.rb"
99
+ end
100
+
101
+ def test_filter_files_glob_miss
102
+ miss = %w[test/dog_and_cat.rb]
103
+ miss_absolute = [File.join(Dir.pwd, 'test/dog_and_cat.rb')]
104
+
105
+ assert_filter_files miss, "test"
106
+ assert_filter_files miss, "nope"
107
+
108
+ assert_filter_files_absolute_paths miss_absolute, "test"
109
+ assert_filter_files_absolute_paths miss_absolute, "nope"
110
+ end
111
+
112
+ def test_filter_files__ignore_file
113
+ files = expander.expand_dirs_to_files "test"
114
+
115
+ File.write ".mtignore", "test/*.rb"
116
+
117
+ act = expander.filter_files files, ".mtignore"
118
+
119
+ assert_equal [], act
120
+ end
121
+
122
+ def test_process
123
+ self.args.concat %w[test --seed 42]
124
+
125
+ act = expander.process
126
+
127
+ assert_kind_of Enumerator, act
128
+ assert_equal %w[test/test_bad.rb test/test_path_expander.rb], act.to_a
129
+ assert_equal %w[--seed 42], expander.args
130
+ assert_equal %w[--seed 42], args # affected our original array (eg, ARGV)
131
+ end
132
+
133
+ def test_process__block
134
+ self.args.concat %w[test --seed 42]
135
+
136
+ act = []
137
+ result = expander.process { |x| act << x }
138
+
139
+ assert_same expander, result
140
+ assert_equal %w[test/test_bad.rb test/test_path_expander.rb], act.to_a
141
+ assert_equal %w[--seed 42], expander.args
142
+ assert_equal %w[--seed 42], args # affected our original array (eg, ARGV)
143
+ end
144
+
145
+ def with_tempfile *lines
146
+ require "tempfile"
147
+
148
+ Tempfile.open("tmp") do |f|
149
+ f.puts lines
150
+ f.flush
151
+ f.rewind
152
+
153
+ yield f
154
+ end
155
+ end
156
+
157
+ def test_process_args_at
158
+ with_tempfile %w[test -test/test_bad.rb --seed 24] do |f|
159
+ assert_process_args(%w[test/test_path_expander.rb],
160
+ %w[--seed 24],
161
+ "@#{f.path}")
162
+ end
163
+ end
164
+
165
+ def test_process_args_dash_dir
166
+ assert_process_args(%w[],
167
+ %w[],
168
+ "test", "-test")
169
+ end
170
+
171
+ def test_process_args_dash_file
172
+ assert_process_args(%w[test/test_path_expander.rb],
173
+ %w[],
174
+ "test", "-test/test_bad.rb")
175
+
176
+ end
177
+
178
+ def test_process_args_dash_other
179
+ assert_process_args(%w[],
180
+ %w[--verbose],
181
+ "--verbose")
182
+ end
183
+
184
+ def test_process_args_dir
185
+ assert_process_args(%w[test/test_bad.rb test/test_path_expander.rb],
186
+ %w[],
187
+ "test")
188
+ end
189
+
190
+ def test_process_args_file
191
+ assert_process_args(%w[test/test_path_expander.rb],
192
+ %w[],
193
+ "test/test_path_expander.rb")
194
+ end
195
+
196
+ def test_process_args_other
197
+ assert_process_args(%w[],
198
+ %w[42],
199
+ "42")
200
+ end
201
+
202
+ def test_process_args_root
203
+ assert_process_args(%w[],
204
+ %w[-n /./],
205
+ "-n",
206
+ "/./")
207
+ end
208
+
209
+ def test_process_args_no_files
210
+ self.expander = MT_VPE.new args, "*.rb", "test" # extra test default
211
+
212
+ assert_process_args(%w[test/test_bad.rb test/test_path_expander.rb],
213
+ %w[-v],
214
+ "-v")
215
+ end
216
+
217
+ def test_process_args_dash
218
+ assert_process_args(%w[-],
219
+ %w[-v],
220
+ "-", "-v")
221
+ end
222
+
223
+ def test_process_flags
224
+ exp = %w[a b c]
225
+ act = expander.process_flags %w[a b c]
226
+
227
+ assert_equal exp, act
228
+ end
229
+ end