Skip to content
Browse files

use `define_method` instead of `let` for named subject

`subject` already memoizes the value
  • Loading branch information...
1 parent 0592aca commit f87dfbfabf7b816c9d68d6417c8ba946ecb999cb @dchelimsky dchelimsky committed Jun 3, 2012
Showing with 1 addition and 2 deletions.
  1. +0 −1 lib/rspec/core/let.rb
  2. +1 −1 lib/rspec/core/subject.rb
View
1 lib/rspec/core/let.rb
@@ -105,7 +105,6 @@ def self.included(mod)
mod.extend ExampleGroupMethods
mod.__send__ :include, ExampleMethods
end
-
end
end
end
View
2 lib/rspec/core/subject.rb
@@ -193,7 +193,7 @@ def its(attribute, &block)
# @see ExampleMethods#subject
# @see ExampleMethods#should
def subject(name=nil, &block)
- let(name) { subject } if name
+ define_method(name) { subject } if name
block ? @explicit_subject_block = block : explicit_subject || implicit_subject
end

0 comments on commit f87dfbf

Please sign in to comment.
Something went wrong with that request. Please try again.