作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我找到了 .and
方法对于链接许多期望非常有用。
expect {
click_button 'Update Boilerplate'
@boilerplate_original.reload
} .to change { @boilerplate_original.title }.to('A new boilerplate')
.and change { @boilerplate_original.intro }.to('Some nice introduction')
.and_not change { @boilerplate_original.intro }
最佳答案
不,没有and_not
并且没有通用否定运算符,如 https://github.com/rspec/rspec-expectations/issues/493 中所述
但是,有一种机制可以定义现有匹配器的否定版本,如 http://www.rubydoc.info/github/rspec/rspec-expectations/RSpec/Matchers.define_negated_matcher 中所述。 ,您可以将其与 and
一起使用.
全套复合匹配器记录在 https://www.relishapp.com/rspec/rspec-expectations/v/3-4/docs/compound-expectations
关于RSpec:是否有 `and change` 没有,例如 `and_not to change` ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34967391/
我找到了 .and方法对于链接许多期望非常有用。 expect { click_button 'Update Boilerplate' @boilerplate_original.reload
我是一名优秀的程序员,十分优秀!