我正在尝试使用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'
我该如何解决?
答案 0 :(得分:1)
不幸的是,这只是一个错误。它已得到修复,我还发布了一个带有更新示例的新版本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