Blocks allow passing anonymous functions to methods. A block is executed using yield. yield can pass arguments to the block. Block syntax can use do/end or curly braces. Checking for a block uses block_given?. Stubs in testing replace real objects with test doubles that return hardcoded values. This allows isolating the code under test and simulating external dependencies.