Skip to content

Fix NoMethodError for Pathname fixture paths #2026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Enhancements:

Bug Fixes:

* Fix `NoMethodError: undefined method 'strip'` when using a `Pathname` object
as the fixture file path. (Aaron Kromer, #2026)
* Escape quotation characters when producing method names for system spec
screenshots. (Shane Cavanaugh, #1955)
* Use relative path for resolving fixtures when `fixture_path` is not set.
Expand Down
2 changes: 1 addition & 1 deletion lib/rspec/rails/fixture_file_upload_support.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module FixtureFileUploadSupport

def rails_fixture_file_wrapper
RailsFixtureFileWrapper.fixture_path = nil
resolved_fixture_path = (fixture_path || RSpec.configuration.fixture_path || '')
resolved_fixture_path = (fixture_path || RSpec.configuration.fixture_path || '').to_s
RailsFixtureFileWrapper.fixture_path = File.join(resolved_fixture_path, '') unless resolved_fixture_path.strip.empty?
RailsFixtureFileWrapper.instance
end
Expand Down
5 changes: 5 additions & 0 deletions spec/rspec/rails/fixture_file_upload_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ module RSpec::Rails
RSpec.configuration.fixture_path = File.dirname(__FILE__)
expect(fixture_file_upload_resolved('fixture_file_upload_support_spec.rb').run).to be true
end

it 'resolves supports `Pathname` objects' do
RSpec.configuration.fixture_path = Pathname(File.dirname(__FILE__))
expect(fixture_file_upload_resolved('fixture_file_upload_support_spec.rb').run).to be true
end
end

context 'with fixture path set in spec' do
Expand Down