Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Deal with circular relationship between world and config #2185

Merged
merged 2 commits into from
Mar 3, 2016

Conversation

myronmarston
Copy link
Member

RSpec::World#initialize references RSpec.configuration
and RSpec::Configuration references RSpec.world in a few
places. This circular dependency is not ideal and has triggered
infinite recursion during some recent changes I've tried to make.
It would be nice to get rid of it entirely, but for now, this is
the simplest change I can make it solve my immediate problems.

Some config methods use `RSpec.world` and have problems if `RSpec.world`
has not been defined yet. So it's best to wait to configure anything
until `RSpec` is defined.
@myronmarston myronmarston force-pushed the world-configuration-circular branch from fcf9a77 to d53df3a Compare March 3, 2016 06:46
@myronmarston myronmarston changed the title [WIP] Deal with circular relationship between world and config Deal with circular relationship between world and config Mar 3, 2016
`RSpec::World#initialize` references `RSpec.configuration`
and `RSpec::Configuration` references `RSpec.world` in a few
places. This circular dependency is not ideal and has triggered
infinite recursion during some recent changes I've tried to make.
It would be nice to get rid of it entirely, but for now, this is
the simplest change I can make it solve my immediate problems.
@myronmarston myronmarston force-pushed the world-configuration-circular branch from d53df3a to fc0e6b5 Compare March 3, 2016 07:14
@@ -178,4 +177,7 @@ def self.const_missing(name)
require MODULES_TO_AUTOLOAD.fetch(name) { return super }
::RSpec.const_get(name)
end

Core::DSL.expose_globally!
Core::SharedExampleGroup::TopLevelDSL.expose_globally!
Copy link
Member

Choose a reason for hiding this comment

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

Whilst I get that this is to prevent configuration being loaded prematurely, feels a bit like duplication :/

Copy link
Member Author

Choose a reason for hiding this comment

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

The loading and using of configuration in this file was causing problems for me and the config.expose_dsl_globally = true doesn't set any state in config so this seemed like the simplest solution. Do you have a suggested alternative that doesn't involve reverting to config.expose_dsl_globally = true?

Copy link
Member

Choose a reason for hiding this comment

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

No, and I think this is better than adding a new method.

JonRowe added a commit that referenced this pull request Mar 3, 2016
Deal with circular relationship between world and config
@JonRowe JonRowe merged commit 6b8257d into master Mar 3, 2016
@JonRowe JonRowe deleted the world-configuration-circular branch March 3, 2016 23:19
@JonRowe
Copy link
Member

JonRowe commented Mar 3, 2016

LGTM

MatheusRich pushed a commit to MatheusRich/rspec-core that referenced this pull request Oct 30, 2020
Deal with circular relationship between world and config
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants