Codecast: Create a RubyGem 57: Write the harvest_totals method
Channel: Stateless Code
Date: 2021-09-21

This is the 57th video in the NerdDice create a RubyGem series. In this video Mike reviews the concept of "duck-typing" in Ruby and creates a method called harvest_totals that takes in a collection of items that respond to "total". Then he creates a DuckTypeTotals module in spec/support to test that the duck-typing works as expected.

This video covers:
00:00:12 Introduction, discussion of duck-typing as it relates to requirement
00:04:08 Create spec file and write "it" statements
00:05:43 Implement returns expected values spec with deterministic seed
00:09:02 Implement the harvest totals method to make first spec pass
00:11:18 Implement error handling specs
00:17:13 Implement error handling in method to make specs pass
00:23:47 Create DuckTypeTotals module in spec/support directory with Group, GoodDuck, and BadDuck classes
00:28:40 Require DuckTypeTotals module in spec
00:29:47 Implement duck-typed object spec
00:30:14 Implement re-raises error spec
00:32:05 Fix RuboCop errors, add exception for intentional redundant self
00:33:13 Commit, fix benchmark failure, amend commit, and force-push


This video is CC0 - No rights reserved. (YouTube doesn't allow this option when publishing.) All code is released under the UNLICENSE.  Stateless Code denies the concept of "intellectual property". Copying is not stealing.