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

Commit a43d59d

Browse files
committed
Delay inclusion of LetDefinitions module.
It needs to be included last so that its definitions can take precedence in case of a name collision.
1 parent b5f2431 commit a43d59d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/rspec/core/example_group.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,13 @@ def self.subclass(parent, args, &example_group_block)
237237
subclass = Class.new(parent)
238238
subclass.set_it_up(*args)
239239
subclass.module_eval(&example_group_block) if example_group_block
240+
241+
# The LetDefinitions module must be included _after_ other modules
242+
# to ensure that it takes precendence when there are name collisions.
243+
# Thus, we delay including it until after the example group block
244+
# has been eval'd.
245+
subclass.send(:include, MemoizedHelpers.module_for(subclass))
246+
240247
subclass
241248
end
242249

lib/rspec/core/memoized_helpers.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ def self.module_for(example_group)
469469
}
470470
end
471471

472-
example_group.__send__(:include, mod)
473472
example_group.const_set(:LetDefinitions, mod)
474473
mod
475474
end

0 commit comments

Comments
 (0)