-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Namespaced worlds cannot access each other #1627
Comments
Hi there. Perfect repro scenario and perfect documentation. I guess you've asked the million dollar question. Should you be able to do this. I've worked on cucumber for years, and rarely if ever use namespaced worlds. As usually my world is reasonably thin / I use ruby namespacing. So my "gut" says we shouldn't allow world transversal. But this is only my opinion.... We definitely need more eyes on this first. EDIT: You mentioned they were objects but nil objects. The fact the methods do return an object suggests partial code paths. Imo these should probably error. |
Looking back at this, I think my answer to the question would be no. Ultimately the point of a namespaced world is to provide some logical organisation of test state, which should remain roughly independent from other state. As such, the idea of some shared world which others can access feels a bit antithetical. I would support a patch to ensure that a world simply cannot observe any others, meaning that in a setup like... module Foo
def observe_bar
bar
end
end
module Bar
end
World(foo: Foo, bar: Bar) then |
Ideally it should probably raise an NME as it should have no context if completely isolated. But yes, glad we're on the same page. Next step, find some time to work on this. I can definitely pick this up part time in the coming month, but other than that no idea how tricky it is. |
👓 What did you see?
Constructed a pair of namespaced worlds, in which one internally used the other to manage some common resources. Both worlds were observed to be defined and non-
nil
within test steps. Within each world instance however, the other world were observed to be defined, butnil
.✅ What did you expect to see?
Expected either:
📦 Which tool/library version are you using?
🔬 How could we reproduce it?
📚 Any additional context?
This issue arose while looking at factoring out common behaviours from some namespaced worlds to one consolidated spot. The intent was to have all of the other worlds access the common world to get access to the shared behaviour. This appeared to be a valid refactoring, since with non-namespaced worlds, each world is able to access the other methods introduced by the others.
There does not appear to be any documentation indicating that this should or should not be possible.
This text was originally generated from a template, then edited by hand. You can modify the template here.
The text was updated successfully, but these errors were encountered: