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

  • SEARCH
  • Home
  • 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 7763161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T14:35:45+00:00 2026-06-01T14:35:45+00:00

I am using Ruby on Rails 3.2.2 and rspec-rails-2.8.1. I would like to output

  • 0

I am using Ruby on Rails 3.2.2 and rspec-rails-2.8.1. I would like to output more information about tests that are going to be run, for example, this way:

# file_name.html.erb
...

# General idea
expected_value = ...

it "... #{expected_value}" do
  ...
end

# Usage that I am trying to implement
expected_page_title =
  I18n.translate(
    'page_title_html'
    :user => @user.firstname
  )

it "displays the #{expected_page_title} page title" do
  view.content_for(:page_title).should have_content(expected_page_title)
end

Note: “Outputs” are intended to be those that are output when you run the rspec . --format documentation command line in the Terminal window.

Is it a right way to test?


Related questions:

  • How to use an instance variable throughout an Example Group, even if it is outside a Example?
  • 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-01T14:35:46+00:00Added an answer on June 1, 2026 at 2:35 pm

    Your question is going to solicit some opinions, but I’ll try and justify mine with some examples.

    Short answer: No, this isn’t how you should be writing RSpec (or any test) descriptions. It’s unconventional and doesn’t add much value for the extra code.

    Long answer: RSpec is a BDD (behavior driven development) tool that was designed to help describe the behavior and intent of your code at the same time as writing automated tests. When you think about the behavior of your code, does adding the expected result to the test description really add much value? If so, maybe you should rethink what you are testing.

    For example, say you have a User class and you want to test a method that concatenates a user’s first and last name:

    describe User do
      expected_full_name = 'Software Guy'
    
      subject { User.new(first: 'Software', last: 'Guy') }
    
      it 'should have the full name #{expected_full_name}' do
        subject.full_name.should == 'Software Guy'
      end
    end
    

    VS

    describe User do
      subject { User.new(first: 'Software', last: 'Guy') }
    
      it 'should have a full name based on the first and last names' do
        subject.full_name.should == 'Software Guy'
      end
    end
    

    In the first test, what does having the expected result in the description really buy you? Does it tell you anything about the expected behavior of a user? Not really.

    Take your example. If I was coming along to your project and saw a test description like that, I would be confused because it doesn’t really tell me what is being tested. I would still need to look at the code to understand what is going on. Compare these two examples:

    it "displays the #{expected_page_title} page title" do
      view.content_for(:page_title).should have_content(expected_page_title)
    end
    

    Which would give you something in the console like:

    “displays the My Awesome Title page title”

    Compare that to:

    it "should translate the page title" do
      view.content_for(:page_title).should have_content(expected_page_title)
    end
    

    Which would be exactly the same in the console as it is in the test:

    “should translate the page title”

    Your obviously free to choose whichever one you want, but I am speaking from a few years of testing experience and highly recommend you don’t do this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Ruby on Rails 3.0.9, RSpec-rails 2 and FactoryGirl. I would like
I am using Ruby on Rails 3.0.9 and RSpec 2. I would like to
I am using Ruby on Rails 3.0.9 and RSpec 2. I would like to
I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2. I would like
I am using Ruby on Rails 3.1.0 and the rspec-rails 2 gem. I would
I am using Ruby on Rails 3.1.0 and the rspec-rails 2 gem. I would
I am using Ruby on Rails 3.0.9 and RSpec 2. I know that there
I am using Ruby on Rails 3.2.2 and rspec-rails-2.8.1. In order to make my
I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1, capybara-1.1.2 and factory_girl-2.6.3. I have
I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2 with the Selenium

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.