0
我試圖做類似如下:Shoulda:如何在設置之外使用實例變量或應該阻止?
@special_attributes = Model.new.methods.select # a special subset
@special_attributes.each do |attribute|
context "A model with #{attribute}" do
setup do
@model = Model.new
end
should "respond to it by name" do
assert_respond_to @model, attribute
end
end
end
然而,@special_attributes超出範圍運行單元測試時,留下我與第2行nil對象我想不出在哪裏/如何定義它以將其納入範圍。有什麼想法嗎?