繁体   English   中英

如何避免测试重复?

[英]How do I avoid test duplication?

该代码出现在我的两个规范中:

it 'does not add the reply' do
  expect { subject }.not_to change { replies.length }
end

it 'does not publish the event' do
  expect { subject }.not_to publish_event(:reply_event)
end

如何编写规格以避免重复?

您可以在以下博客中创建类似于详细显示的助手

https://niallburkley.com/blog/rspecs-shared_examples_for/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM