在没有 `rspec-mocks` 或 `rspec-expectations` 的情况下使用 `rspec-core`
最常见的是将 `rspec-core` 与 `rspec-mocks` 和 `rspec-expectations` 一起使用,如果可用,`rspec-core` 会自动加载这些库,但 `rspec-core` 也可以很好地在没有这两个 gem 安装的情况下使用。
仅在安装了 `rspec-core` 时才使用它
假设仅安装了 `rspec-core`
并且一个名为“core_only_spec.rb”的文件包含
RSpec.describe "Only rspec-core is available" do
it "it fails when an rspec-mocks API is used" do
dbl = double("MyDouble")
end
it "it fails when an rspec-expectations API is used" do
expect(1).to eq(1)
end
end
当我运行 `rspec core_only_spec.rb` 时
则输出应包含“2 个示例,2 个失败”。