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 8384549
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T17:25:52+00:00 2026-06-09T17:25:52+00:00

my_file_spec.rb: require ‘spec_helper’ require ‘my_file’ module M describe C do it ‘should print everything’

  • 0

my_file_spec.rb:

require 'spec_helper'
require 'my_file'

module M
  describe C do
    it 'should print everything' do
      c = C.new
      c.meth.should == "something"
    end
  end
end

my_file.rb:

module M
  class C
    puts "class TEXT" # label1
    def meth
     puts "method TEXT" # label2
     return "something"
    end
  end
end 

The output is:

class TEXT

M::C
  should print everything

Finished in 0.75 seconds
1 example, 0 failures

And finally the question: “Why wasn’t the label2 — (“method TEXT”) printed after the test had been run?”

P.S.
Ruby192, rspec2

  • 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-09T17:25:53+00:00Added an answer on June 9, 2026 at 5:25 pm

    Try using $stderr.puts "method TEXT". This works for me. Just be aware that it is considered bad practice to write tests that have output that you need to examine manually, but I guess you already know that…

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

Sidebar

Related Questions

I have a Rails RSpec file which looks something like require 'spec_helper' describe Something
My spec require 'spec_helper' describe 'user_sessions/new.html.erb' do let (:user_session) { mock_model(UserSession).as_null_object } before do
This is what my spec file looks like: spec/api/v1/projects_spec.rb require spec_helper describe /api/v1/projects, :type
Here is my current users_controller_spec.rb file require 'spec_helper' describe UsersController do render_views . .
I installed simplecov gem and added require 'simplecov' SimpleCov.start to the spec_helper.rb file, now
my file form element is very simple: $this->archivo = new Zend_Form_Element_File('archivo'); $this->archivo->setLabel('Archivo:') ->setRequired(true) ->setDestination(UPLOAD_PATH)
Rspec obviously hates me. I kinda hate him back. #features/step_definitions/custom_steps.rb Then /^I should see
I'm writing a System::Wrapper module to abstract away from CORE::system and the qx operator.
I'm new in rspec, write rspec-test for View and there's a problem: test fails
I'm trying to test for the presence of a form. I'm new to Rails.

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.