gpt4 book ai didi

Ruby, FuzzBert, 无法将 Proc 转换为 String (TypeError)

转载 作者:行者123 更新时间:2023-11-28 20:44:59 24 4
gpt4 key购买 nike

我正在尝试使用 FuzzBert,但我无法让随机生成器工作。

这个例子来自official repository :

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)

我试过 pry 解释器,但我遇到了同样的错误:

> 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'

我该如何解决?

最佳答案

不幸的是,这只是一个错误。它已被修复,我还发布了带有更新示例的新版本 1.0.3。上面的例子现在可以写成

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

关于Ruby, FuzzBert, 无法将 Proc 转换为 String (TypeError),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15228007/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com