-
-
Notifications
You must be signed in to change notification settings - Fork 766
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
Shared context doesn't work with extended methods #2675
Comments
Can you please provide a bit more context of how you use that shared context? I'm not able to reproduce this behavior: module Foo
def something
puts 'hi'
end
end
RSpec.configure do |config|
config.extend Foo
end
RSpec.shared_context 'shared' do
something
end
RSpec.describe do
include_context 'shared'
it { }
end outputs:
|
I'll close this out for now and investigate what's wrong on my end then. Thanks for the response. Will report back when I figure it out. |
I think the problem happens when include context inside configure block: module Foo
def something
puts 'hi'
end
end
RSpec.configure do |config|
config.extend Foo
end
RSpec.shared_context 'shared' do
something
end
RSpec.configure do |config|
config.include_context 'shared', foo: :enabled
end
RSpec.describe "Foo", foo: :enabled do
it { }
end outputs:
|
@pirj I’ve reopened the issue since @tubaxenor provided the failing example. |
Thanks for the reproduction example. It makes sense to extend first, and include after. Can you think of a good example when a module would need something that is defined in the shared context? You can try with swapping the lines 1513 and 1514 and see if some specs/features fail. Do you want to carefully tackle the problem? |
reprodocue issue rspec#2675
Subject of the issue
Methods that were injected via
config.extend(...)
are not defined when called within shared contexts.Your environment
Steps to reproduce
Expected behavior
Prints 'hi'
Actual behavior
something
is undefinedThe text was updated successfully, but these errors were encountered: