Skip to content

Introduction to RSpec: Fix all top level "describe" blocks to "Rspec.describe"#30997

Merged
KevinMulhern merged 3 commits intoTheOdinProject:mainfrom
ZackHoang:introduction_to_rspec/fix_syntax
Apr 21, 2026
Merged

Introduction to RSpec: Fix all top level "describe" blocks to "Rspec.describe"#30997
KevinMulhern merged 3 commits intoTheOdinProject:mainfrom
ZackHoang:introduction_to_rspec/fix_syntax

Conversation

@ZackHoang
Copy link
Copy Markdown
Contributor

Because

Currently, this lesson is mistakenly introducing the top level describe block twices. This PR re-introduces the Rspec.describe syntax to be explicit about how RSpec tests should be written.

This PR

  • Fix all top level describe blocks to RSpec.describe
  • Surround a few words in script tags

Issue

Closes #30988

Additional Information

Pull Request Requirements

  • I have thoroughly read and understand The Odin Project curriculum contributing guide
  • The title of this PR follows the location of change: brief description of change format, e.g. Intro to HTML and CSS lesson: Fix link text
  • The Because section summarizes the reason for this PR
  • The This PR section has a bullet point list describing the changes in this PR
  • If this PR addresses an open issue, it is linked in the Issue section
  • If any lesson files are included in this PR, they have been previewed with the Markdown preview tool to ensure it is formatted correctly
  • If any lesson files are included in this PR, they follow the Layout Style Guide

@github-actions github-actions bot added the Content: Ruby Involves the Ruby course label Apr 17, 2026
@ManonLef ManonLef requested review from a team and CouchofTomato and removed request for a team April 18, 2026 14:23
```

<span id='keyword-it'>The `it` keyword defines an individual example (aka, test)</span>. `it` takes a string argument and is also passed a block. This block is where our expectations of a method are expressed. In this particular case, when we pass 5 and 2 to the `#add` method, we expect it to return 7. This is concisely expressed in our expectation clause, which uses one of [RSpec's equality matchers](http://rspec.info/features/3-12/rspec-expectations/built-in-matchers/equality/), `eql`:
While both syntax are valid, stick to `Rspec.describe` for now. Anyway, <span id='keyword-it'>the `it` keyword defines an individual example (aka, test)</span>. `it` takes a string argument and is also passed a block. This block is where our expectations of a method are expressed. In this particular case, when we pass 5 and 2 to the `#add` method, we expect it to return 7. This is concisely expressed in our expectation clause, which uses one of [RSpec's equality matchers](http://rspec.info/features/3-12/rspec-expectations/built-in-matchers/equality/), `eql`:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While both syntax are valid, stick to Rspec.describe for now.

Nit: Because we're recommending that learners don't use it. What do you think about removing the the second example that shows the describe without the RSpec prefix? does it muddy the water and make things harder to understand?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinMulhern Now that you mention it, I don't think it does for the following reasons:

  1. We did say we want users to use RSpec with its module name without explaining why and some folks might feel strongly to question this, which is a fair concern, and someone will have to explain it on Discord again
  2. It really is an either or option, to use or not to use the module name (Hamlet intended yes) would probably not matter too much for the kind of tests learners will be writing within TOP, both on the Ruby and Rails course. I've never worked with Ruby extensively before so I am not sure if there is any point in which learners will have to research about monkey-patching like you mentioned in this comment of yours. Anyhow, in the spirit of "conventions over configuration" and trusting learners will be able to research their way out, I think it's okay to remove the second example

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those sounds like solid reasons to me! would you like to remove it in this PR?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KevinMulhern I'll get that done in a flash!

project
|__lib
| |__script.rb
| |__calculator.rb
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice spot! 💪

@ZackHoang ZackHoang requested a review from KevinMulhern April 20, 2026 20:40
Copy link
Copy Markdown
Member

@KevinMulhern KevinMulhern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @ZackHoang, this lesson is looking way better 💪

@KevinMulhern KevinMulhern merged commit e58a029 into TheOdinProject:main Apr 21, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content: Ruby Involves the Ruby course

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Introduction to RSpec: Describe a class alternative syntax identical to prior syntax

3 participants