Test Driven Development (TDD) – Part 2 – Integration Testing

Now that your RSpec environment is all set up, it’s time to start writing some actual tests.  Let’s start with integrations tests, which tests how different components (models, controllers etc.) interact with one another. Create the Integration Folder To start, make future you and any team members really happy by creating an integration folder, within...
Read More

Parsing HTML with Nokogiri

Parsing with Nokogiri is a breeze, especially if you’re super familiar with CSS selectors and you’re good at traversing the DOM. 1. First, you need to install the Nokogiri gem: gem install nokogiri   If you are parsing something that lives remotely, you might want to include the open-uri module, which will make it even...
Read More

Recursion

A method that calls itself. The only time I ever saw something calling itself was outside of my wonderful apartment in the delightfully urine soaked street underneath a blanket. I could not for the life of me grasp how it worked. Yeah, I got the metaphors. “It’s kind of like Inception. You can’t wake out...
Read More

Blocks, Procs & Lambdas

Blocks A block is pretty straightforward. There’s the do … end block: If I’ve got an array of numbers: numbers = [1,2,3,4] numbers.map do |num| num * num end or the single-line curly braces block numbers.each { |num| num * num } Proc (procedure) This is kind of a “named” block that you can save...
Read More