@@ -30,12 +30,26 @@ def capture_exec(*ops)
30
30
CaptureExec . new ( out , $?. exitstatus )
31
31
end
32
32
33
- def have_no_preview
34
- have_attributes ( io : be_blank , exit_status : 0 )
35
- end
33
+ if Rails ::VERSION ::STRING . start_with? ( '7.1' )
34
+ let ( :expected_custom_path ) { "/custom/path\n #{ ::Rails . root } /test/mailers/previews" }
35
+ let ( :expected_rspec_path ) { "#{ ::Rails . root } /spec/mailers/previews\n #{ ::Rails . root } /test/mailers/previews" }
36
+
37
+ def have_no_preview ( opts = { } )
38
+ expected_io =
39
+ if opts [ :actually_blank ]
40
+ be_blank
41
+ else
42
+ "#{ ::Rails . root } /test/mailers/previews"
43
+ end
44
+ have_attributes ( io : expected_io , exit_status : 0 )
45
+ end
46
+ else
47
+ let ( :expected_custom_path ) { '/custom/path' }
48
+ let ( :expected_rspec_path ) { "#{ ::Rails . root } /spec/mailers/previews" }
36
49
37
- before do
38
- skip ( "Currently broken for unknown reasons" )
50
+ def have_no_preview ( _opts = { } )
51
+ have_attributes ( io : be_blank , exit_status : 0 )
52
+ end
39
53
end
40
54
41
55
let ( :exec_script ) {
@@ -49,9 +63,7 @@ def have_no_preview
49
63
50
64
it 'sets the preview path to the default rspec path' do
51
65
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
- )
66
+ expect ( capture_exec ( custom_env , exec_script ) ) . to eq ( expected_rspec_path )
55
67
end
56
68
57
69
it 'respects the setting from `show_previews`' do
@@ -69,7 +81,7 @@ def have_no_preview
69
81
custom_env . merge ( 'CUSTOM_PREVIEW_PATH' => '/custom/path' ) ,
70
82
exec_script
71
83
)
72
- ) . to eq ( '/custom/path' )
84
+ ) . to eq ( expected_custom_path )
73
85
end
74
86
75
87
it 'allows initializers to set options' do
@@ -87,7 +99,7 @@ def have_no_preview
87
99
custom_env . merge ( 'NO_ACTION_MAILER' => 'true' ) ,
88
100
exec_script
89
101
)
90
- ) . to have_no_preview
102
+ ) . to have_no_preview ( actually_blank : true )
91
103
end
92
104
end
93
105
@@ -102,7 +114,7 @@ def have_no_preview
102
114
it 'respects the setting from `show_previews`' do
103
115
expect (
104
116
capture_exec ( custom_env . merge ( 'SHOW_PREVIEWS' => 'true' ) , exec_script )
105
- ) . to eq ( " #{ :: Rails . root } /spec/mailers/previews" )
117
+ ) . to eq ( expected_rspec_path )
106
118
end
107
119
108
120
it 'allows initializers to set options' do
0 commit comments