【发布时间】:2015-07-22 00:02:35
【问题描述】:
我在某个类中有这段代码,顺便说一句,这是带有测试/单元的普通 ruby,不涉及 Rails:
10 %w[["y",true],["n",false]].each do |r, state|
11 def must_continue_to_ask_for_input_until_given_yes_or_no
12
13 provide_input(r)
14
15 assert_equal state, @questioner.ask(@question)
16 end
17 end
在 vim 编辑器中使用 !ruby % 运行它时,我收到此错误:
Line 13, NameError: undefined local variable or method `r' for #<QuestionerTest:0x007fe931981fd0>
QuestionerTest 是我的类,它派生自
Class QuestionerTest <Test::Unit::TestCase
环境:
Ruby 2.2.1 on MACOSX Mavericks
No rails involved
test/unit involved
【问题讨论】:
标签: ruby macos exception nameerror