News for hackers. Stuff that matters.
Re:Show HN: PBT – A property-based testing library for Ruby by jack_riminton on Wednesday May 22, 2024 @12:11PM (#40442687)
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?
Re:Show HN: PBT – A property-based testing library for Ruby by Alifatisk on Wednesday May 22, 2024 @12:35PM (#40442934)
> Rails [...] that's what ruby is most used for

I wish that wasn't the case, I use Ruby heavily for gluing different systems together.

Re:Show HN: PBT – A property-based testing library for Ruby by mikepurvis on Wednesday May 22, 2024 @01:03PM (#40443335)
Outside of language level preferences, is there something about the ecosystem around Ruby that makes it particularly well suited to this? I would have thought Python was the glue language winner just because there are already bindings to the entire universe available for it.
Re:Show HN: PBT – A property-based testing library for Ruby by portpecos on Wednesday May 22, 2024 @01:24PM (#40443582)
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/netlinkrb

I started off with ruby for systems glue but now I have a mix of python and ruby. I wish it was all ruby but the lack of updated “glue gems” and the prevalence of updated “glue eggs” means python really is the “glue language winner”.

Re:Show HN: PBT – A property-based testing library for Ruby by sam2426679 on Wednesday May 22, 2024 @03:21PM (#40445079)
> I wish it was all ruby

Why do you not wish it was all Python?

Re:Show HN: PBT – A property-based testing library for Ruby by ilvez on Thursday May 23, 2024 @05:47AM (#40452619)
My answer to this would be: This is totally personal, but for me Ruby is just a language that allows concisely and readable way express myself to get stuff done. Python just does not read so good and forces to do more boiler-plate. Probably skill-issue, but I knew Python before Ruby, so :shrug: To give out any examples, I would need to have some Python code on me, but I don't :D
Re:Show HN: PBT – A property-based testing library for Ruby by Alifatisk on Thursday May 23, 2024 @06:48AM (#40453043)
I’d say simply because of language preference
Re:Show HN: PBT – A property-based testing library for Ruby by Alifatisk on Wednesday May 22, 2024 @02:18PM (#40444209)
> all I could find was this from 8 years ago: https://github.com/BytemarkHosting/netlinkrb

Yeah, that's so typical. I've almost become used to this, seeing useful gems being very old. To me, I see that as either abandoned (which means I have to fork it and polish it) or the gem is considered complete.

Re:Show HN: PBT – A property-based testing library for Ruby by Alifatisk on Wednesday May 22, 2024 @02:15PM (#40444169)
Ruby is my choice primarily because of its syntax and the powerful meta-programming capabilities. The ecosystem in itself is not any richer or better than Python, no, Python has faaar superior libraries and vibrant support. In my case, I've found ruby-toolbox.com to be useful when I need to scavenge for libraries.
Re:Show HN: PBT – A property-based testing library for Ruby by parentheses on Wednesday May 22, 2024 @12:58PM (#40443251)
I imagine it wouldn't be too hard to build up your own data generators for Rails models (or other entities).
Re:Show HN: PBT – A property-based testing library for Ruby by ohbarye on Thursday May 23, 2024 @09:11AM (#40454261)
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