Skip to content

Stop using globally exposed DSL #2420

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

Merged
merged 3 commits into from
Dec 22, 2020
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
5 changes: 4 additions & 1 deletion lib/rspec/rails/extensions/active_record/proxy.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
RSpec.configure do |rspec|
# Delay this in order to give users a chance to configure `expect_with`...
rspec.before(:suite) do
if defined?(RSpec::Matchers) && RSpec::Matchers.configuration.syntax.include?(:should) && defined?(ActiveRecord::Associations)
if defined?(RSpec::Matchers) &&
RSpec::Matchers.configuration.respond_to?(:syntax) && # RSpec 4 dropped support for monkey-patching `should` syntax
RSpec::Matchers.configuration.syntax.include?(:should) &&
defined?(ActiveRecord::Associations)
RSpec::Matchers.configuration.add_should_and_should_not_to ActiveRecord::Associations::CollectionProxy
end
end
Expand Down
3 changes: 2 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ def self.run_all(reporter = nil)

config.shared_context_metadata_behavior = :apply_to_host_groups

config.disable_monkey_patching!
# Zero monkey patching mode is the default and only mode in RSpec 4
config.disable_monkey_patching! if config.respond_to?(:disable_monkey_patching!)

config.warnings = true
config.raise_on_warning = true
Expand Down
4 changes: 2 additions & 2 deletions spec/support/generators.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.included(klass)
klass.include(RSpec::Rails::FeatureCheck)
end

shared_examples_for 'a model generator with fixtures' do |name, class_name|
RSpec.shared_examples_for 'a model generator with fixtures' do |name, class_name|
before { run_generator [name, '--fixture'] }

describe 'the spec' do
Expand All @@ -38,7 +38,7 @@ def self.included(klass)
end
end

shared_examples_for "a request spec generator" do
RSpec.shared_examples_for "a request spec generator" do
describe 'generated with flag `--no-request-specs`' do
before do
run_generator %w[posts --no-request-specs]
Expand Down
2 changes: 1 addition & 1 deletion spec/support/shared_examples.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'pathname'

shared_examples_for "an rspec-rails example group mixin" do |type, *paths|
RSpec.shared_examples_for "an rspec-rails example group mixin" do |type, *paths|
Copy link
Member Author

Choose a reason for hiding this comment

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

It seems that we require spec support files before RSpec.configure, and Core::DSL.expose_globally! was taking precedence. Interesting.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds about right

let(:mixin) { described_class }

def define_group_in(path, group_definition)
Expand Down