Skip to content

Commit

Permalink
Merge pull request #2738 from rspec/fix-fixture-builds-main
Browse files Browse the repository at this point in the history
Remove calls to fixture_path on main
  • Loading branch information
JonRowe committed Feb 23, 2024
1 parent f3d9d63 commit 0db50e9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 18 deletions.
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

0 comments on commit 0db50e9

Please sign in to comment.