Ruby Interview Coding Challenges & How to Solve Them

Doing coding challenges is an excellent way to improve your Ruby & problem-solving skills. And to prepare for coding interviews! Why? Because during a challenge you put all your focus on solving 1 specific problem. You don’t have to worry about anything else. This kind of practice will expand your thinking skills, allow you to … Read more

How to Check If a Variable is Defined in Ruby

Ruby has this defined? keyword that helps you check if a variable is defined or not. If the variable exists you’ll get its type: apple = 1 defined?(apple) # “local-variable” If it doesn’t you’ll get nil: defined?(bacon) # nil This is like Javascript’s typeof operator. If you want to know the class of an object … Read more

How to Use RSpec Mocks (Step-By-Step Tutorial)

What is a mock in RSpec? (Or a mock in general, because this isn’t a concept unique to RSpec.) A mock is an object used for testing. You use mocks to test the interaction between two objects. Instead of testing the output value, like in a regular expectation. For example: You’re writing an API that … Read more

How to Read & Parse CSV Files With Ruby

CSV stands for “Comma-Separated Values”. It’s a common data format which consist of rows with values separated by commas. It’s used for exporting & importing data. For example: You can export your Gmail contacts as a CSV file, and you can also import them using the same format. This is what a CSV file looks … Read more