{"id":22143566,"url":"https://github.com/brettchalupa/learn_ruby_with_specs","last_synced_at":"2026-04-27T12:05:21.437Z","repository":{"id":60149150,"uuid":"540115264","full_name":"brettchalupa/learn_ruby_with_specs","owner":"brettchalupa","description":"LRWS walks you through learning how to program in Ruby with tests written in RSpec.","archived":false,"fork":false,"pushed_at":"2022-09-25T21:20:11.000Z","size":65,"stargazers_count":0,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-24T11:54:19.550Z","etag":null,"topics":["course","education","exercises","rspec","ruby"],"latest_commit_sha":null,"homepage":"https://lrws.code.brettchalupa.com","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brettchalupa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-09-22T18:22:35.000Z","updated_at":"2023-07-25T15:01:54.000Z","dependencies_parsed_at":"2022-09-25T22:24:45.877Z","dependency_job_id":null,"html_url":"https://github.com/brettchalupa/learn_ruby_with_specs","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/brettchalupa/learn_ruby_with_specs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettchalupa%2Flearn_ruby_with_specs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettchalupa%2Flearn_ruby_with_specs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettchalupa%2Flearn_ruby_with_specs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettchalupa%2Flearn_ruby_with_specs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brettchalupa","download_url":"https://codeload.github.com/brettchalupa/learn_ruby_with_specs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brettchalupa%2Flearn_ruby_with_specs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32335353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["course","education","exercises","rspec","ruby"],"created_at":"2024-12-01T22:13:43.969Z","updated_at":"2026-04-27T12:05:21.421Z","avatar_url":"https://github.com/brettchalupa.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Learn Ruby with Specs (LRWS) 💎♻️✅\n\n```\n          _  .-')    (`\\ .-') /` .-')\n         ( \\( -O )    `.( OO ),'( OO ).\n ,--.     ,------. ,--./  .--. (_)---\\_)\n |  |.-') |   /`. '|      |  | /    _ |\n |  | OO )|  /  | ||  |   |  |,\\  :` `.\n |  |`-' ||  |_.' ||  |.'.|  |_)'..`''.)\n(|  '---.'|  .  '.'|         | .-._)   \\\n |      | |  |\\  \\ |   ,'.   | \\       /\n `------' `--' '--''--'   '--'  `-----'\n```\n\n[logo made with patorjk.com's TAAG](http://patorjk.com/software/taag/)\n\nAn interactive, test-driven course to learn the basics of Ruby with RSpec.\n\nProject links:\n\n- [Website](https://lrws.code.brettchalupa.com)\n- [Source on GitHub](https://github.com/brettchalupa/learn_ruby_with_specs)\n\n## Introduction\n\nThere are so many ways to learn how to code, from reading books to screencasts to taking classes. I've found that I learn best when there's a bit of autonomy for me to research and write the code on my own but with a bit of support and guidance.\n\nThat's what _Learn Ruby with Specs (LRWS)_ is all about. Teaching you the basics of the language, driven by specs. What this means it that the answers aren't provided. You need to investigate and learn on your own. 🕵️‍♀️\n\nBy searching line and learning, you'll better internalize what you're learning. The specs will also ensure correctness—that the code you're writing does what you intend it to. Through this process too, you'll gain familiarity with the way specs are written.\n\n### Notes on Readiness\n\n**Work in Progress** -- use at your own risk! I can't guarantee the ordering and lessons will work and won't change. I'm still working on getting this together.\n\nLessons prefixed with `xx_` means they haven't found their way into the lesson plan yet. They're draft lessons that will eventually be assigned a number in the sequence.\n\n### Prerequisites\n\nIf you are absolutely brand new to programming, I would not start with LRWS because it requires a few things: using the command line, understanding specs/tests, and what to search for online. The specs are guiding and helpful, but they are, at the end of the day, just code. Learning how to code from scratch by reading the specs could be a bit challenging, even though RSpec, the library used in this course, reads a lot like the English language.\n\nSo some prerequisites this assumes:\n\n- A little bit of time spent coding before, [The Ruby Quickstart](https://www.ruby-lang.org/en/documentation/quickstart/) is helpful here\n- Comfort with running commands via the Terminal, Shell, or Command Prompt\n- An understanding of the difference between code and tests/specs. Programmers write tests (a.k.a. specs), which is code that tests what other code does. This helps ensure everything is working correctly.\n\n### Why Ruby\n\nRuby's natural syntax is quite intuitive. It's a mature, multi-purpose language with lots of resources out there. I've been using it for over 10 years full-time, and while it has its shortcomings (as all languages do), it's worthwhile and a lot of fun to use!\n\n### Why RSpec\n\n[RSpec](https://rspec.info) is a behavior driven design (BDD) testing framework for Ruby. If all of that means nothing to you, that's okay. Really. It's just a library (third-party code written by others that we can use, a.k.a. gem in Ruby's parlance) that helps us write tests for our code using an approach that allows us to describe in details words what our code does and why.\n\nRuby has its own baked-in testing library, as most languages do. It's called `Test::Unit`. It certainly works and does the trick. But every single place and codebase I've worked in has used RSpec. I'm not sure if that's anecdotal, but it's what I'm most familiar with, and it allows for a level of verbosity with describing the code's behavior that I think will be particularly helpful for someone learning RSpec.\n\n## Get Started\n\n### Developing Locally (Complex)\n\n0. [Install Ruby](https://www.ruby-lang.org/en/documentation/installation/), I use and prefer [RVM](https://rvm.io)\n1. [Use this repo as a template for youself](https://github.com/brettchalupa/learn_ruby_with_specs/generate), as you'll need your own repo to add your code to\n2. Clone your new repo\n3. Install the needed dependencies with with bundler: `bundle install`\n\nAlternatively, if you don't want to use Git, you can [download an archive of the project](https://github.com/brettchalupa/learn_ruby_with_specs/archive/refs/heads/main.zip) and work from that.\n\n### GitHub Codespaces (Simple, Limited Access)\n\nIf you have access to [GitHub Codespaces](https://github.com/features/codespaces), you can get the project set up and running right in your browser, with Ruby and RSpec installed and ready to go. You can even open Visual Studio Code on your Desktop and work from there.\n\n1. [Use this repo as a template for youself](https://github.com/brettchalupa/learn_ruby_with_specs/generate), as you'll need your own repo to add your code to\n2. From your newly created GitHub repository, click \"Code\", select \"Codespaces\", and click \"Create codespace on main\"\n\n## Run the Specs\n\nIn order to run the specs, use this command:\n\n```\nbin/rspec\n```\n\nThat will run all of the tests in all of the lesson folders. They'll all fail because you haven't written any code yet. You'll have completed this course when all of the specs pass.\n\nWhen a test fails, RSpec outputs a detailed explaination of what failed and why:\n\n```\nlearn_ruby_with_specs(main+*) $ bin/rspec --next-failure\nRun options: include {:last_run_status=\u003e\"failed\"}\nF\n\nFailures:\n\n  1) #hello_world prints a greeting to stdout\n     Failure/Error:\n       expect { hello_world }\n         .to output { \"Hello, world!\" }.to_stdout\n\n       expected block to output to stdout, but did not\n     # ./01_hello_world/hello_world_spec.rb:19:in `block (2 levels) in \u003ctop (required)\u003e'\n\nFinished in 0.01161 seconds (files took 0.04234 seconds to load)\n1 example, 1 failure\n\nFailed examples:\n\nrspec ./01_hello_world/hello_world_spec.rb:18 # #hello_world prints a greeting to stdout\n```\n\nWhen a test passes, it outputs they were run successfully\n\n```\nlearn_ruby_with_specs(main+*) $ bin/rspec 01_hello_world/\n\nRandomized with seed 41099\n\n#hello_world\n  prints a greeting to stdout\n\nFinished in 0.00126 seconds (files took 0.04161 seconds to load)\n1 example, 0 failures\n\nRandomized with seed 41099\n```\n\nSeeing a bunch of failing tests isn't very helpful, so here's how to use this project and progress through the lessons.\n\n## Course Structure\n\nEach lesson is organized into its own folder, prefixed with the number of the lesson. For example, `01_hello_world`. This is the first lesson.\n\nWithin an lesson is one or more files ending in `*_spec.rb`. These are RSpec test files, which contains the failing specs that you need to make pass. Also included are any empty Ruby files that will contain the actual code you write. More on that in a second. So, for example:\n\n```\nlearn_ruby_with_specs(main+) $ ls 01_hello_world/\nhello_world_spec.rb\nhello_world.rb\n```\n\n- `hello_world_spec.rb` contains the test code that I've written, which you won't have to change at all.\n- `hello_world.rb` is the blank Ruby file in which you'll write the code to complete the lesson; your code is always written separate from your specs in Ruby, so good to start now.\n\nA lesson with an `x` after the lsson number, like `04x1_strict_double` is a bonus lesson that immediately follows up that lesson. This keeps an order to lessons while allowing others to be slotted inbetween where appropriate.\n\nA lesson that starts with `xx` means it hasn't yet been placed in the lesson sequence. You're welcome to complete it, but it'll get renamed and moved eventually.\n\n\n## Run the Specs for a Given Exercise\n\nYou can run the specs for a given lesson by targeting the folder, example:\n\n```\nbin/rspec 01_hello_world\n```\n\n## Run the Next Failure\n\nRSpec has a convenient way of only running the next failing spec so you can progress one-by-one to make the tests pass. Do this by running:\n\n```\nbin/rspec --next-failure\n```\n\nWhen you fix the next failing test and run the command again, it'll keep running until it finds the new next failing spec.\n\n## Process\n\nProgress through each lesson by making the tests pass. You'll write Ruby code in the empty Ruby files, run the tests, and then make adjustments if the tests still fail.\n\nSteps:\n\n1. Run the specs for the lesson you're working on\n2. Don't change those specs though!\n3. Write code in the non-spec Ruby files\n4. Run the tests to see if they pass\n5. If they pass, move on to the next lesson\n6. If they fail, there's still work to do\n\nOnce an entire directory's specs pass, that lesson is is complete. ✅\n\nThe course is complete when `bin/rspec` succeeds for all lessons. 🎉\n\n## Run Specs for a Given Exercise\n\nYou can run RSpec against a given lesson folder with: `bin/rspec PATH_TO_FOLDER`. So, for example:\n\n```\nbin/rspec 01_hello_world\n```\n\nWill run the specs for the first lesson.\n\n## Tips \u0026 Advice\n\n- 🥽 Read the specs, then re-read them if you are stuck\n- 🔎 Read the errors and stacktrace, this is an important skill; the errors are often quite helpful\n- 💻 Search online; this mirrors the actual process of coding where you get stuck and need to learn more\n- ⌨️ Use the interactive Ruby REPL to experiment with Ruby; start it with: `irb`\n\n## Resources\n\n- [LRWS Discussion Board](https://github.com/brettchalupa/learn_ruby_with_specs/discussions)\n- [The Ruby Quickstart](https://www.ruby-lang.org/en/documentation/quickstart/)\n- [Learn Ruby the Hard Way](https://learnrubythehardway.org)\n- [My screencasts](https://www.youtube.com/c/Monoso/featured) — I make programming screencasts, specifically about Ruby and RSpec. Playlists that might be of interest:\n  - [Test Driven RSpec](https://www.youtube.com/playlist?list=PLr442xinba86s9cCWxoIH_xq5UE9Wwo4Z) — series on RSpec\n  - [The Fundamentals of Ruby](https://www.youtube.com/playlist?list=PLr442xinba85DO691UMttOgaWVKVEkIZx) — general Ruby programming topics\n\n## Solutions\n\nTODO: create solutions repo\n\n## Getting Updates\n\nI plan to add new lessons to this course from time to time. The best way to get notified is to [watch the project on GitHub](https://github.com/brettchalupa/learn_ruby_with_specs). 👀 This will notify of you new releases.\n\nWhen new releases are made, you can fetch the latest version by following these steps:\n\n1. In your course codebase, ensure you have an `upstream` remote pointing to the source repository: `git remote add upstream git@github.com:brettchalupa/learn_ruby_with_specs.git`\n2. Fetch the latest code from `upstream`: `git fetch upstream`\n3. Merge in the latest code into your repo: `git merge origin/upstream --allow-unrelated-histories`\n\nThat'll pull in the latest changes, which will be new lessons and any adjustments to existing ones. You can then run the specs with `bin/rspec` and work on those new lessons.\n\n## Misc\n\n### Feedback\n\nI'd love to know what you think! Please let me know in [Discussions](https://github.com/brettchalupa/learn_ruby_with_specs/discussions) or [on Twitter](https://twitter.com/brett_codes).\n\n### Contributing\n\nIf you have ideas for new lessons or how to make an existing one better, please open up a Pull Request on GitHub with your proposed changes. Thank you!\n\nA few notes on contributing:\n\n- Because the sequence of the lessons is intentional, we'll have to collaborate on where to place a lesson.\n- Running `bin/spec` on a repo without solutions should output all of the failures for every spec. This means that all referenced constants must be present.\n\n### RSpec Style\n\nThere are some potentially contentious decisions for style when it comes to the RSpec found in this project. They are generally made with intention though.\n\n#### Multiple expectations even in unit tests\n\nI don't follow a hard and fast rule of one expectation per unit test. That's generally followed, but there are times where that makes less sense. How I instead think about it and how it's reflected in these specs are that non-obvious test cases require their own examples and language to describe them.\n\nLet me use an example to be more clear. Let's say there's an example testing an exception is raised in Ruby when an argument is passed that is `nil` or empty string `\"\"`. I'd probably just test both of those in the same example if they have the same output.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettchalupa%2Flearn_ruby_with_specs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrettchalupa%2Flearn_ruby_with_specs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrettchalupa%2Flearn_ruby_with_specs/lists"}