@@ -3,33 +3,43 @@ module RSpec::Rails
3
3
context 'with fixture path set in config' do
4
4
it 'resolves fixture file' do
5
5
RSpec . configuration . fixture_path = File . dirname ( __FILE__ )
6
- expect ( fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' ) . run ) . to be true
6
+ expect_to_pass fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' )
7
7
end
8
8
9
9
it 'resolves supports `Pathname` objects' do
10
10
RSpec . configuration . fixture_path = Pathname ( File . dirname ( __FILE__ ) )
11
- expect ( fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' ) . run ) . to be true
11
+ expect_to_pass fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' )
12
12
end
13
13
end
14
14
15
15
context 'with fixture path set in spec' do
16
16
it 'resolves fixture file' do
17
- expect ( fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' , File . dirname ( __FILE__ ) ) . run ) . to be true
17
+ expect_to_pass fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' , File . dirname ( __FILE__ ) )
18
18
end
19
19
end
20
20
21
21
context 'with fixture path not set' do
22
22
it 'resolves fixture using relative path' do
23
23
RSpec . configuration . fixture_path = nil
24
- expect ( fixture_file_upload_resolved ( 'spec/rspec/rails/fixture_file_upload_support_spec.rb' ) . run ) . to be true
24
+ expect_to_pass fixture_file_upload_resolved ( 'spec/rspec/rails/fixture_file_upload_support_spec.rb' )
25
25
end
26
26
end
27
27
28
+ def expect_to_pass ( group )
29
+ result = group . run ( failure_reporter )
30
+ failure_reporter . exceptions . map { |e | raise e }
31
+ expect ( result ) . to be true
32
+ end
33
+
28
34
def fixture_file_upload_resolved ( fixture_name , fixture_path = nil )
29
35
RSpec ::Core ::ExampleGroup . describe do
30
36
include RSpec ::Rails ::FixtureFileUploadSupport
31
37
32
- self . fixture_path = fixture_path
38
+ if ::Rails . version . to_f >= 6.1
39
+ self . file_fixture_path = fixture_path
40
+ else
41
+ self . fixture_path = fixture_path
42
+ end
33
43
34
44
it 'supports fixture file upload' do
35
45
file = fixture_file_upload ( fixture_name )
0 commit comments