rspec - 如果没有断言,有没有办法让 RSpec 失败?
问题描述
Minitest 有proveit!
RSpec 是否有类似的方式来要求断言?
解决方案
这是我的看法:
RSpec.configure do |config|
config.include(Module.new do
attr_writer :expectation_set_count
def expectation_set_count
@expectation_set_count ||= 0
end
def expect(*)
self.expectation_set_count += 1
super
end
end)
config.after do
expect(expectation_set_count).to be > 0
end
end
推荐阅读
- android - 下载mananger调试但崩溃
- mysql - 如何在 mysqld_safe is running 场景中设置 mysql 的密码?
- php - .htaccess 为共享主机上的多个域隐藏 .php
- node.js - 如何使用 Angular 6+ nodejs 实现 SSO
- mysql - PHP MySQL:加入 3 个表,但
- laravel-5 - 如何修复 laravel-dump-server 中的 null 给定错误?
- python - Pygame - 奇怪的蛇
- python - What is the Big O Notation of this function?
- python - 如何获得数组中不存在的最小正整数
- java - 检测java线程开始等待并运行一些代码