@@ -17,9 +17,17 @@ def as_commandline(ops)
1717
1818 def capture_exec ( *ops )
1919 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+
2129 # Necessary to ignore warnings from Rails code base
22- out = io . readlines
30+ out = lines
2331 . reject { |line | line =~ /warning: circular argument reference/ }
2432 . reject { |line | line =~ /Gem::Specification#rubyforge_project=/ }
2533 . reject { |line | line =~ /DEPRECATION WARNING/ }
@@ -30,12 +38,32 @@ def capture_exec(*ops)
3038 CaptureExec . new ( out , $?. exitstatus )
3139 end
3240
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
3545 end
3646
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
3967 end
4068
4169 let ( :exec_script ) {
@@ -49,9 +77,7 @@ def have_no_preview
4977
5078 it 'sets the preview path to the default rspec path' do
5179 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 )
5581 end
5682
5783 it 'respects the setting from `show_previews`' do
@@ -69,7 +95,7 @@ def have_no_preview
6995 custom_env . merge ( 'CUSTOM_PREVIEW_PATH' => '/custom/path' ) ,
7096 exec_script
7197 )
72- ) . to eq ( '/custom/path' )
98+ ) . to eq ( expected_custom_path )
7399 end
74100
75101 it 'allows initializers to set options' do
@@ -87,7 +113,7 @@ def have_no_preview
87113 custom_env . merge ( 'NO_ACTION_MAILER' => 'true' ) ,
88114 exec_script
89115 )
90- ) . to have_no_preview
116+ ) . to have_no_preview ( actually_blank : true )
91117 end
92118 end
93119
@@ -102,7 +128,7 @@ def have_no_preview
102128 it 'respects the setting from `show_previews`' do
103129 expect (
104130 capture_exec ( custom_env . merge ( 'SHOW_PREVIEWS' => 'true' ) , exec_script )
105- ) . to eq ( " #{ :: Rails . root } /spec/mailers/previews" )
131+ ) . to eq ( expected_rspec_path )
106132 end
107133
108134 it 'allows initializers to set options' do
0 commit comments