我正在尝试使用 FuzzBert,但我无法使随机生成器工作。
此示例来自官方存储库 :
require 'fuzzbert'
fuzz "Web App" do
deploy do |data|
#send JSON data via HTTP
end
data "template" do
t = FuzzBert::Template.new <<-EOS
{ user: { id: ${id}, name: "${name}" } }
EOS
t.set(:id) { FuzzBert::Generators.cycle(1..10000) }
t.set(:name) { FuzzBert::Generators.random }
t.generator
end
end
当我运行它(fuzzbert myfile.rb)时,我遇到了这个错误:
fuzzbert-1.0.1/lib/fuzzbert/template.rb:17:in `block (2 levels) in to_data': can't convert Proc into String (TypeError)
我试过撬解释器,我有同样的错误:
> t = FuzzBert::Template.new '{ user: { name: "${name}" } }'
> t.set(:name) { FuzzBert::Generators.random }
> t.to_data
TypeError: can't convert Proc into String
from /home/you/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/fuzzbert-1.0.1/lib/fuzzbert/template.rb:17:in `block (2 levels) in to_data'
我该如何解决?