1
上下文較小的代碼示例再次問這個問題:如何創建早該宏
# this is a dummy shoulda macro that creates a context
def self.macro_context
context "macro" do
yield
end
end
# i am expecting this test to fail within the macro context
context "some context" do
macro_context do
should "test" do
fail
end
end
end
那麼我希望是看到:
1) Error:
test: some context macro context should test. (TestClassName)
但我只得到了這一點:
那麼我希望是看到:
1) Error:
test: some context should test. (TestClassName)
任何想法我做錯了什麼?
唯一的區別似乎是merge_block調用,我沒有看到過,它是做什麼的? – Honza 2010-04-26 09:32:56
正如其名稱所示,它會將您傳遞的塊與您調用'merge_block'的塊合併。在你的情況下,它會將給定的塊合併到「context」活動用戶登錄的「do ... end」中 – Fran 2010-04-26 13:48:27