Augmented Usamimi

it { is_expected.to be_blog.written_by(izumin5210) }

【RSpec】yieldを伴うメソッド(ブロック引数 etc.)のテスト

yield matchersなるものがあるらしい.

let(:array) { [1, 2, 3] }
it { expect { |b| array.each(&b) }.to yield_control }
it { expect { |b| array.each(&b) }.to yield_control.exactly(3) }
it { expect { |b| array.each(&b) }.to yield_successive_args(Integer, Integer, Integer) }

べんりだなあ.

`yield` matchers - Built in matchers - RSpec Expectations - RSpec - Relish

Everyday Rails… Aaron Sumner 著 et al. [Leanpub PDF/iPad/Kindle]