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?
> 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.
Show HN: PBT – A property-based testing library for Ruby
11–20 of 37 posts
Re: Show HN: PBT – A property-based testing library for Ruby
#12Earlier quoted context omitted.
> 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.
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
#13Earlier quoted context omitted.
> 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.
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.
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
#14Very specific question: when tests fail due to a single example, you suggest creating a specific assertion with the given seed. I imagine the seed is used to generate data and depending on the order of your generators, it produces different results. For example, in: PBT.assert(seed = ..) do PBT.property(PBT.integer, PBT.string) ... end Would changing the order of parameters to `property` change the actual test case?
Re: Show HN: PBT – A property-based testing library for Ruby
#15Edited to add: D'oh! There's an explanation in the linked repo.
Re: Show HN: PBT – A property-based testing library for Ruby
#16Earlier quoted context omitted.
> 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.
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
#17Earlier quoted context omitted.
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.
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…
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
#18Earlier quoted context omitted.
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.
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…
Why do you not wish it was all Python?
Re: Show HN: PBT – A property-based testing library for Ruby
#19Very specific question: when tests fail due to a single example, you suggest creating a specific assertion with the given seed. I imagine the seed is used to generate data and depending on the order of your generators, it produces different results. For example, in: PBT.assert(seed = ..) do PBT.property(PBT.integer, PBT.string) ... end Would changing the order of parameters to `property` change the actual test case?
(not OP but I would be surprised if the answer wasn't) yes, because you're changing the order in which the random draws are interpreted. But this isn't a problem in practice because you generally aren't changing the generator in the middle of debugging a failure.
@OP:
I wonder if the README (and possibly runner) should suggest writing a test-case that doesn't rely on PBT when the user wants to preserve a case for future testing.
The issue here is that if you're saving a singular example and it represents a weird corner case, it's totally conceivable that a small change will result in an invisible change to that test case.
Another idea: it'd be great if the test could simply take examples that are failing and add them to a `failing_examples.rb` or some such. I know I'd use a feature like this quite a bit.
Re: Show HN: PBT – A property-based testing library for Ruby
#20Earlier quoted context omitted.
(not OP but I would be surprised if the answer wasn't) yes, because you're changing the order in which the random draws are interpreted. But this isn't a problem in practice because you generally aren't changing the generator in the middle of debugging a failure.
So, this means refactoring becomes potentially difficult. While the gem is still a great accomplishment and very useful, I'd have to engineer my way around this issue before using it with things like a Rails Model which could have changing shape. @OP: I wonder if the README (and possibly runner) should suggest writing a test-case that doesn't rely on PBT when the user wants to preserve a case for future testing. The…