Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如果没有断言,是否有办法使RSpec失败?_Rspec - Fatal编程技术网

如果没有断言,是否有办法使RSpec失败?

如果没有断言,是否有办法使RSpec失败?,rspec,Rspec,Minitest已验证 RSpec是否有类似的方式要求断言?您可以为此配置RSpec,请查看以下内容: 及 基本上,您需要在hook之后设置,并检查元数据是否存在预期运行: (url下降时代码的副本) 这是我的看法: RSpec.configure do|config| config.include(Module.new do 属性写入器:期望集计数 def期望值设置计数 @期望值集计数=0 终止 def expect(*) 自我期望集计数+=1 超级的 终止 (完) config.after

Minitest已
验证


RSpec是否有类似的方式要求断言?

您可以为此配置RSpec,请查看以下内容:

基本上,您需要在
hook之后设置
,并检查元数据是否存在预期运行:
(url下降时代码的副本)

这是我的看法:

RSpec.configure do|config|
config.include(Module.new do
属性写入器:期望集计数
def期望值设置计数
@期望值集计数=0
终止
def expect(*)
自我期望集计数+=1
超级的
终止
(完)
config.after do
期望值(期望值集计数)。大于0
终止
终止

变量
具有模拟期望值是否有错误
?您使用的是一个名为
hasnt\u mock\u expections
的本地变量,但不是
has\u mock\u expections
。。。当我运行
RSpec::Core::ExampleGroup::ErrorScopeError时,我也会得到这样的结果:示例(例如“it”块)内或示例范围内运行的构造(例如“before”、“let”等)中没有“example”。它仅在示例组(例如“描述”或“上下文”块)上可用。
RSpec.configure do |config|
  config.after(:each) do
    result = self.example.metadata[:execution_result]
    has_mock_expectations = RSpec::Mocks.space.instance_eval{receivers}.empty?
    if !result[:exception] && !result[:pending_message] && !RSpec::Matchers.last_should && hasnt_mock_expectations
      $stderr.puts "[WARN] No expectations found in example at #{self.example.location}: Maybe you forgot to write `should` in the example?"
    end
  end
end