我认为我遇到了rspec let和作用域的问题。我可以在示例中("it"块)使用let定义的方法,但无法在外部(describe块中的let所在位置)使用。
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)
如何将connection参数传递给it_behaves_like呢?