【发布时间】:2012-12-23 03:59:01
【问题描述】:
我正在同时学习 Ruby 和 TDD (rspec)。
我写了以下测试:
describe is_eligible do
it "returns true if the passed in string is not part of a list" do
result = is_eligible("abc")
result.should eq(false)
end
end
正在测试以下代码:
def is_eligible(team_name)
array = Array.new
array << "abc" << "def" << "ghi"
if array.include?(team_name)
return false
else
return true
end
end
我收到以下错误,但找不到原因。
*/Users/joel.dehlin/top32/lib/ineligible_teams.rb:6:in `is_eligible':参数数量错误(0 代表 1)(ArgumentError)*
感谢任何帮助!
【问题讨论】:
-
顺便说一句,为了测试真假值,最好使用
.should be_true或should be_false。