Skip to content

Commit fe22555

Browse files
authored
Merge pull request #2026 from cupakromer/fix-nomethoderror-pathname-fixture-path
Fix `NoMethodError` for `Pathname` fixture paths
2 parents 2d94bbe + 6b46d7a commit fe22555

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Enhancements:
1818

1919
Bug Fixes:
2020

21+
* Fix `NoMethodError: undefined method 'strip'` when using a `Pathname` object
22+
as the fixture file path. (Aaron Kromer, #2026)
2123
* Escape quotation characters when producing method names for system spec
2224
screenshots. (Shane Cavanaugh, #1955)
2325
* Use relative path for resolving fixtures when `fixture_path` is not set.

lib/rspec/rails/fixture_file_upload_support.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module FixtureFileUploadSupport
88

99
def rails_fixture_file_wrapper
1010
RailsFixtureFileWrapper.fixture_path = nil
11-
resolved_fixture_path = (fixture_path || RSpec.configuration.fixture_path || '')
11+
resolved_fixture_path = (fixture_path || RSpec.configuration.fixture_path || '').to_s
1212
RailsFixtureFileWrapper.fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
1313
RailsFixtureFileWrapper.instance
1414
end

spec/rspec/rails/fixture_file_upload_support_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ module RSpec::Rails
77
RSpec.configuration.fixture_path = File.dirname(__FILE__)
88
expect(fixture_file_upload_resolved('fixture_file_upload_support_spec.rb').run).to be true
99
end
10+
11+
it 'resolves supports `Pathname` objects' do
12+
RSpec.configuration.fixture_path = Pathname(File.dirname(__FILE__))
13+
expect(fixture_file_upload_resolved('fixture_file_upload_support_spec.rb').run).to be true
14+
end
1015
end
1116

1217
context 'with fixture path set in spec' do

0 commit comments

Comments
 (0)