Skip to content

Commit 5a549a9

Browse files
committed
Merge pull request #2664 from nsimmons/fix-deprecated-fixture_path
Fix deprecated TestFixtures#fixture_path call
1 parent 602a338 commit 5a549a9

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

lib/rspec/rails/fixture_support.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ def run_in_transaction?
2121
if RSpec.configuration.use_active_record?
2222
include Fixtures
2323

24-
self.fixture_path = RSpec.configuration.fixture_path
24+
# TestFixtures#fixture_path is deprecated and will be removed in Rails 7.2
25+
if respond_to?(:fixture_paths=)
26+
fixture_paths << RSpec.configuration.fixture_path
27+
else
28+
self.fixture_path = RSpec.configuration.fixture_path
29+
end
2530
self.use_transactional_tests = RSpec.configuration.use_transactional_fixtures
2631
self.use_instantiated_fixtures = RSpec.configuration.use_instantiated_fixtures
2732

spec/rspec/rails/configuration_spec.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,14 @@ def in_inferring_type_from_location_environment
164164

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

167-
expect(group).to respond_to(:fixture_path)
168-
expect(group.fixture_path).to eq("custom/path")
167+
if ::Rails::VERSION::STRING < '7.1.0'
168+
expect(group).to respond_to(:fixture_path)
169+
expect(group.fixture_path).to eq("custom/path")
170+
else
171+
expect(group).to respond_to(:fixture_paths)
172+
expect(group.fixture_paths).to include("custom/path")
173+
end
174+
169175
expect(group.new.respond_to?(:foo, true)).to be(true)
170176
end
171177
end

0 commit comments

Comments
 (0)