3 ms·
That Ruby looks excellent. I hadn't realized the contracts gem existed. So much of what people redundantly cram into test suites could be handled with simple
by grandalf 12y ago
That Ruby looks excellent. I hadn't realized the contracts gem existed.
So much of what people redundantly cram into test suites could be handled with simple contracts.
- Skoofoo 12y agoRuby is duck-typed, so it is advantageous to write code and tests that are not tied to classes at all. http://www.poodr.com/ http://www.poodr.com/ goes in-depth about this.
- grandalf 12y agoWell, the same kind of contracts approach could be used to enforce a duck-typed set of behaviors: [:quacks], [:barks] => Maybe[:flies] Some Rubyists get pedantic about duck typing. It's just a tool to design good systems, not an article of faith.
- masklinn 12y agoYeah the contract here is a form of nominative type checking, it could just as well be structural.
- bshimmin 12y agoIf, like me, you were wondering how contracts.ruby works, the comments in here are quite instructive: https://github.com/egonSchiele/contracts.ruby/blob/master/lib/contracts/decorators.rb https://github.com/egonSchiele/contracts.ruby/blob/master/li...
- grandalf 12y agovery cool.