Skip to content
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

Remove calls to fixture_path on main #2738

Merged
merged 1 commit into from
Feb 23, 2024
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
52 changes: 39 additions & 13 deletions spec/rspec/rails/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,26 +161,52 @@ def in_inferring_type_from_location_environment
include_examples "infers type from location", :feature, "spec/features"
end

it "fixture support is included with metadata `:use_fixtures`" do
in_sub_process do
a_hash = an_instance_of(Hash)
if ::Rails::VERSION::STRING >= "7.1.0"
expect(RSpec).to receive(:deprecate).with("config.fixture_path = \"custom/path\"", a_hash)
end

if ::Rails::VERSION::STRING >= "7.2.0"
it "fixture support is included with metadata `:use_fixtures`" do
RSpec.configuration.global_fixtures = [:foo]
RSpec.configuration.fixture_path = "custom/path"
RSpec.configuration.fixture_paths = ["custom/path"]

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

expect(group).to respond_to(:fixture_path)
expect(group.fixture_paths).to eq(["custom/path"])

if ::Rails::VERSION::STRING >= "7.1.0"
with_isolated_stderr { expect(group.fixture_path).to eq("custom/path") }
else
expect(group.fixture_path).to eq("custom/path")
expect(group.new.respond_to?(:foo, true)).to be(true)
end
elsif ::Rails::VERSION::STRING >= "7.1.0"
it "fixture support is included with metadata `:use_fixtures`" do
in_sub_process do
a_hash = an_instance_of(Hash)
if ::Rails::VERSION::STRING >= "7.1.0"
expect(RSpec).to receive(:deprecate).with("config.fixture_path = \"custom/path\"", a_hash)
end

RSpec.configuration.global_fixtures = [:foo]
RSpec.configuration.fixture_path = "custom/path"

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

if ::Rails::VERSION::STRING <= "7.2.0"
expect(group).to respond_to(:fixture_path)
end

if ::Rails::VERSION::STRING >= "7.1.0"
with_isolated_stderr { expect(group.fixture_path).to eq("custom/path") }
else
expect(group.fixture_path).to eq("custom/path")
end

expect(group.new.respond_to?(:foo, true)).to be(true)
end
end
else
it "fixture support is included with metadata `:use_fixtures`" do
RSpec.configuration.global_fixtures = [:foo]
RSpec.configuration.fixture_path = "custom/path"

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

expect(group).to respond_to(:fixture_path)
expect(group.fixture_path).to eq("custom/path")
expect(group.new.respond_to?(:foo, true)).to be(true)
end
end
Expand Down
16 changes: 11 additions & 5 deletions spec/rspec/rails/fixture_support_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ module RSpec::Rails
include FixtureSupport
end

# These are deprecated when Rails is 7.1.0 or above
expect(group).to respond_to(:fixture_path)
expect(group).to respond_to(:fixture_path=)

if ::Rails::VERSION::STRING >= "7.1.0"
if ::Rails::VERSION::STRING >= "7.2.0"
expect(group).to respond_to(:fixture_paths)
expect(group).to respond_to(:fixture_paths=)
elsif ::Rails::VERSION::STRING >= "7.1.0"
expect(group).to respond_to(:fixture_paths)
expect(group).to respond_to(:fixture_paths=)

# These are deprecated when Rails is 7.1.0 but still exist
expect(group).to respond_to(:fixture_path)
expect(group).to respond_to(:fixture_path=)
else
expect(group).to respond_to(:fixture_path)
expect(group).to respond_to(:fixture_path=)
end
end
end
Expand Down