Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

extract Let and supporting methods to separate module

  • Loading branch information...
commit a17d693ee06eef1a68a7d49f4cb57e5dcfc1c13f 1 parent d0b3159
@dchelimsky dchelimsky authored
View
1  lib/rspec/core.rb
@@ -1,4 +1,5 @@
require 'rspec/core/load_path'
+require 'rspec/core/let'
require 'rspec/core/deprecation'
require 'rspec/core/mocking/with_absolutely_nothing'
require 'rspec/core/around_proxy'
View
11 lib/rspec/core/example_group.rb
@@ -7,6 +7,7 @@ module Core
class ExampleGroup
extend Advice
include ExampleGroupSubject
+ include Let
attr_accessor :running_example
@@ -200,12 +201,6 @@ def self.to_s
self == Rspec::Core::ExampleGroup ? 'Rspec::Core::ExampleGroup' : name
end
- def self.let(name, &block)
- define_method(name) do
- __memoized[name] ||= instance_eval(&block)
- end
- end
-
def self.all_apply?(filters)
metadata.all_apply?(filters)
end
@@ -214,10 +209,6 @@ def described_class
self.class.describes
end
- def __memoized
- @__memoized ||= {}
- end
-
def __reset__
instance_variables.each { |ivar| remove_instance_variable(ivar) }
__memoized.clear
View
28 lib/rspec/core/let.rb
@@ -0,0 +1,28 @@
+module Rspec
+ module Core
+
+ module Let
+
+ module ClassMethods
+ def let(name, &block)
+ define_method(name) do
+ __memoized[name] ||= instance_eval(&block)
+ end
+ end
+ end
+
+ module InstanceMethods
+ def __memoized
+ @__memoized ||= {}
+ end
+ end
+
+ def self.included(mod)
+ mod.extend ClassMethods
+ mod.__send__ :include, InstanceMethods
+ end
+
+ end
+
+ end
+end
Please sign in to comment.
Something went wrong with that request. Please try again.