Testing Ruby with RSpec: The Complete Guide
What you'll learn
- Utilize test-driven development principles to design and implement clean test specs in Ruby
- Master the syntax and structure of RSpec, the most popular Ruby Gem for testing
- Reduce dependencies in your test suite by mocking objects with class and instance doubles
- Explore the wide collection of RSpec matchers available to test your code
Course content
- Preview13:03
- 00:56About Me
- 09:16Unit Tests vs End-to-End (E2E) Tests
- 01:07Setup rbenv / Ruby on MacOS
- 03:11Installing RSpec
- 00:48Installing Visual Studio Code for MacOS
- 10:17Starting a Project with rspec --init
- 00:28Download Course Files (Optional)
- 05:28Test-Driven Development
- 04:42The describe Method
- 05:33The it Method
- 08:01The expect and eq Methods
- 1 questionThe describe, it and expect Methods
- 07:29Reading Failures
- 08:57Making the Specs Pass
- 9 questionsQUIZ: TDD and RSpec Methods
- 08:01Multiple Examples in Example Group
- 08:23Fixing Failing Specs Again
- 1 questionMaking Specs Pass
- 10:58Reducing Duplication - Before Hooks and Instance Variables
- 04:12Reducing Duplication: Helper Methods
- 06:03Problems With Mutation
- 15:05Reducing Duplication: The let Method
- 04:39Custom Error Messages
- 5 questionsQUIZ: Removing Duplication
- 08:17The context Method and Nested Describes
- 09:07before and after Hooks
- Preview12:00Nested Logic: Hooks
- 1 questionSingle Context Hooks
- 1 questionMulti-Context Hooks
- 08:53Nested Logic: Overwriting Let Variables
Requirements
- Intermediate knowledge of the Ruby programming language (classes, objects, data structures, etc)
- Modern version of Ruby (>2.4)
- Text editor (VSCode is recommended)
Description
Welcome to Testing Ruby with RSpec: The Complete Guide!
This course offers a comprehensive overview of the RSpec testing library for the Ruby programming library. RSpec is the most popular Ruby Gem of all time, with over 300 million downloads to date.
If you're new to the topic, testing is the practice of "writing code that confirms that other code works as expected". Tests control for regressions, which are changes to the code that break the program.
The benefits of testing extend outside of the codebase. Adopting a test-driven approach will also make you a better developer. Tests force you to think critically about the program and its features: the classes, the objects, the methods and more.
Testing Ruby with RSpec begins with the essentials and proceeds to more complex topics including:
Installation
Project Initialization
Test-Driven Development (TDD)
let variables
before and after Hooks
Subjects
Shared Examples
Shared Context
Built-in Matchers
Mocks and Doubles
Instance Doubles
Class Doubles
As a software engineer and consultant who's worked with Ruby for several years, I'm excited to introduce you to the awesome RSpec library, its elegant syntax, and all of its fun quirks.
Thanks for checking out the course!
Who this course is for:
- Intermediate Ruby developers interested in upgrading their skill set
- Programmers who want to explore the fundamentals of testing and TDD
Featured review
Instructor
Hi there, it's nice to meet you! I'm a New York City-based software engineer, author, and consultant who's been teaching on Udemy since 2016.
Like many of my peers, I did not follow a conventional approach to my current role as a web developer. After graduating from New York University in 2013 with a degree in Business Economics and Marketing, I worked as a business analyst, systems administrator, and data analyst for a variety of companies including a digital marketing agency, a financial services firm, and an international tech powerhouse. At one of those roles, I was fortunate enough to be challenged to build several projects with Python and JavaScript.
There was no formal computer science education for me; I discovered coding entirely by accident. A small work interest quickly blossomed into a passionate weekend hobby. Eventually, I left my former role to complete App Academy, a rigorous full-stack web development bootcamp in NYC. The rest is history.
I've always been fascinated by the intersection of technology and education, especially since I've struggled with many of the traditional resources people use to learn how to program. My goal as an instructor is to create comprehensive step-by-step courses that break down the complex details into small, digestible pieces. I like to build the kind of material that I myself would have loved to have when I was starting out.
I'm passionate about teaching and would love to help you discover what code can do for you. See you in a course soon!