From the RSpec docs:
require 'rspec/expectations'
RSpec::Matchers.define :be_a_multiple_of do |expected|
  match do |actual|
    actual % expected == 0
  end
end
RSpec.describe 9 do
  it { is_expected.to be_a_multiple_of(3) }
end
What is going on here? When defining a matcher what is this section of code:
:be_a_multiple_of do |expected|
      match do |actual|
        actual % expected == 0
      end
    end
Is that a Proc? What is being passed to the .define method? What is |expected|? Is that the 3 that we pass into the method? How does :be_a_multiple_of become a method? There seems to be a lot of metaprogrammy magic going on so I'd like to just figure out what is happening.
What is this match do method?