【RSpec】配列要素全てにマッチャを適用する
all
mactcherを利用する.
expect([1, 3, 5]).to all(be_odd)
Compound Matcherも利用可能(Compound Matcherについては『今日から使える!RSpec 3で追加された8つの新機能』を参照されたい).
expect([1, 3, 5]).to all(be_odd.and be < 10) expect([1, 4, 21]).to all(be_odd.or be < 10)
以上,便利マッチャ情報でした.