我相信我有rspec let和範圍的問題。我可以使用let實例中定義的方法(「it」塊),但不能在外面(我所做的描述塊)。Rspec讓範圍
5 describe Connection do
8 let(:connection) { described_class.new(connection_settings) }
9
10 it_behaves_like "any connection", connection
24 end
當我嘗試運行這個天賦,我得到的錯誤:
connection_spec.rb:10: undefined local variable or method `connection' for Class:0xae8e5b8 (NameError)
如何傳遞連接參數的it_behaves_like?
RSpec monkeypatch'new'做到這一點嗎? – 2011-04-10 23:13:42