Skip to content

Commit

Permalink
Merge pull request #2026 from cupakromer/fix-nomethoderror-pathname-f…
Browse files Browse the repository at this point in the history
…ixture-path

Fix `NoMethodError` for `Pathname` fixture paths
  • Loading branch information
JonRowe committed Oct 23, 2018
1 parent 124c82a commit 8ae77c1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
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

0 comments on commit 8ae77c1

Please sign in to comment.