Skip to content

Commit fd00f38

Browse files
committed
Prep for removal of fixture support globally.
This adds metadata to ad-hoc include fixture support for any examples or groups which may require it. It additionally, includes fixture support into all default `RailsExampleGroup` modules. This provides the current functionality for the majority of use cases.
1 parent b81f6de commit fd00f38

File tree

3 files changed

+17
-3
lines changed

3 files changed

+17
-3
lines changed

lib/rspec/rails/configuration.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,10 @@ def self.initialize_configuration(config)
6565
config.add_setting :use_instantiated_fixtures
6666
config.add_setting :global_fixtures
6767
config.add_setting :fixture_path
68+
config.include RSpec::Rails::FixtureSupport, :use_fixtures
6869

69-
# TODO: We'll need to create a deprecated module in order to properly
70-
# report to gems / projects which are relying on this being loaded
71-
# globally.
70+
# We'll need to create a deprecated module in order to properly report to
71+
# gems / projects which are relying on this being loaded globally.
7272
#
7373
# See rspec/rspec-rails#1355 for history
7474
#

lib/rspec/rails/example/rails_example_group.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ module RailsExampleGroup
1111
include RSpec::Rails::MinitestLifecycleAdapter if ::Rails::VERSION::STRING >= '4'
1212
include RSpec::Rails::MinitestAssertionAdapter
1313
include RSpec::Rails::Matchers
14+
include RSpec::Rails::FixtureSupport
1415
end
1516
end
1617
end

spec/rspec/rails/configuration_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,19 @@ def in_inferring_type_from_location_environment
133133
include_examples "infers type from location", :feature, "spec/features"
134134
end
135135

136+
it "fixture support is included with metadata `:use_fixtures`" do
137+
in_sub_process do
138+
RSpec.configuration.global_fixtures = [:foo]
139+
RSpec.configuration.fixture_path = "custom/path"
140+
141+
group = RSpec.describe("Arbitrary Description", :use_fixtures)
142+
143+
expect(group).to respond_to(:fixture_path)
144+
expect(group.fixture_path).to eq("custom/path")
145+
expect(group.new.respond_to?(:foo, true)).to be(true)
146+
end
147+
end
148+
136149
it "metadata `:type => :controller` sets up controller example groups" do
137150
a_controller_class = Class.new
138151
stub_const "SomeController", a_controller_class

0 commit comments

Comments
 (0)