|
3 | 3 | module RSpec::Rails
|
4 | 4 | describe FixtureFileUploadSupport do
|
5 | 5 | context 'with fixture path set in config' do
|
6 |
| - before { RSpec.configuration.fixture_path = File.dirname(__FILE__) } |
7 |
| - |
8 | 6 | it 'resolves fixture file' do
|
9 |
| - expect(fixture_file_upload_resolved.run).to be true |
| 7 | + RSpec.configuration.fixture_path = File.dirname(__FILE__) |
| 8 | + expect(fixture_file_upload_resolved('fixture_file_upload_support_spec.rb').run).to be true |
10 | 9 | end
|
11 | 10 | end
|
12 | 11 |
|
13 | 12 | context 'with fixture path set in spec' do
|
14 | 13 | it 'resolves fixture file' do
|
15 |
| - expect(fixture_file_upload_resolved(File.dirname(__FILE__)).run).to be true |
| 14 | + expect(fixture_file_upload_resolved('fixture_file_upload_support_spec.rb', File.dirname(__FILE__)).run).to be true |
| 15 | + end |
| 16 | + end |
| 17 | + |
| 18 | + context 'with fixture path not set' do |
| 19 | + it 'resolves fixture using relative path' do |
| 20 | + RSpec.configuration.fixture_path = nil |
| 21 | + expect(fixture_file_upload_resolved('spec/rspec/rails/fixture_file_upload_support_spec.rb').run).to be true |
16 | 22 | end
|
17 | 23 | end
|
18 | 24 |
|
19 |
| - def fixture_file_upload_resolved(fixture_path = nil) |
| 25 | + def fixture_file_upload_resolved(fixture_name, fixture_path = nil) |
20 | 26 | RSpec::Core::ExampleGroup.describe do
|
21 | 27 | include RSpec::Rails::FixtureFileUploadSupport
|
22 | 28 |
|
23 |
| - self.fixture_path = fixture_path if fixture_path |
| 29 | + self.fixture_path = fixture_path |
24 | 30 |
|
25 | 31 | it 'supports fixture file upload' do
|
26 |
| - file = fixture_file_upload(File.basename(__FILE__)) |
| 32 | + file = fixture_file_upload(fixture_name) |
27 | 33 | expect(file.read).to match(/describe FixtureFileUploadSupport/im)
|
28 | 34 | end
|
29 | 35 | end
|
|
0 commit comments