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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:40:31+00:00 2026-06-13T09:40:31+00:00

I like to use RSpec’s include configuration method to include modules which are only

  • 0

I like to use RSpec’s include configuration method to include modules which are
only for namespacing so that I don’t have to use fully-qualified names for their
inner classes and modules. This worked fine with RSpec 2.11.0 in Ruby 1.9.2. But
now on Ruby 1.9.3 this doesn’t work anymore. How can I get it working again?

Here an example foobar_spec.rb:

module Foo
  class Bar
  end
end

RSpec.configure do |config|
  config.include Foo
end

describe Foo::Bar do
  it "should work" do
    Bar.new
  end
end

If you call it by the following command:

rspec foobar_spec.rb

It will work in Ruby 1.9.2 just fine. But it will raise the following error in Ruby 1.9.3:

Failure/Error: Bar.new
     NameError:
       uninitialized constant Bar
  • 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-13T09:40:33+00:00Added an answer on June 13, 2026 at 9:40 am

    This mailing list entry discusses the root change in 1.9.3 as to how constants are looked up, so it looks like a deliberate change.

    You could scope the whole test, like this:

    module Foo
      describe Bar do
        it "should work" do
          Bar.new
        end
      end
    end
    

    As another solution, you could extract the new object creation to a before or let or just define the object as the subject of the test.

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

Sidebar

Related Questions

I have an array of Integers in Java, I would like use only a
I have a common use case that I'd like to write a function for:
in rspec, I have a spec that looks something like this: require 'spec_helper' describe
I am trying to specify in my RSpec tests that my controller should use
I'd like to use rspec to test the validity of a serialized hash, but
I am trying to use https://github.com/rifraf/Vendorize which is run using a command like D:\projects\SomeLibrary\lib>ruby
I have a rspec test to validate a function which works depending on the
I have set up a .rvmrc file for my project, which simply looks like
I'd like to use should_receive as the subject of a spec in RSpec. In
I use the sunspot-rails for search. These is a Rspec looks like: describe GET

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.