Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Backport let!()

  • Loading branch information...
commit 12b172d640000b1f973f63f2ce8fd8a073f8f252 1 parent 9d8f4f8
@cgriego cgriego authored committed
View
5 lib/spec/example/example_group_methods.rb
@@ -172,6 +172,11 @@ def let(name, &block)
end
end
+ def let!(name, &block)
+ let(name, &block)
+ before { __send__(name) }
+ end
+
private
def subclass(*args, &example_group_block)
View
19 spec/spec/example/example_group_methods_spec.rb
@@ -753,6 +753,25 @@ def count
counter.count.should == 2
end
end
+
+ describe "#let!" do
+ let!(:creator) do
+ class Creator
+ @count = 0
+ def self.count
+ @count += 1
+ end
+ end
+ end
+
+ it "evaluates the value non-lazily" do
+ lambda { Creator.count }.should_not raise_error
+ end
+
+ it "does not interfere between tests" do
+ Creator.count.should == 1
+ end
+ end
end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.