Skip to content

Commit

Permalink
Merge pull request #2664 from nsimmons/fix-deprecated-fixture_path
Browse files Browse the repository at this point in the history
Fix deprecated TestFixtures#fixture_path call
  • Loading branch information
JonRowe committed May 4, 2023
1 parent 602a338 commit 5a549a9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
7 changes: 6 additions & 1 deletion lib/rspec/rails/fixture_support.rb
Expand Up @@ -21,7 +21,12 @@ def run_in_transaction?
if RSpec.configuration.use_active_record?
include Fixtures

self.fixture_path = RSpec.configuration.fixture_path
# TestFixtures#fixture_path is deprecated and will be removed in Rails 7.2
if respond_to?(:fixture_paths=)
fixture_paths << RSpec.configuration.fixture_path
else
self.fixture_path = RSpec.configuration.fixture_path
end
self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures

Expand Down
10 changes: 8 additions & 2 deletions spec/rspec/rails/configuration_spec.rb
Expand Up @@ -164,8 +164,14 @@ def in_inferring_type_from_location_environment

group = RSpec.describe("Arbitrary Description", :use_fixtures)

expect(group).to respond_to(:fixture_path)
expect(group.fixture_path).to eq("custom/path")
if ::Rails::VERSION::STRING < '7.1.0'
expect(group).to respond_to(:fixture_path)
expect(group.fixture_path).to eq("custom/path")
else
expect(group).to respond_to(:fixture_paths)
expect(group.fixture_paths).to include("custom/path")
end

expect(group.new.respond_to?(:foo, true)).to be(true)
end
end
Expand Down

0 comments on commit 5a549a9

Please sign in to comment.