File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ module FixtureFileUploadSupport
8
8
9
9
def rails_fixture_file_wrapper
10
10
resolved_fixture_path = ( fixture_path || RSpec . configuration . fixture_path || '' )
11
- RailsFixtureFileWrapper . fixture_path = File . join ( resolved_fixture_path , '' )
11
+ RailsFixtureFileWrapper . fixture_path = File . join ( resolved_fixture_path , '' ) unless resolved_fixture_path . strip . empty?
12
12
RailsFixtureFileWrapper . instance
13
13
end
14
14
@@ -18,7 +18,7 @@ class RailsFixtureFileWrapper
18
18
class << self
19
19
attr_reader :fixture_path
20
20
21
- # Get the instance of wrapper
21
+ # Get instance of wrapper
22
22
def instance
23
23
@instance ||= new
24
24
end
Original file line number Diff line number Diff line change @@ -6,24 +6,32 @@ module RSpec::Rails
6
6
before { RSpec . configuration . fixture_path = File . dirname ( __FILE__ ) }
7
7
8
8
it 'resolves fixture file' do
9
- expect ( fixture_file_upload_resolved . run ) . to be true
9
+ expect ( fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' ) . run ) . to be true
10
10
end
11
11
end
12
12
13
13
context 'with fixture path set in spec' do
14
14
it 'resolves fixture file' do
15
- expect ( fixture_file_upload_resolved ( File . dirname ( __FILE__ ) ) . run ) . to be true
15
+ expect ( fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' , File . dirname ( __FILE__ ) ) . run ) . to be true
16
16
end
17
17
end
18
18
19
- def fixture_file_upload_resolved ( fixture_path = nil )
19
+ context 'with fixture path not set' do
20
+ before { RSpec . configuration . fixture_path = nil }
21
+
22
+ it 'resolves fixture with relative path' do
23
+ expect ( fixture_file_upload_resolved ( 'fixture_file_upload_support_spec.rb' ) . run ) . to be true
24
+ end
25
+ end
26
+
27
+ def fixture_file_upload_resolved ( fixture_name , fixture_path = nil )
20
28
RSpec ::Core ::ExampleGroup . describe do
21
29
include RSpec ::Rails ::FixtureFileUploadSupport
22
30
23
31
self . fixture_path = fixture_path if fixture_path
24
32
25
33
it 'supports fixture file upload' do
26
- file = fixture_file_upload ( File . basename ( __FILE__ ) )
34
+ file = fixture_file_upload ( fixture_name )
27
35
expect ( file . read ) . to match ( /describe FixtureFileUploadSupport/im )
28
36
end
29
37
end
You can’t perform that action at this time.
0 commit comments