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

Commit b5f2431

Browse files
committed
Move definition of implicit subject.
This is in prep for changing when the LetDefinitions module is included. The use of `subject` from the `included` hook was causing problems when I was trying to do that.
1 parent d16ee78 commit b5f2431

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

lib/rspec/core/memoized_helpers.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,12 @@ module MemoizedHelpers
4545
#
4646
# @see #should
4747
def subject
48-
raise NotImplementedError, 'This definition is here for documentation purposes only'
49-
' - it is overriden anyway below when this module gets included.'
48+
__memoized.fetch(:subject) do
49+
__memoized[:subject] = begin
50+
described = described_class || self.class.description
51+
Class === described ? described.new : described
52+
end
53+
end
5054
end
5155

5256
# When `should` is called with no explicit receiver, the call is
@@ -148,12 +152,6 @@ def preserve_accessed_lets
148152

149153
def self.included(mod)
150154
mod.extend(ClassMethods)
151-
152-
# This logic defines an implicit subject
153-
mod.subject do
154-
described = described_class || self.class.description
155-
Class === described ? described.new : described
156-
end
157155
end
158156

159157
module ClassMethods

0 commit comments

Comments
 (0)