Skip to content

Commit

Permalink
Delay inclusion of LetDefinitions module.
Browse files Browse the repository at this point in the history
It needs to be included last so that its definitions can take precedence
in case of a name collision.
  • Loading branch information
myronmarston committed Jun 10, 2013
1 parent b5f2431 commit a43d59d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 7 additions & 0 deletions lib/rspec/core/example_group.rb
Expand Up @@ -237,6 +237,13 @@ def self.subclass(parent, args, &example_group_block)
subclass = Class.new(parent)
subclass.set_it_up(*args)
subclass.module_eval(&example_group_block) if example_group_block

# The LetDefinitions module must be included _after_ other modules
# to ensure that it takes precendence when there are name collisions.
# Thus, we delay including it until after the example group block
# has been eval'd.
subclass.send(:include, MemoizedHelpers.module_for(subclass))

subclass
end

Expand Down
1 change: 0 additions & 1 deletion lib/rspec/core/memoized_helpers.rb
Expand Up @@ -469,7 +469,6 @@ def self.module_for(example_group)
}
end

example_group.__send__(:include, mod)
example_group.const_set(:LetDefinitions, mod)
mod
end
Expand Down

0 comments on commit a43d59d

Please sign in to comment.