Live data from Hacker News

Show HN: PBT – A property-based testing library for Ruby

github.com

31–37 of 37 posts

Re: Show HN: PBT – A property-based testing library for Ruby

#31

Earlier quoted context omitted.

Ruby just simply isn’t the glue language winner because of the heavy emphasis on rails. From a systems perspective, I had to switch to python because it has pyroute2, which supports rtnl, devlink, ethtool and more. I would have thought ruby had a full-fledged netlink library right now considering the stability of chef and puppet. But all I could find was this from 8 years ago: https://github.com/BytemarkHosting/netli…

> I wish it was all ruby Why do you not wish it was all Python?

I’d say simply because of language preference

Re: Show HN: PBT – A property-based testing library for Ruby

#33

Interesting! I wonder how this could be applied to a Rails project (since that's what ruby is most used for). For example how would it know to test a wide selection of possible values for different variables if they're not explicitly set up?

I imagine it wouldn't be too hard to build up your own data generators for Rails models (or other entities).

Yeah, the easiest way is to generate attributes and instantiate any Rails model like the one below:

    Pbt.assert do
      Pbt.property(name: Pbt.printable_string, age: Pbt.integer(min: 0, max: 100)) do |name:, age:|
        user = User.new(name: name, age: age)
        # write your test here
      end
    end

Re: Show HN: PBT – A property-based testing library for Ruby

#34

Great work, looks really clean! Check out Minithesis [1] and the paper explaining internal shrinking [2]. It will strongly improve your library's shrinking capabilities and prevent users from having to write their own shrinkers for custom objects in most cases. [1] https://github.com/DRMacIver/minithesis [2] https://drops.dagstuhl.de/entities/document/10.4230/LIPIcs.E...

Wow, I didn't know about them. Thanks for letting me know!

Re: Show HN: PBT – A property-based testing library for Ruby

#35
post #29

Lovely stuff, thank you. It would be cool if we could eventually make use of RBS or inline Sorbet or something better than both to get the types for property testing for free.

Good point. There's already such a project to run PBT based on RBS. I'm also keeping an eye on this.

https://github.com/ksss/raap

Re: Show HN: PBT – A property-based testing library for Ruby

#37

Can anyone recommend an introduction to PBT for someone who knows nothing about it? Edited to add: D'oh! There's an explanation in the linked repo.

It's very basic content though, here's the slides of my presentation at RubyKaigi 2024. This also includes the PBT gems's explanations.

https://speakerdeck.com/ohbarye/unlocking-potential-of-prope...

Speaking of my personal story, I used the fast-check documentation and Fred Herbert's book (their links are in the README) to study.

Post reply on HN