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

How to Use Ruby Any, All, None & One

Today you’ll learn about 4 Enumerable methods that will help you check a conditional statement against an array of elements, a hash, or any other objects that include the Enumerable module. These 4 methods return either true or false. Let’s do this! Contents Ruby All Method If you want to check if all the strings … Read more

How to Use the Ruby Grep Method (With Examples)

Let’s talk about the grep method. What can this method do for you? You can use Grep to filter enumerable objects, like Arrays & Ranges. “But select already does that!” Yes, but grep works in a different way & it produces different results. Let’s see some examples. Ruby Grep Method Examples Given this array: You … Read more

What is Ruby on Rails & Why Is It Useful?

Ruby on Rails (sometimes RoR) is the most popular open-source web application framework. It’s built with the Ruby programming language. You can use Rails to help you build applications, from simple to complex, there are no limits to what you can accomplish with Rails! What is a framework? A framework is a collection of code, … Read more