January 2008
2 posts
5 tags
First Ruby Gem!!!
I’ve just created my first Ruby Gem out of the with_probability code I’ve been working on. Simply
sudo gem install nondeterminism
Much thanks also to the initial author of the Sometimes Pastie. Any problems with or suggestions for the gem? Join the Google Ruby-Nondeterminism Group.
4 tags
with_probability
In fuzzing my database for testing (see Fuzzing your Database and Faker), I’ve found the following to be very useful:
Object.class_eval do
def with_probability(prob, &block)
if rand <= prob
block.call
return ProbabilisticDoer::Done.new
else
return ProbabilisticDoer::NotDone.new
end
end
end
module ProbabilisticDoer
class NotDone
def...