irbでRSpecのmatcher を使えるようにする
tl;dr
irb で以下の2行を実行するだけ。
require 'rspec/expectations' include RSpec::Matchers
例
$ rails c Loading development environment (Rails 7.1.5.1) irb(main):001> require 'rspec/expectations' irb(main):002> include RSpec::Matchers irb(main):003> irb(main):004> expect(1).to eq(1) => true
背景
コードレビュー中など、ふとした時に RSpec の matcher を試したくなることがある。
しかしわざわざ新しくファイルを作ってテストを実行するのは面倒。