🖥

#Rails + #rspec : How to use "change" syntax with not_to condition Tri

2019/11/17に公開

One idea. use change syntax and expect "not to change".

BAD

it do
  expect { subject }.to change { some }.to(true).and_not_to change {
    some.count
  }.by(0)
end

GOOD

it do
  expect { subject }.to change { some }.to(true).and change {
    some.count
  }.by(0)
end

Rspec の change 記法で not_to の否定文をチェーンできない or しづらいので無理やり肯定系で書いてみるのはいかが?

Original by Github issue

https://github.com/YumaInaura/YumaInaura/issues/2727

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

https://line.me/ti/g2/eEPltQ6Tzh3pYAZV8JXKZqc7PJ6L0rpm573dcQ

Twitter

https://twitter.com/YumaInaura

公開日時

2019-11-17

Discussion