module RSpec::Core::Let::ClassMethods

def let(name, &block)

end
end
thing.should be_something
# second invocation, returns the memoized value

thing.do_something
# first invocation, executes block, memoizes and returns result
it "does something" do

let(:thing) { Thing.new }
describe Thing do

== Examples

after the first call.
Generates a method whose return value is memoized
def let(name, &block)
  define_method(name) do
    __memoized[name] ||= instance_eval(&block)
  end
end

def let!(name, &block)

end
end
end
Thing.count.should == 1
thing
it "returns memoized version on first invocation" do

end
Thing.count.should == 1
it "is invoked implicitly" do

let!(:thing) { Thing.new }
context "using let!" do

end
end
Thing.count.should == 1
thing
it "can be invoked explicitly" do

end
Thing.count.should == 0
it "is not invoked implicitly" do

let(:thing) { Thing.new }
context "using let" do

after(:each) { Thing.reset_count }
describe Thing do

end
end
self.class.count += 1
def initialize

end
@count = 0
def self.reset_count

end
@count += val
def self.count=(val)

end
@count ||= 0
def self.count
class Thing

== Examples

reference to that state.
purpose of setting up state and providing a memoized
by an implicit before hook. This serves a dual
Just like let(), except the block is invoked
def let!(name, &block)
  let(name, &block)
  before { __send__(name) }
end