rspec/rspec-core

irb: warn: can't alias context from irb_context.

rlue opened this issue · 1 comments

rlue commented

Subject of the issue

I see that this bug was described in rspec-rails #1693 over four years ago, but I'm still seeing it in the most recent minor versions of Ruby and RSpec (2.7 / 3.9).

When executing irb -r <module>, if the given module is either a) RSpec or b) a script that requires RSpec in turn, then the following warning will be printed to the console:

irb: warn: can't alias context from irb_context.

Note that calling require 'rspec' from within irb does not produce the warning:

irb(main):001:0> require 'rspec'
=> true

Your environment

  • Ruby version: 2.7.0
  • rspec-core version: 3.9.0

Steps to reproduce

$ mkdir bug
$ cd bug
$ bundle init
$ echo "gem 'rspec'" >> Gemfile
$ bundle install
$ bundle exec irb -r rspec

Expected behavior

IRB console should be invoked without warning; i.e.:

$ bundle exec irb -r rspec
irb(main):001:0>

Actual behavior

$ bundle exec irb -r rspec
irb: warn: can't alias context from irb_context.
irb(main):001:0>

This because by default RSpec monkey patches context into the top level, disable monkey patching to silence it.