I have specs that use variables from a shared context. The set up looks something like this:


RSpec.shared_context :handy_things do    
    let(:handy_object)  { ... }


require 'shared_context.rb'
describe 'Something happens' do
  include_context :handy_things

  before(:each) do
    handy_object.option = true

The handy_object from the context is not recognized by Rubymine. I get an inspection message 'Cannot find...'. This is not the end of the world but it annoys me.

Is there a way to let Rubymine know the variables of the shared context are accessible everywhere. Or as workaround to add my shared_context variables to some kind of dictionary so Rubymine doesn't flag it as unknown?


You might try two things:

Replacing your require with require_relative "shared_context" (with the relative path included if they're in different folders, no .rb extension necessary)

Specifying require "./shared_context"

  • Sadly enough, it didn't make any difference. – denBelg Dec 6 '18 at 7:29

Your Answer

