1
1
class FileChangesTest < Minitest ::Test
2
+ include FileHelper
3
+ include OutputHelper
4
+ include CommandHelper
5
+
2
6
def setup
3
7
@command = 'retest'
4
8
end
@@ -10,7 +14,7 @@ def teardown
10
14
def test_start_retest
11
15
launch_retest @command
12
16
13
- assert_match <<~EXPECTED , @output . read
17
+ assert_match <<~EXPECTED , read_output
14
18
Launching Retest...
15
19
Ready to refactor! You can make file changes now
16
20
EXPECTED
@@ -21,25 +25,29 @@ def test_modifying_existing_file
21
25
22
26
modify_file ( 'lib/bundler_app/bottles.rb' )
23
27
24
- assert_match "Test file: test/bundler_app/test_bottles.rb" , @output . read
25
- assert_match "12 runs, 12 assertions, 0 failures, 0 errors, 0 skips" , @output . read
28
+ read_output do |output |
29
+ assert_match "Test file: test/bundler_app/test_bottles.rb" , output
30
+ assert_match "12 runs, 12 assertions, 0 failures, 0 errors, 0 skips" , output
31
+ end
26
32
end
27
33
28
34
def test_modifying_existing_test_file
29
35
launch_retest @command
30
36
31
37
modify_file ( 'test/bundler_app/test_bottles.rb' )
32
38
33
- assert_match "Test file: test/bundler_app/test_bottles.rb" , @output . read
34
- assert_match "12 runs, 12 assertions, 0 failures, 0 errors, 0 skips" , @output . read
39
+ read_output do |output |
40
+ assert_match "Test file: test/bundler_app/test_bottles.rb" , output
41
+ assert_match "12 runs, 12 assertions, 0 failures, 0 errors, 0 skips" , output
42
+ end
35
43
end
36
44
37
45
def test_creating_a_new_test_file
38
46
launch_retest @command
39
47
40
48
create_file 'test/bundler_app/test_foo.rb'
41
49
42
- assert_match "Test file: test/bundler_app/test_foo.rb" , @output . read
50
+ assert_match "Test file: test/bundler_app/test_foo.rb" , read_output
43
51
44
52
ensure
45
53
delete_file 'test/bundler_app/test_foo.rb'
@@ -49,18 +57,18 @@ def test_creating_a_new_file
49
57
launch_retest @command
50
58
51
59
create_file 'lib/bundler_app/foo.rb'
52
- assert_match <<~EXPECTED , @output . read
60
+ assert_match <<~EXPECTED , read_output
53
61
FileNotFound - Retest could not find a matching test file to run.
54
62
EXPECTED
55
63
56
64
create_file 'test/bundler_app/test_foo.rb'
57
- assert_match "Test file: test/bundler_app/test_foo.rb" , @output . read
65
+ assert_match "Test file: test/bundler_app/test_foo.rb" , read_output
58
66
59
67
modify_file ( 'lib/bundler_app/bottles.rb' )
60
- assert_match "Test file: test/bundler_app/test_bottles.rb" , @output . read
68
+ assert_match "Test file: test/bundler_app/test_bottles.rb" , read_output
61
69
62
70
modify_file ( 'lib/bundler_app/foo.rb' )
63
- assert_match "Test file: test/bundler_app/test_foo.rb" , @output . read
71
+ assert_match "Test file: test/bundler_app/test_foo.rb" , read_output
64
72
65
73
ensure
66
74
delete_file 'lib/bundler_app/foo.rb'
@@ -74,7 +82,7 @@ def test_untracked_file
74
82
launch_retest @command
75
83
76
84
modify_file 'lib/bundler_app/foo.rb'
77
- assert_match "Test file: test/bundler_app/test_foo.rb" , @output . read
85
+ assert_match "Test file: test/bundler_app/test_foo.rb" , read_output
78
86
79
87
ensure
80
88
delete_file 'lib/bundler_app/foo.rb'
0 commit comments