Skip to content

Introduction to RSpec: Explain Why One expect Clause per Test Case #31265

Description

@ZackHoang

Checks

Describe your suggestion

This section of this lesson talks about how each test case should only have one expect clause per test case.

Write your expectation using expect. The expect method is also chained with .to for positive expectations, or .to_not/.not_to for negative expectations. We prefer .not_to. Also, limit one expect clause per test case.

I understand that while Ruby is very opinionated, I was wondering if this is actually the case for every Ruby project there is. While this is a very small detail, I'm worried that this phrase might convince learners to split their test cases thinner than needed. I also did a quick Google and on a quick glance, I did not find any result talking about how Rspec only expect one expect clause per test case.

For context, I mostly followed the Node path after being stuck on the Ruby path for a while so I might not be seeing the entire picture but the Node path did not ask learners that there should only be one assertion per test case at all.

I even found an article on Stackoverflow talking about how devs should not limit their assertions to one test case each.

I think we should either remove this section entirely, or add a small paragraph talking about how one should structure their assertions around their tests.

Path

Ruby / Rails

Lesson Url

https://www.theodinproject.com/lessons/ruby-introduction-to-rspec

(Optional) Discord Name

No response

(Optional) Additional Comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions