Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8673075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:21:51+00:00 2026-06-12T19:21:51+00:00

I just started writing RSpec tests, and I came across thoughtbot’s Style Guide ,

  • 0

I just started writing RSpec tests, and I came across thoughtbot’s Style Guide, which recommends against let, let!, before and subject (among others).

I’ve also read similar suggestions in a few other places (including the old RSpec docs warning about before(:all)), but I can’t seem to find the actual argument against them.

So the question is:

Why shouldn’t I be using those methods in my tests? What is the better approach?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T19:21:53+00:00Added an answer on June 12, 2026 at 7:21 pm

    Interesting question; something that I want to know more about as well…. So dug in a bit, and here is what I uncovered:

    Thoughtbot style guide dictum about let, etc.

    1. In an earlier version of the style guide, there’s more to that statement:

      Avoid its, let, let!, specify, subject, and other DSLs. Prefer explicitness and consistency.

    2. ThoughtBot folks made a post on let name let’s not. See also the link to the Github Commit Comment conversation

    3. On one of their recent podcasts Joe Ferris, the CTO of ThoughtBot, explains why it’s not a good idea to use let and subject. Check out the podcast titled Something Else Was Smellier from the 27m37s mark onwards for the next 5 minutes.

    4. Testing Anti-pattern ‘Mystery Guest’ which is dealt with in detail in an older ThoughtBot blogpost is the main reason for why not to use let and its cousins.

    To summarize my understanding of all the above very succinctly:

    Using let et al makes it difficult to understand what’s happening
    within the test on a quick glance, and requires the person to spend
    some time in making the connections.

    Write tests such that it is easy to understand without much effort.

    In addition, using let liberally in tests results in over-sharing among the tests, as well as makes implicit common fixtures – i.e. having a common fixture to start with for every test being written even when it does not apply.

    before(:all)

    The argument against using before(:all) is straight-forward. As explained in the old rspec documentation:

    Warning: The use of before(:all) and after(:all) is generally discouraged because it introduces dependencies between the Examples. Still, it might prove useful for very expensive operations if you know what you are doing.

    before(:all) gets executed only once at the start of the ExampleGroup. As such there is a potential to inadvertently introduce dependencies between the Examples. Thoughtbot’s assertion about the tests not being easy to understand applies to this as well.

    In conclusion, the advise for writing better specs seems to be:

    1. Write tests such that they are easy to understand on a quick glance.
    2. Know what you are doing.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just started writing socket programs. Came to know that single UDP packet
I've just started writing tests for my iOS app, I'm using Xcode4 and OCUnit.
I've just started writing my first app. I have EditText field in which i
I just started out writing my first unit tests with JUnit and I ran
I just started writing powershell scripts for Citrix XenServer. However, I can only find
I've just started writing a reasonably straightforward site using sinatra. My problem is that
I've just started writing GAE web applications in Java so I'm kind of new
I'm just getting started on writing functions instead of writing everything inline. Is this
I have just started learning Jquery and am new to writing javascript (I am
I have just installed C# 2008 Express Edition 2008 and started writing code. My

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.