@@ -17,9 +17,17 @@ def as_commandline(ops)
17
17
18
18
def capture_exec ( *ops )
19
19
ops << { err : [ :child , :out ] }
20
- io = IO . popen ( ops )
20
+ lines = [ ]
21
+
22
+ _process =
23
+ IO . popen ( ops ) do |io |
24
+ while ( line = io . gets )
25
+ lines << line
26
+ end
27
+ end
28
+
21
29
# Necessary to ignore warnings from Rails code base
22
- out = io . readlines
30
+ out = lines
23
31
. reject { |line | line =~ /warning: circular argument reference/ }
24
32
. reject { |line | line =~ /Gem::Specification#rubyforge_project=/ }
25
33
. reject { |line | line =~ /DEPRECATION WARNING/ }
@@ -30,12 +38,32 @@ def capture_exec(*ops)
30
38
CaptureExec . new ( out , $?. exitstatus )
31
39
end
32
40
33
- def have_no_preview
34
- have_attributes ( io : be_blank , exit_status : 0 )
41
+ if ENV [ 'RAILS_VERSION' ] == 'main' && Rails ::VERSION ::STRING == "7.2.0.alpha"
42
+ before do
43
+ skip ( 'This is broken on Rails main but is skipped for green builds of 7.1.x, please fix' )
44
+ end
35
45
end
36
46
37
- before do
38
- skip ( "Currently broken for unknown reasons" )
47
+ if Rails ::VERSION ::STRING . to_f >= 7.1
48
+ let ( :expected_custom_path ) { "/custom/path\n #{ ::Rails . root } /test/mailers/previews" }
49
+ let ( :expected_rspec_path ) { "#{ ::Rails . root } /spec/mailers/previews\n #{ ::Rails . root } /test/mailers/previews" }
50
+
51
+ def have_no_preview ( opts = { } )
52
+ expected_io =
53
+ if opts [ :actually_blank ]
54
+ be_blank
55
+ else
56
+ "#{ ::Rails . root } /test/mailers/previews"
57
+ end
58
+ have_attributes ( io : expected_io , exit_status : 0 )
59
+ end
60
+ else
61
+ let ( :expected_custom_path ) { '/custom/path' }
62
+ let ( :expected_rspec_path ) { "#{ ::Rails . root } /spec/mailers/previews" }
63
+
64
+ def have_no_preview ( _opts = { } )
65
+ have_attributes ( io : be_blank , exit_status : 0 )
66
+ end
39
67
end
40
68
41
69
let ( :exec_script ) {
@@ -49,9 +77,7 @@ def have_no_preview
49
77
50
78
it 'sets the preview path to the default rspec path' do
51
79
skip "this spec fails singularly on JRuby due to weird env things" if RUBY_ENGINE == "jruby"
52
- expect ( capture_exec ( custom_env , exec_script ) ) . to eq (
53
- "#{ ::Rails . root } /spec/mailers/previews"
54
- )
80
+ expect ( capture_exec ( custom_env , exec_script ) ) . to eq ( expected_rspec_path )
55
81
end
56
82
57
83
it 'respects the setting from `show_previews`' do
@@ -69,7 +95,7 @@ def have_no_preview
69
95
custom_env . merge ( 'CUSTOM_PREVIEW_PATH' => '/custom/path' ) ,
70
96
exec_script
71
97
)
72
- ) . to eq ( '/custom/path' )
98
+ ) . to eq ( expected_custom_path )
73
99
end
74
100
75
101
it 'allows initializers to set options' do
@@ -87,7 +113,7 @@ def have_no_preview
87
113
custom_env . merge ( 'NO_ACTION_MAILER' => 'true' ) ,
88
114
exec_script
89
115
)
90
- ) . to have_no_preview
116
+ ) . to have_no_preview ( actually_blank : true )
91
117
end
92
118
end
93
119
@@ -102,7 +128,7 @@ def have_no_preview
102
128
it 'respects the setting from `show_previews`' do
103
129
expect (
104
130
capture_exec ( custom_env . merge ( 'SHOW_PREVIEWS' => 'true' ) , exec_script )
105
- ) . to eq ( " #{ :: Rails . root } /spec/mailers/previews" )
131
+ ) . to eq ( expected_rspec_path )
106
132
end
107
133
108
134
it 'allows initializers to set options' do
0 commit comments