Skip to content

Reduce sandboxing to prevent swallowed deprecations #2857

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion spec/rspec/rails/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
end
end

describe "#infer_spec_type_from_file_location!" do
describe "#infer_spec_type_from_file_location!", :with_isolated_config do
def in_inferring_type_from_location_environment
in_sub_process do
RSpec.configuration.infer_spec_type_from_file_location!
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/channel_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "rspec/rails/feature_check"

module RSpec::Rails
RSpec.describe ChannelExampleGroup do
RSpec.describe ChannelExampleGroup, :with_isolated_config do
if RSpec::Rails::FeatureCheck.has_action_cable_testing?
it_behaves_like "an rspec-rails example group mixin", :channel,
'./spec/channels/', '.\\spec\\channels\\'
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/controller_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ def self.abstract?; false; end
end

module RSpec::Rails
RSpec.describe ControllerExampleGroup do
RSpec.describe ControllerExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :controller,
'./spec/controllers/', '.\\spec\\controllers\\'

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/feature_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe FeatureExampleGroup do
RSpec.describe FeatureExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :feature,
'./spec/features/', '.\\spec\\features\\'

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/helper_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe HelperExampleGroup do
RSpec.describe HelperExampleGroup, :with_isolated_config do
module ::FoosHelper
class InternalClass
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/job_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe JobExampleGroup do
RSpec.describe JobExampleGroup, :with_isolated_config do
if defined?(ActiveJob)
it_behaves_like "an rspec-rails example group mixin", :job,
'./spec/jobs/', '.\\spec\\jobs\\'
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/mailbox_example_group_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def receive(*)

module RSpec
module Rails
RSpec.describe MailboxExampleGroup, skip: !RSpec::Rails::FeatureCheck.has_action_mailbox? do
RSpec.describe MailboxExampleGroup, :with_isolated_config, skip: !RSpec::Rails::FeatureCheck.has_action_mailbox? do
it_behaves_like "an rspec-rails example group mixin", :mailbox,
'./spec/mailboxes/', '.\\spec\\mailboxes\\'

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/mailer_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe MailerExampleGroup do
RSpec.describe MailerExampleGroup, :with_isolated_config do
module ::Rails; end
before do
allow(Rails).to receive_message_chain(:application, :routes, :url_helpers).and_return(Rails)
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/model_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe ModelExampleGroup do
RSpec.describe ModelExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :model,
'./spec/models/', '.\\spec\\models\\'
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/rails_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe RailsExampleGroup do
RSpec.describe RailsExampleGroup, :with_isolated_config do
it 'supports tagged_logger' do
expect(described_class.private_instance_methods).to include(:tagged_logger)
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/request_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe RequestExampleGroup do
RSpec.describe RequestExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :request,
'./spec/requests/', '.\\spec\\requests\\',
'./spec/integration/', '.\\spec\\integration\\',
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/routing_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe RoutingExampleGroup do
RSpec.describe RoutingExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :routing,
'./spec/routing/', '.\\spec\\routing\\'

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/system_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe SystemExampleGroup do
RSpec.describe SystemExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :system,
'./spec/system/', '.\\spec\\system\\'

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/example/view_example_group_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'support/group_failure_formatter'

module RSpec::Rails
RSpec.describe ViewExampleGroup do
RSpec.describe ViewExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :view,
'./spec/views/', '.\\spec\\views\\'

Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/fixture_file_upload_support_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe FixtureFileUploadSupport do
RSpec.describe FixtureFileUploadSupport, :with_isolated_config do
context 'with fixture paths set in config' do
it 'resolves fixture file' do
RSpec.configuration.fixture_paths = [File.dirname(__FILE__)]
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/fixture_support_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe FixtureSupport do
RSpec.describe FixtureSupport, :with_isolated_config do
context "with use_transactional_fixtures set to false" do
it "still supports fixture_path/fixture_paths" do
allow(RSpec.configuration).to receive(:use_transactional_fixtures) { false }
Expand Down
1 change: 1 addition & 0 deletions spec/rspec/rails/matchers/have_http_status_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ def create_response(opts = {})

context 'with deprecated rack status codes' do
it 'supports the original names' do
allow(Rack::Utils).to receive(:warn).with(/unprocessable_entity is deprecated/, anything)
expect(create_response(status: 422)).to have_http_status(:unprocessable_entity)
end
end
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/minitest_lifecycle_adapter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe RSpec::Rails::MinitestLifecycleAdapter do
RSpec.describe RSpec::Rails::MinitestLifecycleAdapter, :with_isolated_config do
it "invokes minitest lifecycle hooks at the appropriate times" do
invocations = []
example_group = RSpec::Core::ExampleGroup.describe("MinitestHooks") do
Expand Down
2 changes: 1 addition & 1 deletion spec/rspec/rails/setup_and_teardown_adapter_spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
RSpec.describe RSpec::Rails::SetupAndTeardownAdapter do
RSpec.describe RSpec::Rails::SetupAndTeardownAdapter, :with_isolated_config do
describe ".setup" do
it "registers before hooks in the order setup is received" do
group = RSpec::Core::ExampleGroup.describe do
Expand Down
4 changes: 2 additions & 2 deletions spec/rspec/rails/view_rendering_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module RSpec::Rails
RSpec.describe ViewRendering do
RSpec.describe ViewRendering, :with_isolated_config do
let(:group) do
RSpec::Core::ExampleGroup.describe do
def controller
Expand Down Expand Up @@ -53,7 +53,7 @@ def example.controller
expect(group.new.render_views?).to be_falsey
end

it "overrides the global config if render_views is enabled there" do
it "overrides the global config if render_views is enabled there", :with_isolated_config do
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doubled up no?

allow(RSpec.configuration).to receive(:render_views?).and_return true
group.render_views false
expect(group.new.render_views?).to be_falsey
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,11 @@ def self.run_all(reporter = nil)
config.warnings = true
config.raise_on_warning = true

config.raise_errors_for_deprecations!

# Execute a provided block with RSpec global objects (configuration,
# world, current example) reset. This is used to test specs with RSpec.
config.around(:example) do |example|
config.around(:example, :with_isolated_config) do |example|
RSpec::Core::Sandbox.sandboxed do |sandbox_config|
# If there is an example-within-an-example, we want to make sure the inner
# example does not get a reference to the outer example (the real spec) if
Expand Down
Loading