【发布时间】:2011-03-08 08:31:30
【问题描述】:
我经常想做
context "empty stack" do
SOME_CONSTANT = "value"
it "should be empty" do
# use SOME_CONSTANT
end
end
context "populated stack" do
SOME_CONSTANT = "a different value"
it "should have some items" do
# use SOME_CONSTANT
end
end
ruby 不会将常量限定为闭包,因此它们会泄漏。有没有人有一个技巧来声明一个上下文范围内的常量?
【问题讨论】: