Skip to content

Commit 71a5751

Browse files
committed
Add missing deprecated method
1 parent 50b82bc commit 71a5751

File tree

3 files changed

+51
-15
lines changed

3 files changed

+51
-15
lines changed

lib/rspec/rails/configuration.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,18 @@ def filter_rails_from_backtrace!
166166

167167
# @deprecated TestFixtures#fixture_path is deprecated and will be removed in Rails 7.2
168168
if ::Rails::VERSION::STRING >= "7.1.0"
169+
def fixture_path
170+
RSpec.deprecate(
171+
"config.fixture_path",
172+
replacement: "config.fixture_paths",
173+
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array"
174+
)
175+
fixture_paths&.first
176+
end
177+
169178
def fixture_path=(path)
170179
RSpec.deprecate(
171-
"config.fixture_path = #{path.inspect}",
180+
"config.fixture_path = #{path.inspect}",
172181
replacement: "config.fixture_paths = [#{path.inspect}]",
173182
message: "Rails 7.1 has deprecated the singular fixture_path in favour of an array"
174183
)

spec/rspec/rails/configuration_spec.rb

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,21 +161,47 @@ def in_inferring_type_from_location_environment
161161
include_examples "infers type from location", :feature, "spec/features"
162162
end
163163

164-
if ::Rails::VERSION::STRING < "7.1.0"
165-
it "fixture support is included with metadata `:use_fixtures`" do
166-
in_sub_process do
167-
RSpec.configuration.global_fixtures = [:foo]
168-
RSpec.configuration.fixture_path = "custom/path"
164+
it "fixture support is included with metadata `:use_fixtures`" do
165+
in_sub_process do
166+
a_hash = an_instance_of(Hash)
167+
if ::Rails::VERSION::STRING >= "7.1.0"
168+
expect(RSpec).to receive(:deprecate).with("config.fixture_path = \"custom/path\"", a_hash)
169+
end
169170

170-
group = RSpec.describe("Arbitrary Description", :use_fixtures)
171+
RSpec.configuration.global_fixtures = [:foo]
172+
RSpec.configuration.fixture_path = "custom/path"
171173

172-
expect(group).to respond_to(:fixture_path)
173-
expect(group.fixture_path).to eq("custom/path")
174+
group = RSpec.describe("Arbitrary Description", :use_fixtures)
174175

175-
expect(group.new.respond_to?(:foo, true)).to be(true)
176+
expect(group).to respond_to(:fixture_path)
177+
178+
if ::Rails::VERSION::STRING >= "7.1.0"
179+
with_isolated_stderr { expect(group.fixture_path).to eq("custom/path") }
180+
else
181+
expect(group.fixture_path).to eq("custom/path")
176182
end
183+
184+
expect(group.new.respond_to?(:foo, true)).to be(true)
185+
end
186+
end
187+
188+
if ::Rails::VERSION::STRING >= "7.1.0"
189+
it "deprecates fixture_path" do
190+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, "config.fixture_path")
191+
RSpec.configuration.fixture_path
192+
193+
RSpec.configuration.fixture_paths = []
194+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, "config.fixture_path")
195+
RSpec.configuration.fixture_path
177196
end
178-
else
197+
198+
it "deprecates fixture_path =" do
199+
expect_deprecation_with_call_site(__FILE__, __LINE__ + 1, /config.fixture_path =/)
200+
RSpec.configuration.fixture_path = "some path"
201+
202+
expect(RSpec.configuration.fixture_paths).to eq(["some path"])
203+
end
204+
179205
it "fixture support is included with metadata `:use_fixtures` and fixture_paths configured" do
180206
in_sub_process do
181207
RSpec.configuration.global_fixtures = [:foo]

spec/rspec/rails/fixture_support_spec.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ module RSpec::Rails
77
include FixtureSupport
88
end
99

10-
if ::Rails::VERSION::STRING < "7.1.0"
11-
expect(group).to respond_to(:fixture_path)
12-
expect(group).to respond_to(:fixture_path=)
13-
else
10+
# These are deprecated when Rails is 7.1.0 or above
11+
expect(group).to respond_to(:fixture_path)
12+
expect(group).to respond_to(:fixture_path=)
13+
14+
if ::Rails::VERSION::STRING >= "7.1.0"
1415
expect(group).to respond_to(:fixture_paths)
1516
expect(group).to respond_to(:fixture_paths=)
1617
end

0 commit comments

Comments
 (0)