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

Update changelog and cleanup comments #938

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
### DEv
### Dev

Enhancements

* Clean up some internal use of Enumerable methods. (Vipul A M)

Bug fixes

* Refactor memoized helpers (let, subject, named subject) to use an internalised
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As an American, I'd usually spell this "internalized" but given that we have you and @samphippen on the team now this is fine :).

method name to avoid conflict with outside methods. Avoids complex ordering
issues with `LetDefinitions` module. See #908 #817 #871 rspec/rspec-rails#738 .
(Andy Lindeman, Jon Rowe)

### 2.14.0.rc1 / 2013-05-27
[full changelog](http://github.com/rspec/rspec-core/compare/v2.13.1...v2.14.0.rc1)

Expand Down
8 changes: 4 additions & 4 deletions lib/rspec/core/memoized_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,14 @@ def self.memoized_method_name_for(name, let_or_subject)

# @api private
def self.define_memoized_method(example_group, name, memoized_method_name, &block)
# We have to pass the block directly to `define_method` to
# allow it to use method constructs like `super` and `return`.
raise "#let or #subject called without a block" if block.nil?

MemoizedHelpers.module_for(example_group).__send__(:define_method, memoized_method_name, &block)
# We have to pass the block directly to `define_method` to
# allow it to use method constructs like `super` and `return`.
module_for(example_group).__send__(:define_method, memoized_method_name, &block)

# Apply the memoization. The method has been defined in an ancestor
# module so we can use `super` here to get the value.
# module so we can use the decorated name here to get the value.
example_group.__send__(:define_method, name) do
__memoized.fetch(name) { |k| __memoized[k] = send(memoized_method_name, &nil) }
end
Expand Down
1 change: 1 addition & 0 deletions spec/rspec/core/memoized_helpers_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ def define_and_run_group
context "when included modules have hooks that define memoized helpers" do
it "allows memoized helpers to override methods in previously included modules" do
group = ExampleGroup.describe do
# this replicates the ordering scenario that breaks in #817
include Module.new {
def self.included(m); m.let(:unrelated) { :unrelated }; end
}
Expand Down