@@ -16,12 +16,8 @@ def as_commandline(ops)
16
16
end
17
17
18
18
def capture_exec ( *ops )
19
- io = if RUBY_VERSION . to_f < 1.9
20
- IO . popen ( as_commandline ( ops ) )
21
- else
22
- ops << { :err => [ :child , :out ] }
23
- IO . popen ( ops )
24
- end
19
+ ops << { :err => [ :child , :out ] }
20
+ io = IO . popen ( ops )
25
21
# Necessary to ignore warnings from Rails code base
26
22
out = io . readlines .
27
23
reject { |line | line =~ /warning: circular argument reference/ } .
@@ -39,7 +35,7 @@ def have_no_preview
39
35
File . expand_path ( File . join ( __FILE__ , '../support/default_preview_path' ) )
40
36
}
41
37
42
- if RSpec ::Rails ::FeatureCheck . has_action_mailer_show_preview ?
38
+ if RSpec ::Rails ::FeatureCheck . has_action_mailer_preview ?
43
39
context 'in the development environment' do
44
40
let ( :custom_env ) { { 'RAILS_ENV' => rails_env } }
45
41
let ( :rails_env ) { 'development' }
@@ -111,71 +107,6 @@ def have_no_preview
111
107
) . to eq ( 'test-host' )
112
108
end
113
109
114
- it 'handles action mailer not being available' do
115
- expect (
116
- capture_exec (
117
- custom_env . merge ( 'NO_ACTION_MAILER' => 'true' ) ,
118
- exec_script
119
- )
120
- ) . to have_no_preview
121
- end
122
- end
123
- elsif RSpec ::Rails ::FeatureCheck . has_action_mailer_preview?
124
- context 'in the development environment' , 'without `show_previews`' do
125
- let ( :custom_env ) { { 'RAILS_ENV' => rails_env } }
126
- let ( :rails_env ) { 'development' }
127
-
128
- it 'sets the preview path to the default rspec path' do
129
- expect ( capture_exec ( custom_env , exec_script ) ) . to eq (
130
- "#{ ::Rails . root } /spec/mailers/previews"
131
- )
132
- end
133
-
134
- it 'respects a custom `preview_path`' do
135
- expect (
136
- capture_exec (
137
- custom_env . merge ( 'CUSTOM_PREVIEW_PATH' => '/custom/path' ) ,
138
- exec_script
139
- )
140
- ) . to eq ( '/custom/path' )
141
- end
142
-
143
- it 'allows initializers to set options' do
144
- expect (
145
- capture_exec (
146
- custom_env . merge ( 'DEFAULT_URL' => 'test-host' ) ,
147
- exec_script
148
- )
149
- ) . to eq ( 'test-host' )
150
- end
151
-
152
- it 'handles action mailer not being available' do
153
- expect (
154
- capture_exec (
155
- custom_env . merge ( 'NO_ACTION_MAILER' => 'true' ) ,
156
- exec_script
157
- )
158
- ) . to have_no_preview
159
- end
160
- end
161
-
162
- context 'in a non-development environment' , 'without `show_previews`' do
163
- let ( :custom_env ) { { 'RAILS_ENV' => rails_env } }
164
- let ( :rails_env ) { 'test' }
165
-
166
- it 'does not set the preview path by default' do
167
- expect ( capture_exec ( custom_env , exec_script ) ) . to have_no_preview
168
- end
169
-
170
- it 'respects a custom `preview_path`' do
171
- expect (
172
- capture_exec (
173
- custom_env . merge ( 'CUSTOM_PREVIEW_PATH' => '/custom/path' ) ,
174
- exec_script
175
- )
176
- ) . to eq ( '/custom/path' )
177
- end
178
-
179
110
it 'handles action mailer not being available' do
180
111
expect (
181
112
capture_exec (
0 commit comments