You are close, but calling include
on top-level you will be calling Module#include
. To get around it you need to remove the original include method so that RSpec's include
gets called instead.
First let's figure out where the system include
comes from:
> method :include
=> #<Method: main.include>
Ok. It looks like it's defined in main
. This is the Ruby top-level object. So let's rename and remove the original include:
> class << self; alias_method :inc, :include; remove_method :include; end
Now we can get down to business:
> require 'rspec'
> inc RSpec::Matchers
> [1,2,3].should include(1)
=> true