如何从 IRB 控制台使用 RSpec?

How to use RSpec from the IRB console?

我想在 IRB 控制台中尝试 RSpec 文档中所有不错的 oneliners。

如何在IRB控制台执行它们?

请提供一个不基于 Rails 的解决方案,只是简单的 Ruby。

这可能正是您要找的:

Standalone
require "rspec/mocks/standalone" to expose the API at the top level (e.g. main) outside the RSpec environment in a REPL like IRB or in a one-off script.

https://relishapp.com/rspec/rspec-mocks/v/3-9/docs/outside-rspec/standalone