似乎我在 Minitest/spec 上找不到太多文档,所以我想知道是否有人可以帮助我弄清楚如何做我需要做的事情。基本上我想在我的所有类和模块上运行测试,以确保它们 1.)如果是静态或 2,则输出正确的值类型。)在 to_symbols 的情况下,所有键都是符号。这是我到目前为止所尝试的:
我认为小黄瓜会是什么样子:
Given binns
When the version method is called
then the return should be a float
and version should be a method or constant
我认为它会是 minitest/spec:
require 'minitest/autorun'
require 'minitest/spec'
require 'binns'
given Binns do
when "the version method is called" do
then "the return should be a float" do
# Do work
end
end
end
但我得到:
syntax error, unexpected keyword_when (SyntaxError)
when "the version method is called" do
^
注意:我也对其他测试建议持开放态度(我对黄瓜不太了解,听说它很重要)或者如果有人有书籍建议,请告诉我一直在寻找一本关于 Ruby 单元测试的好书.