In Passing One Matcher Into Another, you saw how RSpec defines a_value_within as an alias of the be_within matcher. It allows you to write expectations that read smoothly like the following one:
|||expect(results).to start_with a_value_within(0.1).of(Math::PI)|
You can use the same techniques in your own projects. Just call alias_matcher with the name of the new matcher first, followed by the existing one (the same order you’d use with Ruby’s alias_method):
|||RSpec::Matchers.alias_matcher :an_admin, :be_an_admin|
This snippet defines a new method, an_admin, which wraps the existing be_an_admin matcher (a dynamic predicate ...